diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/Platform.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/Platform.kt index 375732c..f79dc1a 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/Platform.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/Platform.kt @@ -11,6 +11,13 @@ expect fun getPlatform(): Platform interface Platform { val name: String val type: PlatformType + + + val isMobile: Boolean + get() = type == PlatformType.iOS || type == PlatformType.Android // TODO: for Web check if it's a mobile browser, but very low priority + + val isDesktop: Boolean + get() = type == PlatformType.JVM || type == PlatformType.Web // TODO: for Web check if it's a desktop browser, but very low priority } enum class PlatformType { @@ -18,8 +25,4 @@ enum class PlatformType { Android, iOS, Web -} - - -val Platform.isMobile: Boolean - get() = type == PlatformType.iOS || type == PlatformType.Android // TODO: for Web check if it's a mobile browser, but very low priority \ No newline at end of file +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/BaseDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/BaseDialog.kt index 982337e..eb62d8d 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/BaseDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/BaseDialog.kt @@ -15,10 +15,9 @@ import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import net.codinux.banking.ui.composables.text.HeaderText import net.codinux.banking.ui.config.Colors +import net.codinux.banking.ui.config.DI import net.codinux.banking.ui.extensions.copy import net.codinux.banking.ui.forms.* -import net.codinux.banking.ui.getPlatform -import net.codinux.banking.ui.isMobile @Composable fun BaseDialog( @@ -32,7 +31,7 @@ fun BaseDialog( properties: DialogProperties = DialogProperties(), content: @Composable () -> Unit ) { - val overwriteDefaultWidth = useMoreThanPlatformDefaultWidthOnMobile && getPlatform().isMobile + val overwriteDefaultWidth = useMoreThanPlatformDefaultWidthOnMobile && DI.platform.isMobile Dialog(onDismissRequest = onDismiss, if (overwriteDefaultWidth) properties.copy(usePlatformDefaultWidth = false) else properties) { RoundedCornersCard(Modifier.let { if (overwriteDefaultWidth) it.fillMaxWidth(0.95f) else it }) { @@ -41,8 +40,10 @@ fun BaseDialog( Row(Modifier.fillMaxWidth()) { HeaderText(title, Modifier.padding(top = 8.dp, bottom = 16.dp).weight(1f)) - TextButton(onDismiss, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) { - Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp)) + if (DI.platform.isDesktop) { + TextButton(onDismiss, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) { + Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp)) + } } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FullscreenViewBase.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FullscreenViewBase.kt index c9e2fbb..88ad2aa 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FullscreenViewBase.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FullscreenViewBase.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import net.codinux.banking.ui.composables.text.HeaderText import net.codinux.banking.ui.config.Colors +import net.codinux.banking.ui.config.DI @Composable fun FullscreenViewBase( @@ -26,8 +27,10 @@ fun FullscreenViewBase( Row(Modifier.fillMaxWidth()) { HeaderText(title, Modifier.padding(top = 8.dp, bottom = 16.dp).weight(1f)) - TextButton(onClosed, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) { - Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp)) + if (DI.platform.isDesktop) { + TextButton(onClosed, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) { + Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp)) + } } }