refactor: use withAreaBoxShape to apply the default AreaBox shape

This commit is contained in:
2023-11-28 10:03:01 +08:00
parent d676617aa5
commit 608074a0cc
5 changed files with 14 additions and 17 deletions

View File

@@ -170,6 +170,16 @@ internal val LocalAreaBoxShape = compositionLocalOf { DefaultAreaBoxShape }
internal val DefaultAreaBoxShape: Shape = DefaultShapes.primary
@Composable
@ReadOnlyComposable
internal fun withAreaBoxShape(
inBox: Shape = LocalAreaBoxShape.current,
outBox: Shape = LocalShapes.current.secondary
) = when (LocalInAreaBox.current) {
true -> inBox
else -> outBox
}
@Composable
@ReadOnlyComposable
private fun defaultAreaBoxStyle() = AreaBoxStyle(

View File

@@ -249,10 +249,7 @@ private fun defaultButtonStyle() = ButtonStyle(
horizontal = LocalSizes.current.spacingPrimary,
vertical = LocalSizes.current.spacingSecondary
),
shape = when (LocalInAreaBox.current) {
true -> LocalAreaBoxShape.current
else -> LocalShapes.current.secondary
},
shape = withAreaBoxShape(),
border = defaultButtonBorder()
)

View File

@@ -567,10 +567,7 @@ private fun defaultDropdownMenuColors() = DropdownMenuColors(
@ReadOnlyComposable
private fun defaultDropdownListStyle() = DropdownListStyle(
padding = PaddingValues(LocalSizes.current.spacingSecondary),
shape = when (LocalInAreaBox.current) {
true -> LocalAreaBoxShape.current
else -> LocalShapes.current.secondary
},
shape = withAreaBoxShape(),
endIconSize = LocalSizes.current.iconSizeTertiary,
borderInactive = defaultDropdownListInactiveBorder(),
borderActive = defaultDropdownListActiveBorder()

View File

@@ -442,10 +442,7 @@ private fun defaultTabStyle() = TabStyle(
horizontal = LocalSizes.current.spacingPrimary,
vertical = LocalSizes.current.spacingSecondary,
),
contentShape = when (LocalInAreaBox.current) {
true -> LocalAreaBoxShape.current
else -> LocalShapes.current.secondary
},
contentShape = withAreaBoxShape(),
indicatorWidth = Dp.Unspecified,
indicatorHeight = DefaultTabIndicatorHeight,
indicatorShape = LocalShapes.current.tertiary

View File

@@ -87,7 +87,6 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.PopupProperties
import com.highcapable.flexiui.LocalColors
import com.highcapable.flexiui.LocalShapes
import com.highcapable.flexiui.LocalSizes
import com.highcapable.flexiui.extension.borderOrNot
import com.highcapable.flexiui.extension.calculateEnd
@@ -788,10 +787,7 @@ private fun defaultTextFieldColors() = TextFieldColors(
@ReadOnlyComposable
private fun defaultTextFieldStyle() = TextFieldStyle(
padding = PaddingValues(LocalSizes.current.spacingSecondary),
shape = when (LocalInAreaBox.current) {
true -> LocalAreaBoxShape.current
else -> LocalShapes.current.secondary
},
shape = withAreaBoxShape(),
borderInactive = defaultTextFieldInactiveBorder(),
borderActive = defaultTextFieldActiveBorder(),
completionStyle = DropdownMenu.style