@momo-kits/native-kits 0.167.1-duo-search.1-debug → 0.167.1-duo-search.2-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +4 -1
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +134 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +20 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +9 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +4 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +10 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +6 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +7 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +13 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +14 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +19 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +5 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +7 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +11 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +8 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +2 -1
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +11 -0
- package/ios/Application/ComposeApi.swift +2 -1
- package/ios/Application/{Components.swift → LegacyHeader.swift} +6 -62
- package/ios/Application/Screen.swift +3 -2
- package/ios/Avatar/Avatar.swift +4 -3
- package/ios/Badge/Badge.swift +6 -4
- package/ios/Badge/BadgeDot.swift +1 -1
- package/ios/Badge/BadgeRibbon.swift +0 -1
- package/ios/Button/Button.swift +15 -12
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +12 -20
- package/ios/Carousel/Carousel.swift +29 -12
- package/ios/Checkbox/Checkbox.swift +7 -3
- package/ios/Chip/Chip.swift +5 -4
- package/ios/Collapse/Collapse.swift +70 -19
- package/ios/Colors+Radius+Spacing/Colors.swift +9 -0
- package/ios/DateTimePicker/DateTimePicker.swift +54 -20
- package/ios/DateTimePicker/WheelPicker.swift +103 -105
- package/ios/Divider/Divider.swift +37 -4
- package/ios/Extensions/Color++.swift +18 -0
- package/ios/Extensions/SkeletonUICompat.swift +11 -0
- package/ios/Icon/Icon.swift +7 -1
- package/ios/IconButton/IconButton.swift +15 -7
- package/ios/Image/Image.swift +7 -34
- package/ios/Information/Information.swift +27 -9
- package/ios/Input/ErrorView.swift +2 -2
- package/ios/Input/Input.swift +160 -147
- package/ios/Input/InputPhoneNumber.swift +12 -9
- package/ios/Input/InputSearch.swift +102 -75
- package/ios/Input/InputTextArea.swift +128 -145
- package/ios/InputDropDown/InputDropDown.swift +10 -7
- package/ios/InputMoney/InputMoney.swift +33 -11
- package/ios/InputOTP/InputOTP.swift +22 -12
- package/ios/Layout/Card.swift +50 -0
- package/ios/Layout/GridContext.swift +123 -3
- package/ios/Layout/Item.swift +5 -4
- package/ios/Layout/Section.swift +4 -100
- package/ios/Loader/Loader.swift +5 -9
- package/ios/Lottie/LottieView.swift +10 -0
- package/ios/{Application/Navigation/Overplay → Navigation}/BottomSheet.swift +65 -9
- package/ios/{Application/Navigation → Navigation}/BottomTab/BottomTab.swift +60 -34
- package/ios/{Application/Navigation → Navigation}/BottomTab/BottomTabBar.swift +11 -6
- package/ios/{Application → Navigation/Component}/FloatingButton.swift +14 -3
- package/ios/Navigation/Component/Header.swift +493 -0
- package/ios/Navigation/Component/HeaderBackground.swift +134 -0
- package/ios/Navigation/Component/HeaderJourney.swift +73 -0
- package/ios/Navigation/Component/HeaderLocation.swift +48 -0
- package/ios/Navigation/Component/HeaderRight.swift +386 -0
- package/ios/Navigation/Component/HeaderTitle.swift +36 -0
- package/ios/{Application/Navigation → Navigation/Component}/HeaderUser.swift +20 -23
- package/ios/{Application/Navigation/component → Navigation/Component}/SideBar.swift +49 -28
- package/ios/{Application/Navigation/Overplay → Navigation/Component}/SnackBar.swift +5 -5
- package/ios/Navigation/HostBackGestureBridge.swift +57 -0
- package/ios/Navigation/Navigation.swift +190 -0
- package/ios/{Application/Navigation → Navigation}/NavigationContainer.swift +46 -41
- package/ios/{Application/Navigation → Navigation}/Navigator.swift +65 -9
- package/ios/{Application → Navigation}/StackScreen.swift +236 -103
- package/ios/{Application/Navigation → Navigation}/Tracking/ScreenTracker.swift +12 -5
- package/ios/OTPKeyboard/OTPKeyboard.swift +8 -11
- package/ios/Pagination/PaginationScroll.swift +2 -2
- package/ios/Popup/PopupDisplay.swift +79 -159
- package/ios/Popup/PopupInput.swift +10 -13
- package/ios/Popup/PopupLayout.swift +97 -2
- package/ios/Popup/PopupNotify.swift +27 -55
- package/ios/Popup/PopupPromotion.swift +22 -50
- package/ios/PopupView/FullscreenPopup.swift +13 -19
- package/ios/PopupView/PopupView.swift +1 -1
- package/ios/PopupView/Utils++.swift +0 -8
- package/ios/ProgressInfo/ProgressInfo.swift +4 -2
- package/ios/Radio/Radio.swift +2 -1
- package/ios/Rating/Rating.swift +9 -1
- package/ios/ScrollIndicator/ScrollIndicator.swift +11 -10
- package/ios/Skeleton/Skeleton.swift +22 -27
- package/ios/Slider/Slider.swift +16 -18
- package/ios/Stepper/Stepper.swift +6 -1
- package/ios/Steps/Steps.swift +8 -6
- package/ios/SuggestAction/SuggestAction.swift +5 -0
- package/ios/Swipeable/SwipeCell.swift +10 -6
- package/ios/Switch/Switch.swift +22 -20
- package/ios/TabView/TabView.swift +102 -21
- package/ios/Tag/Tag.swift +15 -4
- package/ios/Template/Logo/Logo.swift +2 -1
- package/ios/Template/TrustBanner/TrustBanner.swift +41 -27
- package/ios/Title/Title.swift +6 -17
- package/ios/Tooltip/Tooltip.swift +29 -14
- package/ios/Typography/Text.swift +61 -19
- package/ios/Uploader/Uploader.swift +3 -1
- package/ios/native-kits.podspec +2 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +77 -1
- package/package.json +1 -1
- package/ios/Application/HeaderRight.swift +0 -324
- package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
- package/ios/Application/Navigation/HeaderTitle.swift +0 -57
- package/ios/Application/Navigation/NavigationOptions.swift +0 -109
- package/ios/Application/Navigation/NavigatorManager.swift +0 -29
- package/ios/Application/Navigation/component/DuoScrollGradient.swift +0 -54
- package/ios/Application/Navigation/component/Header.swift +0 -183
- package/ios/Application/Navigation/component/HeaderBackground.swift +0 -84
- package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
- package/ios/Application/Navigation/component/HeaderRightWidthKey.swift +0 -11
- package/ios/Application/Navigation/component/NavigationFooter.swift +0 -90
- package/ios/Application/Navigation/component/NavigationHeaderRight.swift +0 -280
- /package/ios/{Application/Layout → Layout}/ScreenLayout.swift +0 -0
- /package/ios/{Application/Navigation → Navigation}/BottomTab/CurvedContainer.swift +0 -0
- /package/ios/{Application/Navigation → Navigation}/BottomTab/DuoBarCompression.swift +0 -0
- /package/ios/{Application/Navigation → Navigation}/BottomTab/DuoTabBar.swift +0 -0
- /package/ios/{Application/Navigation/Overplay → Navigation}/ModalScreen.swift +0 -0
|
@@ -101,7 +101,6 @@ fun InputOTP(
|
|
|
101
101
|
) {
|
|
102
102
|
val maxLength = length ?: 10
|
|
103
103
|
var isFocused by remember { mutableStateOf(false) }
|
|
104
|
-
var isBlurred = false
|
|
105
104
|
|
|
106
105
|
val handleChangeText: (String) -> Unit = { text ->
|
|
107
106
|
if (text.length <= maxLength &&
|
|
@@ -127,13 +126,9 @@ fun InputOTP(
|
|
|
127
126
|
onValueChange = handleChangeText,
|
|
128
127
|
singleLine = true,
|
|
129
128
|
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = if (dataType == "number") KeyboardType.Number else KeyboardType.Ascii),
|
|
130
|
-
modifier =
|
|
129
|
+
modifier = Modifier.height(56.dp).onFocusChanged {
|
|
130
|
+
if (it.isFocused) onFocus() else if (isFocused) onBlur()
|
|
131
131
|
isFocused = it.isFocused
|
|
132
|
-
if (it.isFocused) {
|
|
133
|
-
onFocus()
|
|
134
|
-
}
|
|
135
|
-
if (!it.isFocused && isBlurred) onBlur()
|
|
136
|
-
if (it.isFocused && !isBlurred) isBlurred = true
|
|
137
132
|
},
|
|
138
133
|
decorationBox = { innerTextField ->
|
|
139
134
|
Box {
|
|
@@ -207,11 +202,11 @@ fun InputOTP(
|
|
|
207
202
|
style = Typography.headerDefaultBold,
|
|
208
203
|
text = value[i].toString()
|
|
209
204
|
)
|
|
210
|
-
if (i != value.length - 1 || (isFocused && value.length !=
|
|
205
|
+
if (i != value.length - 1 || (isFocused && value.length != maxLength)) {
|
|
211
206
|
Spacer(Modifier.width(Spacing.L))
|
|
212
207
|
}
|
|
213
208
|
}
|
|
214
|
-
if (isFocused && value.length !=
|
|
209
|
+
if (isFocused && value.length != maxLength) OTPCaret()
|
|
215
210
|
}
|
|
216
211
|
}
|
|
217
212
|
}
|
|
@@ -89,7 +89,7 @@ fun InputPhoneNumber(
|
|
|
89
89
|
|
|
90
90
|
// Memoized color calculations
|
|
91
91
|
val theme = AppTheme.current
|
|
92
|
-
val colors = remember(
|
|
92
|
+
val colors = remember(theme, iconColor) {
|
|
93
93
|
Triple(
|
|
94
94
|
theme.colors.text.default, // textColor
|
|
95
95
|
theme.colors.text.hint, // placeholderColor
|
|
@@ -173,7 +173,7 @@ fun InputPhoneNumber(
|
|
|
173
173
|
Box(
|
|
174
174
|
modifier = Modifier.width(1.dp)
|
|
175
175
|
.height(size.values.dividerHeight)
|
|
176
|
-
.background(
|
|
176
|
+
.background(theme.colors.border.default)
|
|
177
177
|
)
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -29,6 +29,7 @@ import androidx.compose.ui.Alignment
|
|
|
29
29
|
import androidx.compose.ui.Modifier
|
|
30
30
|
import androidx.compose.ui.focus.onFocusChanged
|
|
31
31
|
import androidx.compose.ui.graphics.Color
|
|
32
|
+
import androidx.compose.ui.graphics.SolidColor
|
|
32
33
|
import androidx.compose.ui.graphics.takeOrElse
|
|
33
34
|
import androidx.compose.ui.text.TextStyle
|
|
34
35
|
import androidx.compose.ui.text.input.KeyboardType
|
|
@@ -99,7 +100,8 @@ data class InputSearchProps(
|
|
|
99
100
|
val loading: Boolean = false,
|
|
100
101
|
val fontWeight: InputFontWeight = InputFontWeight.REGULAR,
|
|
101
102
|
val keyboardType: KeyboardType = KeyboardType.Text,
|
|
102
|
-
|
|
103
|
+
// Unspecified resolves to the theme surface (white in the light theme).
|
|
104
|
+
val backgroundColor: Color = Color.Unspecified,
|
|
103
105
|
val clearCondition: (() -> Boolean)? = null,
|
|
104
106
|
val keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
|
|
105
107
|
val keyboardActions: KeyboardActions = KeyboardActions.Default,
|
|
@@ -118,7 +120,6 @@ fun InputSearch(
|
|
|
118
120
|
),
|
|
119
121
|
) {
|
|
120
122
|
var isFocused by remember { mutableStateOf(false) }
|
|
121
|
-
var isBlurred = false
|
|
122
123
|
val disabledColor = AppTheme.current.colors.text.disable
|
|
123
124
|
var textColor = AppTheme.current.colors.text.default
|
|
124
125
|
var placeholderColor = AppTheme.current.colors.text.hint
|
|
@@ -134,7 +135,7 @@ fun InputSearch(
|
|
|
134
135
|
|
|
135
136
|
val fontFamily = getFontFamily(AppTheme.current.font, inputSearchProps.fontWeight.value)
|
|
136
137
|
|
|
137
|
-
val textStyle = remember(textColor, inputSearchProps.fontWeight.value, fontFamily) {
|
|
138
|
+
val textStyle = remember(textColor, inputSearchProps.fontWeight.value, fontFamily, scaleFontSize) {
|
|
138
139
|
TextStyle(
|
|
139
140
|
color = textColor,
|
|
140
141
|
fontSize = scaleFontSize,
|
|
@@ -167,13 +168,13 @@ fun InputSearch(
|
|
|
167
168
|
textStyle = textStyle,
|
|
168
169
|
keyboardOptions = inputSearchProps.keyboardOptions.copy(keyboardType = inputSearchProps.keyboardType),
|
|
169
170
|
keyboardActions = inputSearchProps.keyboardActions,
|
|
171
|
+
cursorBrush = SolidColor(AppTheme.current.colors.primary),
|
|
172
|
+
// Transitions only: onFocusChanged also runs once on attach with isFocused = false.
|
|
170
173
|
modifier = inputSearchProps.modifier.weight(1f).fillMaxHeight().onFocusChanged {
|
|
174
|
+
val wasFocused = isFocused
|
|
171
175
|
isFocused = it.isFocused
|
|
172
|
-
if (it.isFocused)
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
if (!it.isFocused && isBlurred) inputSearchProps.onBlur()
|
|
176
|
-
if (it.isFocused && !isBlurred) isBlurred = true
|
|
176
|
+
if (it.isFocused && !wasFocused) inputSearchProps.onFocus()
|
|
177
|
+
if (!it.isFocused && wasFocused) inputSearchProps.onBlur()
|
|
177
178
|
},
|
|
178
179
|
onValueChange = inputSearchProps.onChangeText,
|
|
179
180
|
decorationBox = { innerTextField ->
|
|
@@ -186,7 +187,7 @@ fun InputSearch(
|
|
|
186
187
|
)
|
|
187
188
|
).fillMaxHeight()
|
|
188
189
|
.background(
|
|
189
|
-
inputSearchProps.backgroundColor,
|
|
190
|
+
inputSearchProps.backgroundColor.takeOrElse { AppTheme.current.colors.background.surface },
|
|
190
191
|
RoundedCornerShape(Radius.XL)
|
|
191
192
|
),
|
|
192
193
|
horizontalArrangement = Arrangement.Start,
|
|
@@ -13,6 +13,7 @@ import androidx.compose.ui.Alignment
|
|
|
13
13
|
import androidx.compose.ui.Modifier
|
|
14
14
|
import androidx.compose.ui.focus.onFocusChanged
|
|
15
15
|
import androidx.compose.ui.graphics.Color
|
|
16
|
+
import androidx.compose.ui.graphics.SolidColor
|
|
16
17
|
import androidx.compose.ui.text.TextStyle
|
|
17
18
|
import androidx.compose.ui.text.input.KeyboardType
|
|
18
19
|
import androidx.compose.ui.unit.Dp
|
|
@@ -56,7 +57,6 @@ fun InputTextArea(
|
|
|
56
57
|
keyboardType: KeyboardType = KeyboardType.Text,
|
|
57
58
|
) {
|
|
58
59
|
var isFocused by remember { mutableStateOf(false) }
|
|
59
|
-
var isBlurred = false
|
|
60
60
|
val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) =
|
|
61
61
|
getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
|
|
62
62
|
|
|
@@ -81,13 +81,13 @@ fun InputTextArea(
|
|
|
81
81
|
fontFamily = getFontFamily(AppTheme.current.font, fontWeight.value)
|
|
82
82
|
),
|
|
83
83
|
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
|
|
84
|
+
cursorBrush = SolidColor(AppTheme.current.colors.primary),
|
|
85
|
+
// Transitions only: onFocusChanged also runs once on attach with isFocused = false.
|
|
84
86
|
modifier = Modifier.height(scaleHeight).onFocusChanged {
|
|
87
|
+
val wasFocused = isFocused
|
|
85
88
|
isFocused = it.isFocused
|
|
86
|
-
if (it.isFocused)
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
if (!it.isFocused && isBlurred) onBlur()
|
|
90
|
-
if (it.isFocused && !isBlurred) isBlurred = true
|
|
89
|
+
if (it.isFocused && !wasFocused) onFocus()
|
|
90
|
+
if (!it.isFocused && wasFocused) onBlur()
|
|
91
91
|
},
|
|
92
92
|
onValueChange = {
|
|
93
93
|
if (it.length <= maxLength) {
|
|
@@ -254,7 +254,7 @@ internal fun BuildAction(
|
|
|
254
254
|
val closeAction = remember { mutableStateOf("button_action") }
|
|
255
255
|
when (buttonDirection) {
|
|
256
256
|
PopupActionDirection.AUTO -> {
|
|
257
|
-
if (secondary != null && (secondary.title.length > 12 || primary?.title?.length
|
|
257
|
+
if (secondary != null && (secondary.title.length > 12 || (primary?.title?.length ?: 0) > 12)) {
|
|
258
258
|
RenderColumn(
|
|
259
259
|
secondary = secondary,
|
|
260
260
|
onAction = onAction,
|
|
@@ -5,13 +5,10 @@ import androidx.compose.foundation.border
|
|
|
5
5
|
import androidx.compose.foundation.layout.*
|
|
6
6
|
import androidx.compose.foundation.shape.CircleShape
|
|
7
7
|
import androidx.compose.runtime.Composable
|
|
8
|
-
import androidx.compose.runtime.mutableFloatStateOf
|
|
9
8
|
import androidx.compose.runtime.remember
|
|
10
9
|
import androidx.compose.ui.Alignment
|
|
11
10
|
import androidx.compose.ui.Modifier
|
|
12
11
|
import androidx.compose.ui.draw.clip
|
|
13
|
-
import androidx.compose.ui.layout.onGloballyPositioned
|
|
14
|
-
import androidx.compose.ui.platform.LocalDensity
|
|
15
12
|
import androidx.compose.ui.text.style.TextAlign
|
|
16
13
|
import androidx.compose.ui.unit.dp
|
|
17
14
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
@@ -180,7 +177,6 @@ private fun ProgressInfoVertical(
|
|
|
180
177
|
) {
|
|
181
178
|
val theme = AppTheme.current
|
|
182
179
|
val lineColor = remember(theme) { theme.colors.primary.copy(alpha = 0.2f) }
|
|
183
|
-
val density = LocalDensity.current
|
|
184
180
|
|
|
185
181
|
Column(
|
|
186
182
|
modifier = modifier
|
|
@@ -189,16 +185,18 @@ private fun ProgressInfoVertical(
|
|
|
189
185
|
) {
|
|
190
186
|
steps.forEachIndexed { index, item ->
|
|
191
187
|
val isLast = index == steps.lastIndex
|
|
192
|
-
val rowHeightPx = remember { mutableFloatStateOf(0f) }
|
|
193
|
-
val rowHeightDp = with(density) { rowHeightPx.value.toDp() }
|
|
194
188
|
|
|
189
|
+
// Intrinsic height lets the connector fill the row in one pass; measuring the row and
|
|
190
|
+
// feeding it back lagged a frame and never let the line shrink with its text.
|
|
195
191
|
Row(
|
|
196
192
|
modifier = Modifier
|
|
197
193
|
.fillMaxWidth()
|
|
198
|
-
.
|
|
194
|
+
.height(IntrinsicSize.Min),
|
|
199
195
|
) {
|
|
200
196
|
Column(
|
|
201
|
-
modifier = Modifier
|
|
197
|
+
modifier = Modifier
|
|
198
|
+
.fillMaxHeight()
|
|
199
|
+
.heightIn(min = if (isLast) 40.dp else 48.dp),
|
|
202
200
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
203
201
|
) {
|
|
204
202
|
ProgressInfoStepIcon(
|
|
@@ -211,7 +209,7 @@ private fun ProgressInfoVertical(
|
|
|
211
209
|
Spacer(
|
|
212
210
|
modifier = Modifier
|
|
213
211
|
.width(2.dp)
|
|
214
|
-
.
|
|
212
|
+
.weight(1f)
|
|
215
213
|
.background(lineColor),
|
|
216
214
|
)
|
|
217
215
|
}
|
|
@@ -40,7 +40,7 @@ fun Radio(
|
|
|
40
40
|
verticalAlignment = Alignment.CenterVertically,
|
|
41
41
|
) {
|
|
42
42
|
Box(
|
|
43
|
-
modifier =
|
|
43
|
+
modifier = Modifier
|
|
44
44
|
.padding(end = if (label.isEmpty()) 0.dp else Spacing.XS)
|
|
45
45
|
.border(borderWidth, borderColor, RoundedCornerShape(Radius.M))
|
|
46
46
|
.conditional(IsShowBaseLineDebug) {
|
|
@@ -43,9 +43,11 @@ private fun getValueForPosition(
|
|
|
43
43
|
step: Float,
|
|
44
44
|
): Float {
|
|
45
45
|
val availableSpace = containerWidth - thumbWidth
|
|
46
|
-
if (availableSpace <= 0f) return min
|
|
47
|
-
val relStepUnit = step / (max - min)
|
|
46
|
+
if (availableSpace <= 0f || max <= min) return min
|
|
48
47
|
var relPosition = (positionInView - thumbWidth / 2f) / availableSpace
|
|
48
|
+
// A zero step would make the snap math NaN, and NaN.roundToInt() throws.
|
|
49
|
+
if (step <= 0f) return clamp(min + relPosition * (max - min), min, max)
|
|
50
|
+
val relStepUnit = step / (max - min)
|
|
49
51
|
val relOffset = relPosition % relStepUnit
|
|
50
52
|
relPosition -= relOffset
|
|
51
53
|
if (relOffset / relStepUnit >= 0.5f) relPosition += relStepUnit
|
|
@@ -131,6 +133,11 @@ fun Slider(
|
|
|
131
133
|
var draggingLow by remember { mutableStateOf(true) }
|
|
132
134
|
var isDragging by remember { mutableStateOf(false) }
|
|
133
135
|
|
|
136
|
+
// pointerInput is not keyed on the callbacks, so read their latest values.
|
|
137
|
+
val currentOnValueChanged by rememberUpdatedState(onValueChanged)
|
|
138
|
+
val currentOnTouchStart by rememberUpdatedState(onSliderTouchStart)
|
|
139
|
+
val currentOnTouchEnd by rememberUpdatedState(onSliderTouchEnd)
|
|
140
|
+
|
|
134
141
|
val thumbColor = if (disabled) theme.colors.text.disable else theme.colors.primary
|
|
135
142
|
val trackActiveColor = if (disabled) theme.colors.text.disable else theme.colors.primary
|
|
136
143
|
val trackInactiveColor = theme.colors.background.default
|
|
@@ -167,7 +174,7 @@ fun Slider(
|
|
|
167
174
|
|
|
168
175
|
draggingLow = disableRange || isLowCloser(touchX, lowCenterX, highCenterX)
|
|
169
176
|
isDragging = true
|
|
170
|
-
|
|
177
|
+
currentOnTouchStart(lowValue, highValue)
|
|
171
178
|
|
|
172
179
|
// Apply initial press
|
|
173
180
|
applyDrag(touchX, trackWidthPx, thumbSizePx,
|
|
@@ -175,7 +182,7 @@ fun Slider(
|
|
|
175
182
|
lowValue, highValue) { nl, nh ->
|
|
176
183
|
lowValue = nl
|
|
177
184
|
highValue = nh
|
|
178
|
-
|
|
185
|
+
currentOnValueChanged(nl, nh, true)
|
|
179
186
|
}
|
|
180
187
|
|
|
181
188
|
// Track move / release
|
|
@@ -186,7 +193,7 @@ fun Slider(
|
|
|
186
193
|
|
|
187
194
|
if (!moveChange.pressed) {
|
|
188
195
|
isDragging = false
|
|
189
|
-
|
|
196
|
+
currentOnTouchEnd(lowValue, highValue)
|
|
190
197
|
break
|
|
191
198
|
}
|
|
192
199
|
|
|
@@ -195,7 +202,7 @@ fun Slider(
|
|
|
195
202
|
lowValue, highValue) { nl, nh ->
|
|
196
203
|
lowValue = nl
|
|
197
204
|
highValue = nh
|
|
198
|
-
|
|
205
|
+
currentOnValueChanged(nl, nh, true)
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
}
|
|
@@ -8,8 +8,10 @@ import androidx.compose.foundation.gestures.detectHorizontalDragGestures
|
|
|
8
8
|
import androidx.compose.foundation.layout.*
|
|
9
9
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
10
10
|
import androidx.compose.runtime.Composable
|
|
11
|
+
import androidx.compose.runtime.getValue
|
|
11
12
|
import androidx.compose.runtime.remember
|
|
12
13
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
14
|
+
import androidx.compose.runtime.rememberUpdatedState
|
|
13
15
|
import androidx.compose.ui.Alignment
|
|
14
16
|
import androidx.compose.ui.Modifier
|
|
15
17
|
import androidx.compose.ui.draw.clip
|
|
@@ -62,6 +64,12 @@ fun Swipe(
|
|
|
62
64
|
|
|
63
65
|
val offsetX = remember { Animatable(0f) }
|
|
64
66
|
|
|
67
|
+
// pointerInput is keyed on the action counts only, so read the latest callbacks.
|
|
68
|
+
val currentOnOpen by rememberUpdatedState(onSwipeableOpen)
|
|
69
|
+
val currentOnClose by rememberUpdatedState(onSwipeableClose)
|
|
70
|
+
val currentOnLeftOpen by rememberUpdatedState(onSwipeableLeftOpen)
|
|
71
|
+
val currentOnRightOpen by rememberUpdatedState(onSwipeableRightOpen)
|
|
72
|
+
|
|
65
73
|
val shape = remember(itemRadius) {
|
|
66
74
|
if (itemRadius > 0.dp) RoundedCornerShape(itemRadius) else RoundedCornerShape(0.dp)
|
|
67
75
|
}
|
|
@@ -71,17 +79,17 @@ fun Swipe(
|
|
|
71
79
|
val current = offsetX.value
|
|
72
80
|
val target = when {
|
|
73
81
|
current > leftWidthPx * 0.5f && left.isNotEmpty() -> {
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
currentOnLeftOpen()
|
|
83
|
+
currentOnOpen()
|
|
76
84
|
leftWidthPx
|
|
77
85
|
}
|
|
78
86
|
current < -rightWidthPx * 0.5f && right.isNotEmpty() -> {
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
currentOnRightOpen()
|
|
88
|
+
currentOnOpen()
|
|
81
89
|
-rightWidthPx
|
|
82
90
|
}
|
|
83
91
|
else -> {
|
|
84
|
-
|
|
92
|
+
currentOnClose()
|
|
85
93
|
0f
|
|
86
94
|
}
|
|
87
95
|
}
|
|
@@ -43,9 +43,10 @@ fun Switch(
|
|
|
43
43
|
|
|
44
44
|
val (circleBackgroundColor, backgroundColor) = colors
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// Both params default to "", so blank must fall back too or the id is always empty.
|
|
47
47
|
val automationIdValue = remember(accessibilityId, title, value) {
|
|
48
|
-
accessibilityId
|
|
48
|
+
accessibilityId?.takeIf { it.isNotEmpty() }
|
|
49
|
+
?: "toggle_${title?.takeIf { it.isNotEmpty() } ?: "unknown"}_$value"
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
// Memoize alignment calculation
|
|
@@ -10,9 +10,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
10
10
|
import androidx.compose.runtime.*
|
|
11
11
|
import androidx.compose.ui.Alignment
|
|
12
12
|
import androidx.compose.ui.Modifier
|
|
13
|
+
import androidx.compose.ui.draw.clipToBounds
|
|
14
|
+
import androidx.compose.ui.geometry.Offset
|
|
13
15
|
import androidx.compose.ui.graphics.Color
|
|
14
16
|
import androidx.compose.ui.graphics.drawscope.withTransform
|
|
15
|
-
import androidx.compose.ui.graphics.drawscope.DrawScope
|
|
16
17
|
import androidx.compose.ui.graphics.Path
|
|
17
18
|
import androidx.compose.ui.layout.onGloballyPositioned
|
|
18
19
|
import androidx.compose.ui.layout.positionInParent
|
|
@@ -73,6 +74,8 @@ fun TabView(
|
|
|
73
74
|
} else null
|
|
74
75
|
|
|
75
76
|
val coroutineScope = rememberCoroutineScope()
|
|
77
|
+
// The collector below outlives recompositions; read the latest callback, not the first one.
|
|
78
|
+
val currentOnPageSelected by rememberUpdatedState(onPageSelected)
|
|
76
79
|
|
|
77
80
|
// Keep selectedIndex in sync when user swipes the pager
|
|
78
81
|
if (pagerState != null) {
|
|
@@ -80,7 +83,7 @@ fun TabView(
|
|
|
80
83
|
snapshotFlow { pagerState.currentPage }.collect { page ->
|
|
81
84
|
if (!lazyRendered.contains(page)) lazyRendered.add(page)
|
|
82
85
|
selectedIndex = page
|
|
83
|
-
|
|
86
|
+
currentOnPageSelected(page)
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
@@ -362,7 +365,7 @@ private fun CardTabBar(
|
|
|
362
365
|
}
|
|
363
366
|
}
|
|
364
367
|
|
|
365
|
-
val active = tabs
|
|
368
|
+
val active = tabs.getOrNull(selectedIndex) ?: return@BoxWithConstraints
|
|
366
369
|
Row(
|
|
367
370
|
modifier = Modifier
|
|
368
371
|
// Pinned to the strip's BOTTOM edge so the two always end on the same
|
|
@@ -415,7 +418,8 @@ private val CARD_TAB_HEIGHT = 40.dp
|
|
|
415
418
|
private val CARD_TAB_ACTIVE_HEIGHT = 44.dp
|
|
416
419
|
@Composable
|
|
417
420
|
private fun CardTabEar(width: Dp, mirrored: Boolean, color: Color, nudge: Dp) {
|
|
418
|
-
|
|
421
|
+
// Clipped like react-kits' Svg, whose 28-wide path is cut at a 22pt `pathWidth`.
|
|
422
|
+
Canvas(modifier = Modifier.offset(x = nudge).width(width).height(CARD_TAB_ACTIVE_HEIGHT).clipToBounds()) {
|
|
419
423
|
val path = Path().apply {
|
|
420
424
|
moveTo(0f, 0f)
|
|
421
425
|
lineTo(0.60765f, 0f)
|
|
@@ -425,8 +429,12 @@ private fun CardTabEar(width: Dp, mirrored: Boolean, color: Color, nudge: Dp) {
|
|
|
425
429
|
lineTo(0f, 44f)
|
|
426
430
|
close()
|
|
427
431
|
}
|
|
428
|
-
|
|
429
|
-
|
|
432
|
+
// Path coordinates are dp (react-kits viewBox), but DrawScope draws in px.
|
|
433
|
+
val pxPerDp = density
|
|
434
|
+
withTransform({
|
|
435
|
+
if (mirrored) scale(-1f, 1f)
|
|
436
|
+
scale(pxPerDp, pxPerDp, pivot = Offset.Zero)
|
|
437
|
+
}) { drawPath(path = path, color = color) }
|
|
430
438
|
}
|
|
431
439
|
}
|
|
432
440
|
|
|
@@ -30,6 +30,22 @@ enum class TagColor(val backgroundColor: Color, val textColor: Color) {
|
|
|
30
30
|
Grey(Colors.black_04, Colors.black_12),
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// RN only accepts the `_03` palette as a custom tag color.
|
|
34
|
+
private val tagCustomColors = listOf(
|
|
35
|
+
Colors.black_03,
|
|
36
|
+
Colors.pink_03,
|
|
37
|
+
Colors.violet_03,
|
|
38
|
+
Colors.indigo_03,
|
|
39
|
+
Colors.blue_03,
|
|
40
|
+
Colors.mint_03,
|
|
41
|
+
Colors.green_03,
|
|
42
|
+
Colors.lime_03,
|
|
43
|
+
Colors.yellow_03,
|
|
44
|
+
Colors.gold_03,
|
|
45
|
+
Colors.orange_03,
|
|
46
|
+
Colors.red_03,
|
|
47
|
+
)
|
|
48
|
+
|
|
33
49
|
@Composable
|
|
34
50
|
fun Tag(
|
|
35
51
|
label: String = "Label",
|
|
@@ -38,27 +54,9 @@ fun Tag(
|
|
|
38
54
|
size: TagSize = TagSize.Large,
|
|
39
55
|
customColor: Color? = null,
|
|
40
56
|
) {
|
|
41
|
-
val
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Color(0xFF962AF0),
|
|
45
|
-
Color(0xFF4E4BFF),
|
|
46
|
-
Color(0xFF007AFF),
|
|
47
|
-
Color(0xFF13C2C2),
|
|
48
|
-
Color(0xFF34C759),
|
|
49
|
-
Color(0xFFA0D911),
|
|
50
|
-
Color(0xFFFFCC00),
|
|
51
|
-
Color(0xFFFA8C16),
|
|
52
|
-
Color(0xFFFA541C),
|
|
53
|
-
Color(0xFFF5222D)
|
|
54
|
-
)
|
|
55
|
-
var tagColor = color.backgroundColor
|
|
56
|
-
var labelColor = color.textColor
|
|
57
|
-
|
|
58
|
-
if (primaryColors.contains(customColor)) {
|
|
59
|
-
tagColor = color.backgroundColor
|
|
60
|
-
labelColor = color.textColor
|
|
61
|
-
}
|
|
57
|
+
val custom = customColor?.takeIf { it in tagCustomColors }
|
|
58
|
+
val tagColor = custom ?: color.backgroundColor
|
|
59
|
+
val labelColor = if (custom != null) Colors.black_01 else color.textColor
|
|
62
60
|
|
|
63
61
|
Box(
|
|
64
62
|
modifier = Modifier
|
|
@@ -87,8 +87,8 @@ fun Text(
|
|
|
87
87
|
color ?: theme.colors.text.default
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
//
|
|
91
|
-
val optimizedStyle = remember(style) {
|
|
90
|
+
// lineHeight is a key: it is scaled, so it changes with the font scale even when style doesn't.
|
|
91
|
+
val optimizedStyle = remember(style, lineHeight) {
|
|
92
92
|
style.copy(
|
|
93
93
|
fontWeight = null,
|
|
94
94
|
lineHeight = if (lineHeight.value.isFinite() && lineHeight.value > 0) lineHeight else style.lineHeight
|
|
@@ -21,6 +21,7 @@ import androidx.compose.ui.unit.*
|
|
|
21
21
|
import androidx.compose.ui.window.Popup
|
|
22
22
|
import androidx.compose.ui.window.PopupPositionProvider
|
|
23
23
|
import androidx.compose.ui.window.PopupProperties
|
|
24
|
+
import kotlinx.coroutines.flow.drop
|
|
24
25
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
25
26
|
import vn.momo.kits.const.*
|
|
26
27
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
@@ -147,8 +148,10 @@ fun Tooltip(
|
|
|
147
148
|
val density = LocalDensity.current
|
|
148
149
|
val offsetPx = with(density) { (TOOLTIP_OFFSET + ARROW_SIZE).roundToPx() }
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
val currentOnVisibleChange by rememberUpdatedState(onVisibleChange)
|
|
152
|
+
LaunchedEffect(state) {
|
|
153
|
+
// changes only, like RN: the initial value is not reported
|
|
154
|
+
snapshotFlow { state.isVisible }.drop(1).collect { currentOnVisibleChange?.invoke(it) }
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
Box(modifier = modifier) {
|
package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt
CHANGED
|
@@ -128,11 +128,13 @@ fun getHours(hourMode: Int): List<String> {
|
|
|
128
128
|
* Get a list of minutes
|
|
129
129
|
*/
|
|
130
130
|
fun getMinutes(interval: Int): List<String> {
|
|
131
|
+
// A non-positive interval would never reach 60.
|
|
132
|
+
val step = interval.coerceAtLeast(1)
|
|
131
133
|
val minutes = mutableListOf<String>()
|
|
132
134
|
var min = 0
|
|
133
135
|
while (min < 60) {
|
|
134
136
|
minutes.add(paddingNum(min))
|
|
135
|
-
min +=
|
|
137
|
+
min += step
|
|
136
138
|
}
|
|
137
139
|
return minutes
|
|
138
140
|
}
|
|
@@ -154,22 +154,14 @@ internal fun WheelPickerItem(
|
|
|
154
154
|
.fillMaxWidth()
|
|
155
155
|
.height(itemHeight)
|
|
156
156
|
.graphicsLayer {
|
|
157
|
-
|
|
158
|
-
val
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
val absoluteOffset =
|
|
164
|
-
(index - firstVisibleIndex) * itemHeightValue - (visibleItemOffset / itemHeightValue)
|
|
165
|
-
val relativePosition = absoluteOffset / viewportHeight
|
|
166
|
-
|
|
167
|
-
val distance = abs(2 - relativePosition)
|
|
168
|
-
|
|
157
|
+
// Rows away from the centre slot (two below the first visible row); RN fades 1 → 0.8 → 0.4.
|
|
158
|
+
val distance = abs(
|
|
159
|
+
index - listState.firstVisibleItemIndex -
|
|
160
|
+
listState.firstVisibleItemScrollOffset / itemHeight.toPx() - 2
|
|
161
|
+
)
|
|
169
162
|
alpha = when {
|
|
170
|
-
distance <=
|
|
171
|
-
distance <=
|
|
172
|
-
distance <= 3 -> 0.4f
|
|
163
|
+
distance <= 1f -> 1f - 0.2f * distance
|
|
164
|
+
distance <= 2f -> 0.8f - 0.4f * (distance - 1f)
|
|
173
165
|
else -> 0.4f
|
|
174
166
|
}
|
|
175
167
|
},
|
|
@@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable
|
|
|
11
11
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
12
12
|
import androidx.compose.runtime.DisposableEffect
|
|
13
13
|
import androidx.compose.runtime.LaunchedEffect
|
|
14
|
+
import androidx.compose.runtime.remember
|
|
14
15
|
import androidx.compose.ui.Alignment
|
|
15
16
|
import androidx.compose.ui.Modifier
|
|
16
17
|
import androidx.compose.ui.unit.dp
|
|
@@ -54,10 +55,10 @@ fun BottomTab(
|
|
|
54
55
|
val navigator = LocalNavigator.current
|
|
55
56
|
val navController = rememberNavController()
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
// Only on new items: this recomposes on every tab switch and would drop options a tab set at runtime.
|
|
59
|
+
remember(items) {
|
|
60
|
+
bottomTabOptionItems = items.map { it.options ?: NavigationOptions() }.toMutableList()
|
|
61
|
+
}
|
|
61
62
|
|
|
62
63
|
LaunchedEffect(Unit){
|
|
63
64
|
navigation.markAsBottomTabRoot()
|
|
@@ -92,7 +93,12 @@ fun BottomTab(
|
|
|
92
93
|
val onTabSelected: (Int) -> Unit = {
|
|
93
94
|
val targetRoute = "option$it"
|
|
94
95
|
if (currentRoute != targetRoute) {
|
|
95
|
-
|
|
96
|
+
// one entry per tab above the first, so switching never grows the back stack
|
|
97
|
+
navController.navigate(targetRoute) {
|
|
98
|
+
popUpTo("option0") { saveState = true }
|
|
99
|
+
launchSingleTop = true
|
|
100
|
+
restoreState = true
|
|
101
|
+
}
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
|
|
@@ -41,7 +41,7 @@ internal fun BottomTabBar(
|
|
|
41
41
|
onTabSelected: (Int) -> Unit,
|
|
42
42
|
) {
|
|
43
43
|
val currentRoute = navController.currentBackStackEntryAsState().value?.destination?.route
|
|
44
|
-
val selectedIndex = items.
|
|
44
|
+
val selectedIndex = items.indices.firstOrNull { "option$it" == currentRoute } ?: 0
|
|
45
45
|
|
|
46
46
|
val layout = getScreenLayout()
|
|
47
47
|
val mid = items.size / 2
|
|
@@ -179,14 +179,13 @@ internal fun TabBarItem(item: BottomTabItem, selected: Boolean, onClick: () -> U
|
|
|
179
179
|
overflow = TextOverflow.Ellipsis
|
|
180
180
|
)
|
|
181
181
|
}
|
|
182
|
-
if (badgeLabel != null) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
Badge(badgeLabel, modifier = Modifier.offset(x = 44.dp, y = (-42).dp))
|
|
182
|
+
if (badgeLabel != null && badgeLabel.isNotEmpty()) {
|
|
183
|
+
Badge(badgeLabel, modifier = Modifier.offset(x = 44.dp, y = (-42).dp))
|
|
184
|
+
} else if (badgeLabel != null || item.showDot) {
|
|
185
|
+
BadgeDot(
|
|
186
|
+
size = DotSize.Small,
|
|
187
|
+
modifier = Modifier.offset(x = 50.dp, y = (-48).dp)
|
|
188
|
+
)
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
}
|
|
@@ -97,7 +97,8 @@ internal fun parseHeaderTint(value: String?): Color? {
|
|
|
97
97
|
val hex = when (raw.length) {
|
|
98
98
|
3 -> "FF" + raw.map { "$it$it" }.joinToString("")
|
|
99
99
|
6 -> "FF$raw"
|
|
100
|
-
|
|
100
|
+
// CSS #RRGGBBAA, as RN passes it; Compose wants AARRGGBB
|
|
101
|
+
8 -> raw.substring(6) + raw.substring(0, 6)
|
|
101
102
|
else -> return null
|
|
102
103
|
}
|
|
103
104
|
val v = hex.toLongOrNull(16) ?: return null
|
package/gradle.properties
CHANGED
|
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
|
|
|
18
18
|
name="ComposeKits"
|
|
19
19
|
group=vn.momo.kits
|
|
20
20
|
artifact.id=kits
|
|
21
|
-
version=0.167.1-duo-search.
|
|
21
|
+
version=0.167.1-duo-search.2
|
|
22
22
|
|
|
23
23
|
repo=GitLab
|
|
24
24
|
url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
|