2
0
Эх сурвалжийг харах

code improvements

code improvements

code improvements

code improvements
Milan Jurkulak 1 жил өмнө
parent
commit
ccd2567f7e

+ 3 - 1
composeApp/src/androidMain/AndroidManifest.xml

@@ -51,8 +51,10 @@
 
         <activity
             android:name=".activity.MainActivity"
+            android:screenOrientation="fullSensor"
             android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
-            android:exported="true">
+            android:exported="true"
+            tools:ignore="DiscouragedApi">
 
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />

+ 2 - 1
composeApp/src/commonMain/kotlin/org/mjdev/desktop/components/file/FolderIcon.kt

@@ -3,6 +3,7 @@ package org.mjdev.desktop.components.file
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.aspectRatio
 import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.layout.size
 import androidx.compose.foundation.layout.width
@@ -59,7 +60,7 @@ fun FolderIcon(
         onDragEnd = onDragEnd
     ) {
         Column(
-            modifier = Modifier.wrapContentSize()
+            modifier = Modifier.wrapContentSize().aspectRatio(1f)
         ) {
             Box(
                 modifier = Modifier.size(computedSize)

+ 6 - 1
composeApp/src/commonMain/kotlin/org/mjdev/desktop/components/file/FolderView.kt

@@ -1,14 +1,17 @@
 package org.mjdev.desktop.components.file
 
 import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.aspectRatio
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.derivedStateOf
 import androidx.compose.runtime.getValue
 import androidx.compose.runtime.remember
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clipToBounds
 import androidx.compose.ui.unit.Dp
 import androidx.compose.ui.unit.DpSize
 import androidx.compose.ui.unit.dp
@@ -28,6 +31,7 @@ import org.mjdev.desktop.extensions.PathExt.isDirectory
 import org.mjdev.desktop.extensions.PathExt.listFiles
 import org.mjdev.desktop.context.DesktopContextScope.Companion.withDesktopContext
 import org.mjdev.desktop.extensions.LaunchedEffect.runAsync
+import org.mjdev.desktop.extensions.Modifier.clipCircle
 import kotlin.math.max
 
 // todo orientation
@@ -79,7 +83,8 @@ fun FolderView(
                 files.forEach { file ->
                     item {
                         FolderIcon(
-                            modifier = Modifier.padding(iconSpacing),
+                            modifier = Modifier
+                                .padding(iconSpacing),
                             path = file.path,
                             customName = file.customName,
                             iconSize = iconSize,

+ 2 - 1
composeApp/src/desktopMain/kotlin/org/mjdev/desktop/Main.kt

@@ -2,10 +2,11 @@ package org.mjdev.desktop
 
 import Notify
 import org.mjdev.desktop.components.main.MainWindow
+import org.mjdev.desktop.helpers.application.application
 
 fun main(
     args: Array<String>
-) = org.mjdev.desktop.helpers.application.application(
+) = application(
     args = args.toList(),
     exitProcessOnExit = true
 ) {

+ 2 - 0
composeApp/src/desktopMain/kotlin/org/mjdev/desktop/helpers/application/Application.kt

@@ -41,6 +41,7 @@ import kotlin.system.exitProcess
 fun application(
     args: List<String> = emptyList(),
     exitProcessOnExit: Boolean = true,
+    onExit: () -> Unit = {},
     content: @Composable ApplicationScope.() -> Unit
 ) {
     if (System.getProperty("compose.application.configure.swing.globals") == "true") {
@@ -54,6 +55,7 @@ fun application(
     }
     if (exitProcessOnExit) {
         Log.i("Exiting application.")
+        onExit()
         exitProcess(0)
     }
 }

+ 2 - 2
composeApp/src/desktopMain/kotlin/org/mjdev/desktop/helpers/system/meminfo/MemInfo.desktop.kt

@@ -8,6 +8,6 @@ actual fun MemInfo(
     context: IDesktopContext
 ): MemInfoStub = when (hostOs) {
     // todo other platforms
-    OS.Linux -> MemInfoLinux()
-    else -> MemInfoStub()
+    OS.Linux -> MemInfoLinux(context)
+    else -> MemInfoStub(context)
 }