Added option that dialogs on mobile platforms use more than platform's default dialog width (which makes AddAccount- and EnterTanDialog way better usable)
This commit is contained in:
parent
7ead4297f8
commit
9209347d86
|
@ -19,3 +19,7 @@ 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
|
|
@ -41,6 +41,7 @@ fun AddAccountDialog(
|
||||||
confirmButtonTitle = "Hinzufügen",
|
confirmButtonTitle = "Hinzufügen",
|
||||||
confirmButtonEnabled = isRequiredDataEntered && isAddingAccount == false,
|
confirmButtonEnabled = isRequiredDataEntered && isAddingAccount == false,
|
||||||
showProgressIndicatorOnConfirmButton = isAddingAccount,
|
showProgressIndicatorOnConfirmButton = isAddingAccount,
|
||||||
|
useMoreThanPlatformDefaultWidthOnMobile = true,
|
||||||
onDismiss = onDismiss,
|
onDismiss = onDismiss,
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
selectedBank?.let {
|
selectedBank?.let {
|
||||||
|
|
|
@ -15,8 +15,10 @@ 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.Style
|
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(
|
||||||
|
@ -24,15 +26,16 @@ fun BaseDialog(
|
||||||
confirmButtonTitle: String = "OK",
|
confirmButtonTitle: String = "OK",
|
||||||
confirmButtonEnabled: Boolean = true,
|
confirmButtonEnabled: Boolean = true,
|
||||||
showProgressIndicatorOnConfirmButton: Boolean = false,
|
showProgressIndicatorOnConfirmButton: Boolean = false,
|
||||||
|
useMoreThanPlatformDefaultWidthOnMobile: Boolean = false,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onConfirm: (() -> Unit)? = null,
|
onConfirm: (() -> Unit)? = null,
|
||||||
properties: DialogProperties = DialogProperties(),
|
properties: DialogProperties = DialogProperties(),
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
|
val overwriteDefaultWidth = useMoreThanPlatformDefaultWidthOnMobile && getPlatform().isMobile
|
||||||
|
|
||||||
|
Dialog(onDismissRequest = onDismiss, if (overwriteDefaultWidth) properties.copy(usePlatformDefaultWidth = false) else properties) {
|
||||||
Dialog(onDismissRequest = onDismiss, properties) {
|
RoundedCornersCard(Modifier.let { if (overwriteDefaultWidth) it.fillMaxWidth(0.95f) else it }) {
|
||||||
RoundedCornersCard {
|
|
||||||
Column(Modifier.background(Color.White).padding(8.dp)) {
|
Column(Modifier.background(Color.White).padding(8.dp)) {
|
||||||
|
|
||||||
Row(Modifier.fillMaxWidth()) {
|
Row(Modifier.fillMaxWidth()) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
|
||||||
|
|
||||||
BaseDialog(
|
BaseDialog(
|
||||||
title = "TAN Eingabe",
|
title = "TAN Eingabe",
|
||||||
|
useMoreThanPlatformDefaultWidthOnMobile = true,
|
||||||
confirmButtonEnabled = enteredTan.length > 2,
|
confirmButtonEnabled = enteredTan.length > 2,
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
tanChallengeReceived.callback(EnterTanResult(enteredTan))
|
tanChallengeReceived.callback(EnterTanResult(enteredTan))
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package net.codinux.banking.ui.extensions
|
||||||
|
|
||||||
|
import androidx.compose.ui.window.DialogProperties
|
||||||
|
|
||||||
|
fun DialogProperties.copy(
|
||||||
|
dismissOnBackPress: Boolean = this.dismissOnBackPress,
|
||||||
|
dismissOnClickOutside: Boolean = this.dismissOnClickOutside,
|
||||||
|
usePlatformDefaultWidth: Boolean = this.usePlatformDefaultWidth
|
||||||
|
) = DialogProperties(dismissOnBackPress, dismissOnClickOutside, usePlatformDefaultWidth = usePlatformDefaultWidth)
|
Loading…
Reference in New Issue