mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
refactor: use AreaBox for outside box in Navigation
This commit is contained in:
@@ -64,6 +64,7 @@ import com.highcapable.flexiui.interaction.rippleClickable
|
|||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
data class NavigationColors(
|
data class NavigationColors(
|
||||||
|
val backgroundColor: Color,
|
||||||
val indicatorColor: Color,
|
val indicatorColor: Color,
|
||||||
val selectedContentColor: Color,
|
val selectedContentColor: Color,
|
||||||
val unselectedContentColor: Color
|
val unselectedContentColor: Color
|
||||||
@@ -71,7 +72,7 @@ data class NavigationColors(
|
|||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
data class NavigationStyle(
|
data class NavigationStyle(
|
||||||
val padding: PaddingValues,
|
val boxStyle: AreaBoxStyle,
|
||||||
val contentSpacing: Dp,
|
val contentSpacing: Dp,
|
||||||
val contentPadding: PaddingValues,
|
val contentPadding: PaddingValues,
|
||||||
val contentShape: Shape
|
val contentShape: Shape
|
||||||
@@ -86,8 +87,10 @@ fun NavigationRow(
|
|||||||
content: @Composable RowScope.() -> Unit
|
content: @Composable RowScope.() -> Unit
|
||||||
) {
|
) {
|
||||||
NavigationStyleBox(modifier, horizontal = true, colors, style) {
|
NavigationStyleBox(modifier, horizontal = true, colors, style) {
|
||||||
Row(
|
AreaRow(
|
||||||
modifier = Modifier.fillMaxWidth().selectableGroup(),
|
modifier = Modifier.fillMaxWidth().selectableGroup(),
|
||||||
|
color = colors.backgroundColor,
|
||||||
|
style = style.boxStyle,
|
||||||
horizontalArrangement = arrangement,
|
horizontalArrangement = arrangement,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
content = content
|
content = content
|
||||||
@@ -104,8 +107,10 @@ fun NavigationColumn(
|
|||||||
content: @Composable ColumnScope.() -> Unit
|
content: @Composable ColumnScope.() -> Unit
|
||||||
) {
|
) {
|
||||||
NavigationStyleBox(modifier, horizontal = false, colors, style) {
|
NavigationStyleBox(modifier, horizontal = false, colors, style) {
|
||||||
Column(
|
AreaColumn(
|
||||||
modifier = Modifier.fillMaxWidth().selectableGroup(),
|
modifier = Modifier.fillMaxWidth().selectableGroup(),
|
||||||
|
color = colors.backgroundColor,
|
||||||
|
style = style.boxStyle,
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = arrangement,
|
verticalArrangement = arrangement,
|
||||||
content = content
|
content = content
|
||||||
@@ -197,7 +202,7 @@ private fun NavigationStyleBox(
|
|||||||
style: NavigationStyle,
|
style: NavigationStyle,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
Box(modifier = modifier.padding(style.padding)) {
|
Box(modifier = modifier) {
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalHorizontalNavigation provides horizontal,
|
LocalHorizontalNavigation provides horizontal,
|
||||||
LocalNavigationColors provides colors,
|
LocalNavigationColors provides colors,
|
||||||
@@ -232,6 +237,7 @@ private val LocalNavigationContentShape = compositionLocalOf<Shape?> { null }
|
|||||||
@Composable
|
@Composable
|
||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
private fun defaultNavigationColors() = NavigationColors(
|
private fun defaultNavigationColors() = NavigationColors(
|
||||||
|
backgroundColor = AreaBox.color,
|
||||||
indicatorColor = LocalColors.current.themeTertiary,
|
indicatorColor = LocalColors.current.themeTertiary,
|
||||||
selectedContentColor = LocalColors.current.themePrimary,
|
selectedContentColor = LocalColors.current.themePrimary,
|
||||||
unselectedContentColor = LocalColors.current.textSecondary
|
unselectedContentColor = LocalColors.current.textSecondary
|
||||||
@@ -240,11 +246,7 @@ private fun defaultNavigationColors() = NavigationColors(
|
|||||||
@Composable
|
@Composable
|
||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
private fun defaultNavigationStyle() = NavigationStyle(
|
private fun defaultNavigationStyle() = NavigationStyle(
|
||||||
padding = when {
|
boxStyle = AreaBox.style,
|
||||||
LocalInSurface.current || LocalInAreaBox.current ->
|
|
||||||
PaddingValues(vertical = LocalSizes.current.spacingPrimary)
|
|
||||||
else -> PaddingValues(LocalSizes.current.spacingPrimary)
|
|
||||||
},
|
|
||||||
contentSpacing = LocalSizes.current.spacingSecondary,
|
contentSpacing = LocalSizes.current.spacingSecondary,
|
||||||
contentPadding = PaddingValues(
|
contentPadding = PaddingValues(
|
||||||
horizontal = LocalSizes.current.spacingPrimary,
|
horizontal = LocalSizes.current.spacingPrimary,
|
||||||
|
Reference in New Issue
Block a user