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,
|
||||
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",
|
||||
confirmButtonEnabled = isRequiredDataEntered && isAddingAccount == false,
|
||||
showProgressIndicatorOnConfirmButton = isAddingAccount,
|
||||
useMoreThanPlatformDefaultWidthOnMobile = true,
|
||||
onDismiss = onDismiss,
|
||||
onConfirm = {
|
||||
selectedBank?.let {
|
||||
|
|
|
@ -15,8 +15,10 @@ 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.Style
|
||||
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(
|
||||
|
@ -24,15 +26,16 @@ fun BaseDialog(
|
|||
confirmButtonTitle: String = "OK",
|
||||
confirmButtonEnabled: Boolean = true,
|
||||
showProgressIndicatorOnConfirmButton: Boolean = false,
|
||||
useMoreThanPlatformDefaultWidthOnMobile: Boolean = false,
|
||||
onDismiss: () -> Unit,
|
||||
onConfirm: (() -> Unit)? = null,
|
||||
properties: DialogProperties = DialogProperties(),
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val overwriteDefaultWidth = useMoreThanPlatformDefaultWidthOnMobile && getPlatform().isMobile
|
||||
|
||||
|
||||
Dialog(onDismissRequest = onDismiss, properties) {
|
||||
RoundedCornersCard {
|
||||
Dialog(onDismissRequest = onDismiss, if (overwriteDefaultWidth) properties.copy(usePlatformDefaultWidth = false) else properties) {
|
||||
RoundedCornersCard(Modifier.let { if (overwriteDefaultWidth) it.fillMaxWidth(0.95f) else it }) {
|
||||
Column(Modifier.background(Color.White).padding(8.dp)) {
|
||||
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
|
|
|
@ -50,6 +50,7 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
|
|||
|
||||
BaseDialog(
|
||||
title = "TAN Eingabe",
|
||||
useMoreThanPlatformDefaultWidthOnMobile = true,
|
||||
confirmButtonEnabled = enteredTan.length > 2,
|
||||
onConfirm = {
|
||||
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