From 01bb17c988fae61964fcc99ca5a26fef97936d9d Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Thu, 30 Nov 2023 14:09:00 +0800 Subject: [PATCH] refactor: not use default prefix when there are no default value --- .../highcapable/flexiui/component/Dropdown.kt | 12 ++++++------ .../com/highcapable/flexiui/component/Tab.kt | 11 ++++++----- .../highcapable/flexiui/component/TextField.kt | 16 ++++++++-------- .../flexiui/component/DesktopContextMenu.kt | 17 +++++++++-------- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Dropdown.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Dropdown.kt index 1badd57..7b657d8 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Dropdown.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Dropdown.kt @@ -341,9 +341,9 @@ fun DropdownMenuItem( .then(modifier) .fillMaxWidth() .sizeIn( - minWidth = DefaultMenuItemMinWidth, - maxWidth = DefaultMenuItemMaxWidth, - minHeight = DefaultMenuItemMinHeight + minWidth = MenuItemMinWidth, + maxWidth = MenuItemMaxWidth, + minHeight = MenuItemMinHeight ) .rippleClickable( enabled = enabled, @@ -604,6 +604,6 @@ private val DefaultMenuContentPadding = 16.dp private const val DefaultInTransitionDuration = 120 private const val DefaultOutTransitionDuration = 90 -private val DefaultMenuItemMinWidth = 112.dp -private val DefaultMenuItemMaxWidth = 280.dp -private val DefaultMenuItemMinHeight = 32.dp \ No newline at end of file +private val MenuItemMinWidth = 112.dp +private val MenuItemMaxWidth = 280.dp +private val MenuItemMinHeight = 32.dp \ No newline at end of file diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Tab.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Tab.kt index 2d289be..163daac 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Tab.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Tab.kt @@ -295,11 +295,11 @@ class TabRow internal constructor( val currentWidth = indicatorWidth.orElse() ?: currentTabPosition.tabWidth val animatedWidh by animateDpAsState( targetValue = currentWidth, - animationSpec = tween(DefaultTabIndicatorDuration, easing = FastOutSlowInEasing) + animationSpec = tween(TabIndicatorDuration, easing = FastOutSlowInEasing) ) val animatedOffsetX by animateDpAsState( targetValue = currentTabPosition.calculateCenter(currentWidth), - animationSpec = tween(DefaultTabIndicatorDuration, easing = FastOutSlowInEasing) + animationSpec = tween(TabIndicatorDuration, easing = FastOutSlowInEasing) ) fillMaxWidth() .wrapContentSize(Alignment.BottomStart) @@ -378,7 +378,7 @@ private class ScrollableTabData(private val scrollState: ScrollState, private va coroutineScope.launch { scrollState.animateScrollTo( value = calculatedOffset, - animationSpec = tween(DefaultTabIndicatorDuration, easing = FastOutSlowInEasing) + animationSpec = tween(TabIndicatorDuration, easing = FastOutSlowInEasing) ) } } @@ -448,5 +448,6 @@ private fun defaultTabStyle() = TabStyle( indicatorShape = LocalShapes.current.tertiary ) -private const val DefaultTabIndicatorDuration = 250 -private val DefaultTabIndicatorHeight = 3.dp \ No newline at end of file +private val DefaultTabIndicatorHeight = 3.dp + +private const val TabIndicatorDuration = 250 \ No newline at end of file diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/TextField.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/TextField.kt index bd6daaa..0af7a46 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/TextField.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/TextField.kt @@ -356,17 +356,17 @@ fun PasswordTextField( placeholder = placeholder, footer = { Box( - modifier = Modifier.width(DefaultDecorIconSize), + modifier = Modifier.width(TextDecorIconSize), 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 pressed by cInteractionSource.collectIsPressedAsState() if (pressed) focusRequester.requestFocus() if (value.text.isEmpty() && animatedSize == 0.dp) passwordVisible = defaultPasswordVisible IconToggleButton( modifier = Modifier.size(animatedSize).pointerHoverState(TextFieldPointerState.Common), - style = IconButton.style.copy(padding = DefaultDecorIconPadding), + style = IconButton.style.copy(padding = TextDecorIconPadding), checked = passwordVisible, onCheckedChange = { passwordVisible = it @@ -471,10 +471,10 @@ fun BackspaceTextField( placeholder = placeholder, footer = { Box( - modifier = Modifier.width(DefaultDecorIconSize), + modifier = Modifier.width(TextDecorIconSize), 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 pressed by cInteractionSource.collectIsPressedAsState() if (pressed) focusRequester.requestFocus() @@ -489,7 +489,7 @@ fun BackspaceTextField( focusRequester.requestFocus() }, modifier = Modifier.width(animatedSize).pointerHoverState(TextFieldPointerState.Common), - style = IconButton.style.copy(padding = DefaultDecorIconPadding), + style = IconButton.style.copy(padding = TextDecorIconPadding), enabled = enabled, interactionSource = cInteractionSource ) { Icon(imageVector = Icons.Backspace) } @@ -797,5 +797,5 @@ private fun defaultTextFieldInactiveBorder() = BorderStroke(LocalSizes.current.b @ReadOnlyComposable private fun defaultTextFieldActiveBorder() = BorderStroke(LocalSizes.current.borderSizePrimary, LocalColors.current.themePrimary) -private val DefaultDecorIconSize = 24.dp -private val DefaultDecorIconPadding = PaddingValues(2.dp) \ No newline at end of file +private val TextDecorIconSize = 24.dp +private val TextDecorIconPadding = PaddingValues(2.dp) \ No newline at end of file diff --git a/flexiui-core/src/desktopMain/kotlin/com/highcapable/flexiui/component/DesktopContextMenu.kt b/flexiui-core/src/desktopMain/kotlin/com/highcapable/flexiui/component/DesktopContextMenu.kt index f295e5a..a95b4f1 100644 --- a/flexiui-core/src/desktopMain/kotlin/com/highcapable/flexiui/component/DesktopContextMenu.kt +++ b/flexiui-core/src/desktopMain/kotlin/com/highcapable/flexiui/component/DesktopContextMenu.kt @@ -64,8 +64,8 @@ import androidx.compose.ui.window.rememberPopupPositionProviderAtPosition import com.highcapable.flexiui.LocalColors import com.highcapable.flexiui.LocalShapes import com.highcapable.flexiui.LocalSizes -import com.highcapable.flexiui.interaction.rippleClickable import com.highcapable.flexiui.extension.orElse +import com.highcapable.flexiui.interaction.rippleClickable import java.awt.event.KeyEvent @Immutable @@ -150,9 +150,9 @@ private fun MenuItemContent( .onHover { hovered = it } .fillMaxWidth() .sizeIn( - minWidth = DefaultMenuContentMinWidth, - maxWidth = DefaultMenuContentMaxWidth, - minHeight = DefaultMenuContentMinHeight + minWidth = MenuContentMinWidth, + maxWidth = MenuContentMaxWidth, + minHeight = MenuContentMinHeight ), color = Color.Transparent, style = style, @@ -218,7 +218,8 @@ internal fun defaultContextMenuStyle() = ContextMenuStyle( ) ) -private val DefaultMenuContentMinWidth = 112.dp -private val DefaultMenuContentMaxWidth = 280.dp -private val DefaultMenuContentMinHeight = 32.dp -private val DefaultMenuContentPadding = 16.dp \ No newline at end of file +private val DefaultMenuContentPadding = 16.dp + +private val MenuContentMinWidth = 112.dp +private val MenuContentMaxWidth = 280.dp +private val MenuContentMinHeight = 32.dp \ No newline at end of file