mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
feat: add default properties in Dialog
This commit is contained in:
@@ -120,7 +120,7 @@ data class FlexiDialogStyle(
|
|||||||
* @param colors the colors of dialog, default is [FlexiDialogDefaults.colors].
|
* @param colors the colors of dialog, default is [FlexiDialogDefaults.colors].
|
||||||
* @param style the style of dialog, default is [FlexiDialogDefaults.style].
|
* @param style the style of dialog, default is [FlexiDialogDefaults.style].
|
||||||
* @param contentAlignment the alignment of dialog content, default is [Alignment.TopStart].
|
* @param contentAlignment the alignment of dialog content, default is [Alignment.TopStart].
|
||||||
* @param properties the properties of dialog, default is [DefaultDialogProperties].
|
* @param properties the properties of dialog, default is [FlexiDialogDefaults.properties].
|
||||||
* @param title the title of the [FlexiDialog], should typically be [Icon] or [Text].
|
* @param title the title of the [FlexiDialog], should typically be [Icon] or [Text].
|
||||||
* @param content the content of the [FlexiDialog].
|
* @param content the content of the [FlexiDialog].
|
||||||
* @param confirmButton the confirm button of the [FlexiDialog], should typically be [Button].
|
* @param confirmButton the confirm button of the [FlexiDialog], should typically be [Button].
|
||||||
@@ -136,7 +136,7 @@ fun FlexiDialog(
|
|||||||
colors: FlexiDialogColors = FlexiDialogDefaults.colors(),
|
colors: FlexiDialogColors = FlexiDialogDefaults.colors(),
|
||||||
style: FlexiDialogStyle = FlexiDialogDefaults.style(),
|
style: FlexiDialogStyle = FlexiDialogDefaults.style(),
|
||||||
contentAlignment: Alignment = Alignment.TopStart,
|
contentAlignment: Alignment = Alignment.TopStart,
|
||||||
properties: DialogPropertiesWrapper = DefaultDialogProperties,
|
properties: DialogPropertiesWrapper = FlexiDialogDefaults.properties(),
|
||||||
title: (@Composable RowScope.() -> Unit)? = null,
|
title: (@Composable RowScope.() -> Unit)? = null,
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
confirmButton: @Composable (() -> Unit)? = null,
|
confirmButton: @Composable (() -> Unit)? = null,
|
||||||
@@ -173,7 +173,7 @@ fun FlexiDialog(
|
|||||||
* @param colors the colors of dialog, default is [FlexiDialogDefaults.colors].
|
* @param colors the colors of dialog, default is [FlexiDialogDefaults.colors].
|
||||||
* @param style the style of dialog, default is [FlexiDialogDefaults.style].
|
* @param style the style of dialog, default is [FlexiDialogDefaults.style].
|
||||||
* @param contentAlignment the alignment of dialog content, default is [Alignment.TopStart].
|
* @param contentAlignment the alignment of dialog content, default is [Alignment.TopStart].
|
||||||
* @param properties the properties of dialog, default is [DefaultDialogProperties].
|
* @param properties the properties of dialog, default is [FlexiDialogDefaults.properties].
|
||||||
* @param title the title of the [FlexiDialog], should typically be [Icon] or [Text].
|
* @param title the title of the [FlexiDialog], should typically be [Icon] or [Text].
|
||||||
* @param content the content of the [FlexiDialog].
|
* @param content the content of the [FlexiDialog].
|
||||||
* @param confirmButton the confirm button of the [FlexiDialog], should typically be [Button].
|
* @param confirmButton the confirm button of the [FlexiDialog], should typically be [Button].
|
||||||
@@ -191,7 +191,7 @@ fun FlexiDialog(
|
|||||||
colors: FlexiDialogColors = FlexiDialogDefaults.colors(),
|
colors: FlexiDialogColors = FlexiDialogDefaults.colors(),
|
||||||
style: FlexiDialogStyle = FlexiDialogDefaults.style(),
|
style: FlexiDialogStyle = FlexiDialogDefaults.style(),
|
||||||
contentAlignment: Alignment = Alignment.TopStart,
|
contentAlignment: Alignment = Alignment.TopStart,
|
||||||
properties: DialogPropertiesWrapper = DefaultDialogProperties,
|
properties: DialogPropertiesWrapper = FlexiDialogDefaults.properties(),
|
||||||
title: (@Composable RowScope.() -> Unit)? = null,
|
title: (@Composable RowScope.() -> Unit)? = null,
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
confirmButton: @Composable (() -> Unit)? = null,
|
confirmButton: @Composable (() -> Unit)? = null,
|
||||||
@@ -343,6 +343,26 @@ private fun BasicFlexiDialog(
|
|||||||
*/
|
*/
|
||||||
object FlexiDialogDefaults {
|
object FlexiDialogDefaults {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [DialogPropertiesWrapper] with the default values.
|
||||||
|
* @see DialogPropertiesWrapper
|
||||||
|
* @return [DialogPropertiesWrapper]
|
||||||
|
*/
|
||||||
|
@Stable
|
||||||
|
fun properties(
|
||||||
|
dismissOnClickOutside: Boolean = true,
|
||||||
|
dismissOnBackPress: Boolean = true,
|
||||||
|
usePlatformDefaultWidth: Boolean = false,
|
||||||
|
usePlatformInsets: Boolean = true,
|
||||||
|
scrimColor: Color = DefaultScrimColor
|
||||||
|
) = DialogPropertiesWrapper(
|
||||||
|
dismissOnClickOutside = dismissOnClickOutside,
|
||||||
|
dismissOnBackPress = dismissOnBackPress,
|
||||||
|
usePlatformDefaultWidth = usePlatformDefaultWidth,
|
||||||
|
usePlatformInsets = usePlatformInsets,
|
||||||
|
scrimColor = scrimColor
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a [FlexiDialogColors] with the default values.
|
* Creates a [FlexiDialogColors] with the default values.
|
||||||
* @param backgroundColor the background color.
|
* @param backgroundColor the background color.
|
||||||
@@ -439,7 +459,6 @@ private const val AnimationMinmumScale = 0.8f
|
|||||||
|
|
||||||
private const val DefaultScrimOpacity = 0.35f
|
private const val DefaultScrimOpacity = 0.35f
|
||||||
private val DefaultScrimColor = Color.Black.copy(alpha = DefaultScrimOpacity)
|
private val DefaultScrimColor = Color.Black.copy(alpha = DefaultScrimOpacity)
|
||||||
private val DefaultDialogProperties = DialogPropertiesWrapper(usePlatformDefaultWidth = false, scrimColor = DefaultScrimColor)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scrim animation effect of Flexi UI dialog is still in experimental function,
|
* The scrim animation effect of Flexi UI dialog is still in experimental function,
|
||||||
|
Reference in New Issue
Block a user