mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
feat: add maxHeight in FlexiDialog
This commit is contained in:
@@ -34,6 +34,7 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -86,6 +87,7 @@ data class FlexiDialogColors(
|
|||||||
* @param titleTextStyle the title text style.
|
* @param titleTextStyle the title text style.
|
||||||
* @param contentTextStyle the content text style.
|
* @param contentTextStyle the content text style.
|
||||||
* @param maxWidth the dialog's max width.
|
* @param maxWidth the dialog's max width.
|
||||||
|
* @param maxHeight the dialog's max height.
|
||||||
* @param outPadding the dialog's out padding.
|
* @param outPadding the dialog's out padding.
|
||||||
* @param titlePadding the title padding.
|
* @param titlePadding the title padding.
|
||||||
* @param contentPadding the content padding.
|
* @param contentPadding the content padding.
|
||||||
@@ -97,6 +99,7 @@ data class FlexiDialogStyle(
|
|||||||
val titleTextStyle: TextStyle,
|
val titleTextStyle: TextStyle,
|
||||||
val contentTextStyle: TextStyle,
|
val contentTextStyle: TextStyle,
|
||||||
val maxWidth: Dp,
|
val maxWidth: Dp,
|
||||||
|
val maxHeight: Dp,
|
||||||
val outPadding: ComponentPadding,
|
val outPadding: ComponentPadding,
|
||||||
val titlePadding: ComponentPadding,
|
val titlePadding: ComponentPadding,
|
||||||
val contentPadding: ComponentPadding,
|
val contentPadding: ComponentPadding,
|
||||||
@@ -193,12 +196,14 @@ fun FlexiDialog(
|
|||||||
animated = animated,
|
animated = animated,
|
||||||
boxStyle = style.boxStyle,
|
boxStyle = style.boxStyle,
|
||||||
maxWidth = style.maxWidth,
|
maxWidth = style.maxWidth,
|
||||||
|
maxHeight = style.maxHeight,
|
||||||
contentAlignment = contentAlignment,
|
contentAlignment = contentAlignment,
|
||||||
properties = properties
|
properties = properties
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
val hasButtons = confirmButton != null || cancelButton != null || neutralButton != null
|
val hasButtons = confirmButton != null || cancelButton != null || neutralButton != null
|
||||||
Content()
|
// The content should not overlap with the buttons, so it has a weight of 1f.
|
||||||
|
Column(modifier = Modifier.weight(1f, fill = false)) { Content() }
|
||||||
if (hasButtons) Buttons()
|
if (hasButtons) Buttons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,6 +220,7 @@ private fun BasicFlexiDialog(
|
|||||||
animated: Boolean,
|
animated: Boolean,
|
||||||
boxStyle: AreaBoxStyle,
|
boxStyle: AreaBoxStyle,
|
||||||
maxWidth: Dp,
|
maxWidth: Dp,
|
||||||
|
maxHeight: Dp,
|
||||||
contentAlignment: Alignment,
|
contentAlignment: Alignment,
|
||||||
properties: DialogPropertiesWrapper,
|
properties: DialogPropertiesWrapper,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
@@ -247,7 +253,7 @@ private fun BasicFlexiDialog(
|
|||||||
else Modifier.then(modifier)
|
else Modifier.then(modifier)
|
||||||
) {
|
) {
|
||||||
AreaBox(
|
AreaBox(
|
||||||
modifier = Modifier.widthIn(max = maxWidth),
|
modifier = Modifier.widthIn(max = maxWidth).heightIn(max = maxHeight),
|
||||||
style = boxStyle,
|
style = boxStyle,
|
||||||
contentAlignment = contentAlignment
|
contentAlignment = contentAlignment
|
||||||
) { content() }
|
) { content() }
|
||||||
@@ -284,6 +290,7 @@ private fun defaultFlexiDialogStyle() = FlexiDialogStyle(
|
|||||||
titleTextStyle = LocalTypography.current.titleSecondary,
|
titleTextStyle = LocalTypography.current.titleSecondary,
|
||||||
contentTextStyle = LocalTypography.current.primary,
|
contentTextStyle = LocalTypography.current.primary,
|
||||||
maxWidth = DefaultMaxWidth,
|
maxWidth = DefaultMaxWidth,
|
||||||
|
maxHeight = DefaultMaxHeight,
|
||||||
outPadding = ComponentPadding(horizontal = DefaultHorizontalOutPadding),
|
outPadding = ComponentPadding(horizontal = DefaultHorizontalOutPadding),
|
||||||
titlePadding = ComponentPadding(LocalSizes.current.spacingSecondary),
|
titlePadding = ComponentPadding(LocalSizes.current.spacingSecondary),
|
||||||
contentPadding = ComponentPadding(LocalSizes.current.spacingSecondary),
|
contentPadding = ComponentPadding(LocalSizes.current.spacingSecondary),
|
||||||
@@ -294,6 +301,7 @@ private const val AnimationDuration = 250
|
|||||||
private const val AnimationMinmumScale = 0.8f
|
private const val AnimationMinmumScale = 0.8f
|
||||||
|
|
||||||
private val DefaultMaxWidth = 300.dp
|
private val DefaultMaxWidth = 300.dp
|
||||||
|
private val DefaultMaxHeight = 500.dp
|
||||||
private val DefaultHorizontalOutPadding = 50.dp
|
private val DefaultHorizontalOutPadding = 50.dp
|
||||||
|
|
||||||
private const val DefaultScrimOpacity = 0.35f
|
private const val DefaultScrimOpacity = 0.35f
|
||||||
|
Reference in New Issue
Block a user