Improve global dialog UI
This commit is contained in:
parent
8e8d1ce9c8
commit
6f80179fb3
@ -1,25 +1,24 @@
|
||||
package com.readrops.app.util.components.dialog
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.AlertDialogDefaults
|
||||
import androidx.compose.material3.BasicAlertDialog
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import com.readrops.app.util.theme.MediumSpacer
|
||||
import com.readrops.app.util.theme.spacing
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun BaseDialog(
|
||||
title: String,
|
||||
@ -28,23 +27,22 @@ fun BaseDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
Dialog(
|
||||
BasicAlertDialog(
|
||||
onDismissRequest = onDismiss
|
||||
) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(24.dp),
|
||||
modifier = modifier
|
||||
Surface(
|
||||
tonalElevation = AlertDialogDefaults.TonalElevation,
|
||||
shape = AlertDialogDefaults.shape,
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colorScheme.background)
|
||||
.padding(MaterialTheme.spacing.largeSpacing)
|
||||
modifier = modifier
|
||||
.padding(MaterialTheme.spacing.largeSpacing)
|
||||
) {
|
||||
Icon(
|
||||
painter = icon,
|
||||
tint = AlertDialogDefaults.iconContentColor,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(MaterialTheme.spacing.largeSpacing)
|
||||
)
|
||||
@ -53,7 +51,8 @@ fun BaseDialog(
|
||||
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.headlineSmall
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
color = AlertDialogDefaults.titleContentColor
|
||||
)
|
||||
|
||||
MediumSpacer()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.readrops.app.util.components.dialog
|
||||
|
||||
import androidx.compose.material3.AlertDialogDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@ -18,7 +19,10 @@ fun ErrorDialog(
|
||||
icon = painterResource(id = R.drawable.ic_error),
|
||||
onDismiss = onDismiss
|
||||
) {
|
||||
Text(text = ErrorMessage.get(exception, LocalContext.current))
|
||||
Text(
|
||||
text = ErrorMessage.get(exception, LocalContext.current),
|
||||
color = AlertDialogDefaults.textContentColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,7 @@ fun TwoChoicesDialog(
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismiss
|
||||
) {
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text(text = dismissText)
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user