Removed Dialog and Fullscreen upper right close button on mobile (is not common on mobile and anyway harder to reach with thumb than buttons at the bottom

This commit is contained in:
dankito 2024-09-01 18:04:40 +02:00
parent e5119b237e
commit abfe92a19b
3 changed files with 19 additions and 12 deletions

View File

@ -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
}

View File

@ -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))
}
}
}

View File

@ -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))
}
}
}