Răsfoiți Sursa

design fixes

milan jurkulák 2 ani în urmă
părinte
comite
cf87105738

+ 20 - 1
build.gradle.kts

@@ -10,6 +10,23 @@ plugins {
 group = libs.versions.packageName.get()
 version = libs.versions.packageVersion.get()
 
+//kotlin {
+//    jvmToolchain(8)
+//    jvmToolchain {
+//        (this as JavaToolchainSpec).apply {
+//            languageVersion.set(JavaLanguageVersion.of(8))
+//        }
+//    }
+//    compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
+//}
+
+//java {
+//    toolchain {
+//        languageVersion.set(JavaLanguageVersion.of(8))
+//    }
+//    targetCompatibility = JavaVersion.VERSION_1_8
+//}
+
 allprojects {
     repositories {
         maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
@@ -51,10 +68,12 @@ allprojects {
         implementation(libs.coil.compose)
         implementation(libs.coil.mp)
 //        implementation(libs.coil.gif)
-        implementation(libs.coil.network.ktor)
+        implementation(libs.coil.network.okhttp)
         // glide
 //        implementation(libs.glide)
+//        implementation(libs.landscapist.glide)
         // palette
+//        implementation(libs.landscapist.palette)
         implementation(libs.material.kolor)
         // json
         implementation(libs.google.gson)

+ 16 - 13
gradle/libs.versions.toml

@@ -18,6 +18,7 @@ materialKolor = "1.7.0"
 coil3 = "3.0.0-alpha06"
 ktor = "3.0.0-wasm2"
 kotlinxCoroutinesSwing = "1.8.0"
+#lanscapist = "2.3.8"
 #generativeai = "0.5.0-1.0.0-wasm"
 #compose-webview = "1.9.20"
 #decompose = "3.0.0-alpha07"
@@ -25,27 +26,29 @@ kotlinxCoroutinesSwing = "1.8.0"
 [libraries]
 gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
 gradle-api = { module = "com.android.tools.build:gradle-api", version.ref = "gradle" }
-#gradle-kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
-#dbus-java-core = { module = "com.github.hypfvieh:dbus-java-core", version = "5.0.0" }
-#dbus-java-transport-native-unixsocket = { module = "com.github.hypfvieh:dbus-java-transport-native-unixsocket", version = "5.0.0" }
-ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
-coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil3" }
-coil-compose-core = { module = "io.coil-kt.coil3:coil-compose-core", version.ref = "coil3" }
-coil-network-ktor = { module = "io.coil-kt.coil3:coil-network-ktor", version.ref = "coil3" }
-coil-mp = { module = "io.coil-kt.coil3:coil", version.ref = "coil3" }
-#coil-gif = { module = "io.coil-kt.coil3:coil-gif", version = "2.2.7" }
+kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinxCoroutinesSwing" }
 mozilla-rhino = { module = "org.mozilla:rhino", version = "1.7.13" }
 okhttp-client = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp3" }
 material-kolor = { module = "com.materialkolor:material-kolor", version.ref = "materialKolor" }
 google-gson = { module = "com.google.code.gson:gson", version = "2.8.9" }
-font-icons-awesome = { module = "br.com.devsrsouza.compose.icons:font-awesome-desktop", version = "1.1.0" }
+ini4j = { module = "org.ini4j:ini4j", version = "0.5.4" }
+ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
+coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil3" }
+coil-compose-core = { module = "io.coil-kt.coil3:coil-compose-core", version.ref = "coil3" }
+coil-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp", version.ref = "coil3" }
+coil-mp = { module = "io.coil-kt.coil3:coil", version.ref = "coil3" }
+coil-gif = { module = "io.coil-kt.coil3:coil-gif", version = "2.2.7" }
+
+#landscapist-glide = { module = "com.github.skydoves:landscapist-glide", version.ref = "lanscapist" }
+#landscapist-palette = { module = "com.github.skydoves:landscapist-palette", version.ref = "lanscapist" }
+#font-icons-awesome = { module = "br.com.devsrsouza.compose.icons:font-awesome-desktop", version = "1.1.0" }
+#gradle-kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
+#dbus-java-core = { module = "com.github.hypfvieh:dbus-java-core", version = "5.0.0" }
+#dbus-java-transport-native-unixsocket = { module = "com.github.hypfvieh:dbus-java-transport-native-unixsocket", version = "5.0.0" }
 #compose-webview = { module = "io.github.kevinnzou:compose-webview-multiplatform", version.ref = "compose-webview" }
 #decompose = { module = "com.arkivanov.decompose:decompose", version.ref = "decompose" }
 #decompose-extensions-compose = { module = "com.arkivanov.decompose:extensions-compose", version.ref = "decompose" }
-ini4j = { module = "org.ini4j:ini4j", version = "0.5.4" }
-kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinxCoroutinesSwing" }
 #google-generativeai = { module = "dev.shreyaspatil.generativeai:generativeai-google-jvm", version.ref = "generativeai" }
-glide = { module = "com.github.bumptech.glide:glide", version = "4.16.0" }
 
 #// open ai
 #//        implementation("com.aallam.openai:openai-client:3.8.2")

+ 1 - 1
src/main/kotlin/eu/mjdev/desktop/components/appsmenu/AppsMenu.kt

@@ -71,7 +71,7 @@ fun AppsMenu(
                 .padding(menuPadding)
                 .background(appMenuBackgroundColor.copy(alpha = 0.7f), RoundedCornerShape(24.dp))
                 .clip(RoundedCornerShape(24.dp))
-                .border(2.dp, appMenuBackgroundColor, RoundedCornerShape(24.dp))
+                .border(2.dp, Color.White.copy(0.1f), RoundedCornerShape(24.dp))
         ) {
             Column(
                 modifier = Modifier.fillMaxSize()

+ 3 - 1
src/main/kotlin/eu/mjdev/desktop/components/background/BackgroundImage.kt

@@ -29,6 +29,7 @@ fun BackgroundImage(
     fadeOutDuration: Long = 5000L,
     backgroundColor: Color = Color.SuperDarkGray,
     backgrounds: List<Any> = emptyList(),
+    onError: (Throwable) -> Unit = { e -> e.printStackTrace() },
     onChange: (bck: Any?) -> Unit = {}
 ) = Box(
     modifier = modifier.background(backgroundColor)
@@ -45,7 +46,8 @@ fun BackgroundImage(
         ImageAny(
             modifier = modifier,
             contentScale = ContentScale.Crop,
-            src = value
+            src = value,
+            onFail = onError
         )
     }
     launchedEffect(currentBackground.value) {

+ 7 - 0
src/main/kotlin/eu/mjdev/desktop/components/controlcenter/ControlCenter.kt

@@ -129,6 +129,13 @@ fun ControlCenter(
                             contentBackgroundColor = Color.Transparent
                         ) {
                             Row {
+                                Divider(
+                                    modifier = Modifier
+                                        .fillMaxHeight()
+                                        .width(2.dp),
+                                    color = Color.White.copy(0.1f),
+                                    thickness = 2.dp
+                                )
                                 Box(
                                     modifier = Modifier.width(controlCenterExpandedWidth),
                                 ) {

+ 82 - 57
src/main/kotlin/eu/mjdev/desktop/components/desktoppanel/DesktopPanel.kt

@@ -49,16 +49,25 @@ fun DesktopPanel(
     iconOuterPadding: PaddingValues = PaddingValues(2.dp),
     panelAlpha: Float = 0.7f,
     showMenuIcon: Boolean = true,
+    panelContentPadding: PaddingValues = PaddingValues(4.dp),
     panelState: VisibilityState = rememberVisibilityState(),
     enterAnimation: EnterTransition = fadeIn() + slideInVertically(initialOffsetY = { it }),
     exitAnimation: ExitTransition = slideOutVertically(targetOffsetY = { it }) + fadeOut(),
+    tooltipHeight: Dp = 64.dp,
     tooltipData: MutableState<Any?> = mutableStateOf(null),
     onTooltip: (item: Any?) -> Unit = { item -> tooltipData.value = item },
     panelHeight: (visible: Boolean) -> Dp = { visible ->
-        if (visible) iconSize.height + iconOuterPadding.height else dividerWidth
+        if (visible) iconSize.height + iconOuterPadding.height + tooltipHeight + panelContentPadding.height
+        else dividerWidth
     },
     onMenuIconClicked: () -> Unit = {},
     onFocusChange: (Boolean) -> Unit = {},
+    tooltipConverter: (Any?) -> TooltipData = { item ->
+        when (item) {
+            is App -> TooltipData(title = item.name, description = item.comment)
+            else -> TooltipData(title = item.toString())
+        }
+    }
 ) = ChromeWindow(
     visible = true,
     enterAnimation = enterAnimation,
@@ -78,75 +87,91 @@ fun DesktopPanel(
         orientation = Vertical,
         state = panelState,
     ) { isVisible ->
-        if (!isVisible) {
-            Divider(
-                modifier = Modifier
-                    .fillMaxWidth()
-                    .height(dividerWidth),
-                color = Color.Transparent,
-                thickness = dividerWidth
-            )
-        } else {
+        Divider(
+            modifier = Modifier
+                .fillMaxWidth()
+                .height(dividerWidth),
+            color = Color.Transparent,
+            thickness = dividerWidth
+        )
+        if (isVisible) {
             TooltipArea(
                 modifier = Modifier.fillMaxWidth().wrapContentHeight(),
                 tooltip = {
-                    // todo more types
-                    when (tooltipData.value) {
-                        is App -> DesktopPanelAppTooltip(tooltipData.value as App)
-                        else -> {}
-                    }
+                    DesktopPanelTooltip(
+                        tooltipData.value,
+                        converter = tooltipConverter
+                    )
                 },
                 tooltipPlacement = TooltipPlacement.CursorPoint(
                     alignment = Alignment.TopEnd,
                     offset = DpOffset(32.dp, 32.dp)
                 )
             ) {
-                TopShadow(
-                    modifier = Modifier.fillMaxWidth()
-                        .wrapContentHeight()
-                        .onPlaced(panelState::onPlaced),
-                    color = shadowColor,
-                    contentBackgroundColor = backgroundColor.copy(alpha = panelAlpha)
-                ) {
+                Column {
                     Box(
-                        modifier = Modifier.fillMaxWidth().wrapContentHeight().background(
-                            brush = Brush.verticalGradient(
-                                colors = listOf(
-                                    backgroundColor.copy(alpha = 0.3f),
-                                    backgroundColor.copy(alpha = 0.7f),
-                                    backgroundColor.copy(alpha = 0.3f),
-                                )
-                            )
-                        )
+                        modifier = Modifier.fillMaxWidth()
+                            .height(tooltipHeight)
+                    )
+                    TopShadow(
+                        modifier = Modifier.fillMaxWidth()
+                            .wrapContentHeight()
+                            .onPlaced(panelState::onPlaced),
+                        color = shadowColor,
+                        contentBackgroundColor = backgroundColor.copy(alpha = panelAlpha)
                     ) {
-                        if (showMenuIcon) {
-                            DesktopMenuIcon(
-                                modifier = Modifier.align(Alignment.CenterStart),
-                                iconColor = iconColor,
-                                iconBackgroundColor = iconBackgroundColor,
-                                iconSize = iconSize,
-                                iconPadding = iconPadding,
-                                iconOuterPadding = iconOuterPadding,
-                                onTooltip = onTooltip,
-                                onClick = onMenuIconClicked
+                        Column {
+                            Divider(
+                                modifier = Modifier
+                                    .fillMaxWidth()
+                                    .height(2.dp),
+                                color = Color.White.copy(0.1f),
+                                thickness = 2.dp
                             )
-                        }
-                        DesktopPanelFavoriteApps(
-                            modifier = Modifier.align(Alignment.Center),
-                            iconColor = iconColor,
-                            iconBackgroundColor = iconBackgroundColor,
-                            iconSize = iconSize,
-                            iconPadding = iconPadding,
-                            iconOuterPadding = iconOuterPadding,
-                            onTooltip = onTooltip
-                        )
-                        DesktopPanelLanguage(
-                            modifier = Modifier.align(Alignment.CenterEnd),
-                            onTooltip = onTooltip,
-                            onClick = {
-                                // todo
+                            Box(
+                                modifier = Modifier.fillMaxWidth()
+                                    .wrapContentHeight()
+                                    .background(
+                                        brush = Brush.verticalGradient(
+                                            colors = listOf(
+                                                backgroundColor.copy(alpha = 0.3f),
+                                                backgroundColor.copy(alpha = 0.7f),
+                                                backgroundColor.copy(alpha = 0.3f),
+                                            )
+                                        )
+                                    )
+                                    .padding(panelContentPadding)
+                            ) {
+                                if (showMenuIcon) {
+                                    DesktopMenuIcon(
+                                        modifier = Modifier.align(Alignment.CenterStart),
+                                        iconColor = iconColor,
+                                        iconBackgroundColor = iconBackgroundColor,
+                                        iconSize = iconSize,
+                                        iconPadding = iconPadding,
+                                        iconOuterPadding = iconOuterPadding,
+                                        onTooltip = onTooltip,
+                                        onClick = onMenuIconClicked
+                                    )
+                                }
+                                DesktopPanelFavoriteApps(
+                                    modifier = Modifier.align(Alignment.Center),
+                                    iconColor = iconColor,
+                                    iconBackgroundColor = iconBackgroundColor,
+                                    iconSize = iconSize,
+                                    iconPadding = iconPadding,
+                                    iconOuterPadding = iconOuterPadding,
+                                    onTooltip = onTooltip
+                                )
+                                DesktopPanelLanguage(
+                                    modifier = Modifier.align(Alignment.CenterEnd),
+                                    onTooltip = onTooltip,
+                                    onClick = {
+                                        // todo
+                                    }
+                                )
                             }
-                        )
+                        }
                     }
                 }
             }

+ 0 - 47
src/main/kotlin/eu/mjdev/desktop/components/desktoppanel/DesktopPanelAppTooltip.kt

@@ -1,47 +0,0 @@
-package eu.mjdev.desktop.components.desktoppanel
-
-import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.wrapContentSize
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
-import eu.mjdev.desktop.components.text.TextAny
-import eu.mjdev.desktop.provider.DesktopProvider
-import eu.mjdev.desktop.provider.DesktopProvider.Companion.LocalDesktop
-import eu.mjdev.desktop.provider.data.App
-
-@Composable
-fun DesktopPanelAppTooltip(
-    app: App?,
-    api: DesktopProvider = LocalDesktop.current
-) = Box(
-    modifier = Modifier
-        .wrapContentSize()
-        .background(api.currentUser.theme.backgroundColor, RoundedCornerShape(8.dp))
-        .padding(4.dp)
-) {
-    if (app != null) {
-        Column {
-            if (app.name.isNotEmpty()) {
-                TextAny(
-                    text = app.name,
-                    color = Color.White,
-                    fontSize = 14.sp
-                )
-            }
-            if (app.comment.isNotEmpty()) {
-                TextAny(
-                    text = app.comment,
-                    color = Color.White,
-                    fontSize = 12.sp
-                )
-            }
-        }
-    }
-}

+ 2 - 1
src/main/kotlin/eu/mjdev/desktop/components/desktoppanel/DesktopPanelIcon.kt

@@ -40,6 +40,7 @@ fun DesktopPanelIcon(
     iconPadding: PaddingValues = PaddingValues(4.dp),
     iconOuterPadding: PaddingValues = PaddingValues(2.dp),
     iconState: MutableState<Boolean> = remember { mutableStateOf(false) },
+    contentDescription: String? = null,
     onToolTip: (item: Any?) -> Unit = {},
     onClick: () -> Unit,
 ) {
@@ -51,7 +52,7 @@ fun DesktopPanelIcon(
             .clipRect()
             .onPointerEvent(PointerEventType.Enter) {
                 iconState.value = true
-                onToolTip(app)
+                onToolTip(app ?: contentDescription)
             }
             .onPointerEvent(PointerEventType.Exit) {
                 iconState.value = false

+ 56 - 0
src/main/kotlin/eu/mjdev/desktop/components/desktoppanel/DesktopPanelTooltip.kt

@@ -0,0 +1,56 @@
+package eu.mjdev.desktop.components.desktoppanel
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.wrapContentSize
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import eu.mjdev.desktop.components.text.TextAny
+import eu.mjdev.desktop.provider.DesktopProvider
+import eu.mjdev.desktop.provider.DesktopProvider.Companion.LocalDesktop
+
+@Composable
+fun DesktopPanelTooltip(
+    item: Any?,
+    api: DesktopProvider = LocalDesktop.current,
+    converter: (Any?) -> TooltipData = { TooltipData(description = it.toString()) }
+) = Box(
+    modifier = Modifier
+        .wrapContentSize()
+        .background(api.currentUser.theme.backgroundColor, RoundedCornerShape(8.dp))
+        .border(2.dp, Color.White.copy(0.2f), RoundedCornerShape(8.dp))
+        .padding(8.dp)
+) {
+    if (item != null) {
+        with(converter(item)) {
+            Column {
+                if (title.isNotEmpty()) {
+                    TextAny(
+                        text = title,
+                        color = Color.White,
+                        fontSize = 14.sp
+                    )
+                }
+                if (description.isNotEmpty()) {
+                    TextAny(
+                        text = description,
+                        color = Color.White,
+                        fontSize = 12.sp
+                    )
+                }
+            }
+        }
+    }
+}
+
+data class TooltipData(
+    val title: String = "",
+    val description: String = ""
+)

+ 1 - 0
src/main/kotlin/eu/mjdev/desktop/components/desktoppanel/applets/DesktopMenuIcon.kt

@@ -24,6 +24,7 @@ fun DesktopMenuIcon(
     modifier = modifier
 ) {
     DesktopPanelIcon(
+        contentDescription = "System menu",
         icon = "menu",
         iconColor = iconColor,
         iconBackgroundColor = iconBackgroundColor,

+ 2 - 1
src/main/kotlin/eu/mjdev/desktop/windows/MainWindow.kt

@@ -53,7 +53,8 @@ fun MainWindow(
                     }
                 },
             backgroundColor = api.currentUser.theme.backgroundColor,
-            backgrounds = api.appsProvider.backgrounds + api.currentUser.config.desktopBackgroundUrls,
+            backgrounds = //api.appsProvider.backgrounds +
+            api.currentUser.config.desktopBackgroundUrls,
             switchDelay = api.currentUser.theme.backgroundRotationDelay,
             onChange = { src ->
                 palette.apply {