Dialog buttons now use the full dialog width (instead of right aligning them)
This commit is contained in:
parent
84a147d4c9
commit
7ead4297f8
|
@ -2,7 +2,6 @@ package net.codinux.banking.ui.config
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
object Style {
|
object Style {
|
||||||
|
@ -13,6 +12,4 @@ object Style {
|
||||||
|
|
||||||
val HeaderFontWeight: FontWeight = FontWeight.Bold
|
val HeaderFontWeight: FontWeight = FontWeight.Bold
|
||||||
|
|
||||||
val DialogButtonWidth = 200.dp
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
|
@ -44,24 +45,22 @@ fun BaseDialog(
|
||||||
|
|
||||||
content()
|
content()
|
||||||
|
|
||||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
|
Row(Modifier.fillMaxWidth()) {
|
||||||
TextButton(onClick = onDismiss, Modifier.width(Style.DialogButtonWidth)) {
|
TextButton(onClick = onDismiss, Modifier.weight(0.5f)) {
|
||||||
Text("Abbrechen", color = Colors.CodinuxSecondaryColor)
|
Text("Abbrechen", color = Colors.CodinuxSecondaryColor, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.width(8.dp))
|
|
||||||
|
|
||||||
TextButton(
|
TextButton(
|
||||||
modifier = Modifier.width(Style.DialogButtonWidth),
|
modifier = Modifier.weight(0.5f),
|
||||||
enabled = confirmButtonEnabled,
|
enabled = confirmButtonEnabled,
|
||||||
onClick = { onConfirm?.invoke() ?: onDismiss() }
|
onClick = { onConfirm?.invoke() ?: onDismiss() }
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||||
if (showProgressIndicatorOnConfirmButton) {
|
if (showProgressIndicatorOnConfirmButton) {
|
||||||
CircularProgressIndicator(Modifier.padding(end = 6.dp))
|
CircularProgressIndicator(Modifier.padding(end = 6.dp))
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(confirmButtonTitle, color = Colors.CodinuxSecondaryColor)
|
Text(confirmButtonTitle, color = Colors.CodinuxSecondaryColor, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.codinux.banking.ui.dialogs
|
package net.codinux.banking.ui.dialogs
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.width
|
|
||||||
import androidx.compose.material.AlertDialog
|
import androidx.compose.material.AlertDialog
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.TextButton
|
import androidx.compose.material.TextButton
|
||||||
|
@ -27,8 +26,10 @@ fun ErrorDialog(
|
||||||
} },
|
} },
|
||||||
onDismissRequest = { onDismiss?.invoke() },
|
onDismissRequest = { onDismiss?.invoke() },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton({ onDismiss?.invoke() }, Modifier.width(Style.DialogButtonWidth)) {
|
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
|
||||||
Text(confirmButtonText, color = Colors.CodinuxSecondaryColor)
|
TextButton({ onDismiss?.invoke() }, Modifier.fillMaxWidth()) {
|
||||||
|
Text(confirmButtonText, color = Colors.CodinuxSecondaryColor, textAlign = TextAlign.Center)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue