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 { interface Platform {
val name: String val name: String
val type: PlatformType 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 { enum class PlatformType {
@ -19,7 +26,3 @@ enum class PlatformType {
iOS, iOS,
Web 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 androidx.compose.ui.window.DialogProperties
import net.codinux.banking.ui.composables.text.HeaderText import net.codinux.banking.ui.composables.text.HeaderText
import net.codinux.banking.ui.config.Colors 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.extensions.copy
import net.codinux.banking.ui.forms.* import net.codinux.banking.ui.forms.*
import net.codinux.banking.ui.getPlatform
import net.codinux.banking.ui.isMobile
@Composable @Composable
fun BaseDialog( fun BaseDialog(
@ -32,7 +31,7 @@ fun BaseDialog(
properties: DialogProperties = DialogProperties(), properties: DialogProperties = DialogProperties(),
content: @Composable () -> Unit 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) { Dialog(onDismissRequest = onDismiss, if (overwriteDefaultWidth) properties.copy(usePlatformDefaultWidth = false) else properties) {
RoundedCornersCard(Modifier.let { if (overwriteDefaultWidth) it.fillMaxWidth(0.95f) else it }) { RoundedCornersCard(Modifier.let { if (overwriteDefaultWidth) it.fillMaxWidth(0.95f) else it }) {
@ -41,10 +40,12 @@ fun BaseDialog(
Row(Modifier.fillMaxWidth()) { Row(Modifier.fillMaxWidth()) {
HeaderText(title, Modifier.padding(top = 8.dp, bottom = 16.dp).weight(1f)) HeaderText(title, Modifier.padding(top = 8.dp, bottom = 16.dp).weight(1f))
if (DI.platform.isDesktop) {
TextButton(onDismiss, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) { TextButton(onDismiss, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) {
Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp)) Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp))
} }
} }
}
content() content()

View File

@ -12,6 +12,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import net.codinux.banking.ui.composables.text.HeaderText import net.codinux.banking.ui.composables.text.HeaderText
import net.codinux.banking.ui.config.Colors import net.codinux.banking.ui.config.Colors
import net.codinux.banking.ui.config.DI
@Composable @Composable
fun FullscreenViewBase( fun FullscreenViewBase(
@ -26,10 +27,12 @@ fun FullscreenViewBase(
Row(Modifier.fillMaxWidth()) { Row(Modifier.fillMaxWidth()) {
HeaderText(title, Modifier.padding(top = 8.dp, bottom = 16.dp).weight(1f)) HeaderText(title, Modifier.padding(top = 8.dp, bottom = 16.dp).weight(1f))
if (DI.platform.isDesktop) {
TextButton(onClosed, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) { TextButton(onClosed, colors = ButtonDefaults.buttonColors(contentColor = Colors.Zinc700, backgroundColor = Color.Transparent)) {
Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp)) Icon(Icons.Filled.Close, contentDescription = "Close dialog", Modifier.size(32.dp))
} }
} }
}
Column(Modifier.fillMaxWidth().weight(1f)) { Column(Modifier.fillMaxWidth().weight(1f)) {
content() content()