mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
refactor: not use default prefix when there are no default value
This commit is contained in:
@@ -341,9 +341,9 @@ fun DropdownMenuItem(
|
|||||||
.then(modifier)
|
.then(modifier)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.sizeIn(
|
.sizeIn(
|
||||||
minWidth = DefaultMenuItemMinWidth,
|
minWidth = MenuItemMinWidth,
|
||||||
maxWidth = DefaultMenuItemMaxWidth,
|
maxWidth = MenuItemMaxWidth,
|
||||||
minHeight = DefaultMenuItemMinHeight
|
minHeight = MenuItemMinHeight
|
||||||
)
|
)
|
||||||
.rippleClickable(
|
.rippleClickable(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
@@ -604,6 +604,6 @@ private val DefaultMenuContentPadding = 16.dp
|
|||||||
private const val DefaultInTransitionDuration = 120
|
private const val DefaultInTransitionDuration = 120
|
||||||
private const val DefaultOutTransitionDuration = 90
|
private const val DefaultOutTransitionDuration = 90
|
||||||
|
|
||||||
private val DefaultMenuItemMinWidth = 112.dp
|
private val MenuItemMinWidth = 112.dp
|
||||||
private val DefaultMenuItemMaxWidth = 280.dp
|
private val MenuItemMaxWidth = 280.dp
|
||||||
private val DefaultMenuItemMinHeight = 32.dp
|
private val MenuItemMinHeight = 32.dp
|
@@ -295,11 +295,11 @@ class TabRow internal constructor(
|
|||||||
val currentWidth = indicatorWidth.orElse() ?: currentTabPosition.tabWidth
|
val currentWidth = indicatorWidth.orElse() ?: currentTabPosition.tabWidth
|
||||||
val animatedWidh by animateDpAsState(
|
val animatedWidh by animateDpAsState(
|
||||||
targetValue = currentWidth,
|
targetValue = currentWidth,
|
||||||
animationSpec = tween(DefaultTabIndicatorDuration, easing = FastOutSlowInEasing)
|
animationSpec = tween(TabIndicatorDuration, easing = FastOutSlowInEasing)
|
||||||
)
|
)
|
||||||
val animatedOffsetX by animateDpAsState(
|
val animatedOffsetX by animateDpAsState(
|
||||||
targetValue = currentTabPosition.calculateCenter(currentWidth),
|
targetValue = currentTabPosition.calculateCenter(currentWidth),
|
||||||
animationSpec = tween(DefaultTabIndicatorDuration, easing = FastOutSlowInEasing)
|
animationSpec = tween(TabIndicatorDuration, easing = FastOutSlowInEasing)
|
||||||
)
|
)
|
||||||
fillMaxWidth()
|
fillMaxWidth()
|
||||||
.wrapContentSize(Alignment.BottomStart)
|
.wrapContentSize(Alignment.BottomStart)
|
||||||
@@ -378,7 +378,7 @@ private class ScrollableTabData(private val scrollState: ScrollState, private va
|
|||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
scrollState.animateScrollTo(
|
scrollState.animateScrollTo(
|
||||||
value = calculatedOffset,
|
value = calculatedOffset,
|
||||||
animationSpec = tween(DefaultTabIndicatorDuration, easing = FastOutSlowInEasing)
|
animationSpec = tween(TabIndicatorDuration, easing = FastOutSlowInEasing)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -448,5 +448,6 @@ private fun defaultTabStyle() = TabStyle(
|
|||||||
indicatorShape = LocalShapes.current.tertiary
|
indicatorShape = LocalShapes.current.tertiary
|
||||||
)
|
)
|
||||||
|
|
||||||
private const val DefaultTabIndicatorDuration = 250
|
private val DefaultTabIndicatorHeight = 3.dp
|
||||||
private val DefaultTabIndicatorHeight = 3.dp
|
|
||||||
|
private const val TabIndicatorDuration = 250
|
@@ -356,17 +356,17 @@ fun PasswordTextField(
|
|||||||
placeholder = placeholder,
|
placeholder = placeholder,
|
||||||
footer = {
|
footer = {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.width(DefaultDecorIconSize),
|
modifier = Modifier.width(TextDecorIconSize),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
val animatedSize by animateDpAsState(if (value.text.isNotEmpty()) DefaultDecorIconSize else 0.dp)
|
val animatedSize by animateDpAsState(if (value.text.isNotEmpty()) TextDecorIconSize else 0.dp)
|
||||||
val cInteractionSource = remember { MutableInteractionSource() }
|
val cInteractionSource = remember { MutableInteractionSource() }
|
||||||
val pressed by cInteractionSource.collectIsPressedAsState()
|
val pressed by cInteractionSource.collectIsPressedAsState()
|
||||||
if (pressed) focusRequester.requestFocus()
|
if (pressed) focusRequester.requestFocus()
|
||||||
if (value.text.isEmpty() && animatedSize == 0.dp) passwordVisible = defaultPasswordVisible
|
if (value.text.isEmpty() && animatedSize == 0.dp) passwordVisible = defaultPasswordVisible
|
||||||
IconToggleButton(
|
IconToggleButton(
|
||||||
modifier = Modifier.size(animatedSize).pointerHoverState(TextFieldPointerState.Common),
|
modifier = Modifier.size(animatedSize).pointerHoverState(TextFieldPointerState.Common),
|
||||||
style = IconButton.style.copy(padding = DefaultDecorIconPadding),
|
style = IconButton.style.copy(padding = TextDecorIconPadding),
|
||||||
checked = passwordVisible,
|
checked = passwordVisible,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
passwordVisible = it
|
passwordVisible = it
|
||||||
@@ -471,10 +471,10 @@ fun BackspaceTextField(
|
|||||||
placeholder = placeholder,
|
placeholder = placeholder,
|
||||||
footer = {
|
footer = {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.width(DefaultDecorIconSize),
|
modifier = Modifier.width(TextDecorIconSize),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
val animatedSize by animateDpAsState(if (value.text.isNotEmpty()) DefaultDecorIconSize else 0.dp)
|
val animatedSize by animateDpAsState(if (value.text.isNotEmpty()) TextDecorIconSize else 0.dp)
|
||||||
val cInteractionSource = remember { MutableInteractionSource() }
|
val cInteractionSource = remember { MutableInteractionSource() }
|
||||||
val pressed by cInteractionSource.collectIsPressedAsState()
|
val pressed by cInteractionSource.collectIsPressedAsState()
|
||||||
if (pressed) focusRequester.requestFocus()
|
if (pressed) focusRequester.requestFocus()
|
||||||
@@ -489,7 +489,7 @@ fun BackspaceTextField(
|
|||||||
focusRequester.requestFocus()
|
focusRequester.requestFocus()
|
||||||
},
|
},
|
||||||
modifier = Modifier.width(animatedSize).pointerHoverState(TextFieldPointerState.Common),
|
modifier = Modifier.width(animatedSize).pointerHoverState(TextFieldPointerState.Common),
|
||||||
style = IconButton.style.copy(padding = DefaultDecorIconPadding),
|
style = IconButton.style.copy(padding = TextDecorIconPadding),
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
interactionSource = cInteractionSource
|
interactionSource = cInteractionSource
|
||||||
) { Icon(imageVector = Icons.Backspace) }
|
) { Icon(imageVector = Icons.Backspace) }
|
||||||
@@ -797,5 +797,5 @@ private fun defaultTextFieldInactiveBorder() = BorderStroke(LocalSizes.current.b
|
|||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
private fun defaultTextFieldActiveBorder() = BorderStroke(LocalSizes.current.borderSizePrimary, LocalColors.current.themePrimary)
|
private fun defaultTextFieldActiveBorder() = BorderStroke(LocalSizes.current.borderSizePrimary, LocalColors.current.themePrimary)
|
||||||
|
|
||||||
private val DefaultDecorIconSize = 24.dp
|
private val TextDecorIconSize = 24.dp
|
||||||
private val DefaultDecorIconPadding = PaddingValues(2.dp)
|
private val TextDecorIconPadding = PaddingValues(2.dp)
|
@@ -64,8 +64,8 @@ import androidx.compose.ui.window.rememberPopupPositionProviderAtPosition
|
|||||||
import com.highcapable.flexiui.LocalColors
|
import com.highcapable.flexiui.LocalColors
|
||||||
import com.highcapable.flexiui.LocalShapes
|
import com.highcapable.flexiui.LocalShapes
|
||||||
import com.highcapable.flexiui.LocalSizes
|
import com.highcapable.flexiui.LocalSizes
|
||||||
import com.highcapable.flexiui.interaction.rippleClickable
|
|
||||||
import com.highcapable.flexiui.extension.orElse
|
import com.highcapable.flexiui.extension.orElse
|
||||||
|
import com.highcapable.flexiui.interaction.rippleClickable
|
||||||
import java.awt.event.KeyEvent
|
import java.awt.event.KeyEvent
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -150,9 +150,9 @@ private fun MenuItemContent(
|
|||||||
.onHover { hovered = it }
|
.onHover { hovered = it }
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.sizeIn(
|
.sizeIn(
|
||||||
minWidth = DefaultMenuContentMinWidth,
|
minWidth = MenuContentMinWidth,
|
||||||
maxWidth = DefaultMenuContentMaxWidth,
|
maxWidth = MenuContentMaxWidth,
|
||||||
minHeight = DefaultMenuContentMinHeight
|
minHeight = MenuContentMinHeight
|
||||||
),
|
),
|
||||||
color = Color.Transparent,
|
color = Color.Transparent,
|
||||||
style = style,
|
style = style,
|
||||||
@@ -218,7 +218,8 @@ internal fun defaultContextMenuStyle() = ContextMenuStyle(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
private val DefaultMenuContentMinWidth = 112.dp
|
private val DefaultMenuContentPadding = 16.dp
|
||||||
private val DefaultMenuContentMaxWidth = 280.dp
|
|
||||||
private val DefaultMenuContentMinHeight = 32.dp
|
private val MenuContentMinWidth = 112.dp
|
||||||
private val DefaultMenuContentPadding = 16.dp
|
private val MenuContentMaxWidth = 280.dp
|
||||||
|
private val MenuContentMinHeight = 32.dp
|
Reference in New Issue
Block a user