@momo-kits/native-kits 0.169.10-beta.1-debug → 0.169.10-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/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +19 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +5 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +5 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +7 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +18 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +6 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +27 -44
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +13 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +7 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +14 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +39 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +35 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +16 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +1 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +1 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +2 -3
- package/gradle.properties +1 -1
- package/ios/Application/DesignSystemKits.swift +2 -3
- package/ios/Application/LanguageSource.swift +2 -3
- package/ios/Application/Localize.swift +4 -7
- package/ios/Application/LocalizeModifier.swift +2 -3
- package/ios/Badge/Badge.swift +5 -7
- package/ios/Button/Button.swift +2 -3
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +3 -5
- package/ios/Carousel/Carousel.swift +2 -3
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Icon/Icon.swift +2 -3
- package/ios/IconButton/IconButton.swift +2 -3
- package/ios/Input/InputSearch.swift +6 -23
- package/ios/Layout/ModalLayout.swift +2 -3
- package/ios/Layout/ScreenLayout.swift +10 -12
- package/ios/Layout/Section.swift +2 -3
- package/ios/Navigation/BottomSheet.swift +6 -9
- package/ios/Navigation/BottomTab/BottomTab.swift +6 -9
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -6
- package/ios/Navigation/BottomTab/CurvedContainer.swift +2 -3
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +6 -6
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -6
- package/ios/Navigation/Component/Header.swift +46 -31
- package/ios/Navigation/Component/HeaderJourney.swift +1 -2
- package/ios/Navigation/Component/HeaderLocation.swift +1 -2
- package/ios/Navigation/Component/HeaderRight.swift +15 -18
- package/ios/Navigation/Component/HeaderUser.swift +1 -2
- package/ios/Navigation/Component/SideBar.swift +15 -7
- package/ios/Navigation/HostBackGestureBridge.swift +2 -3
- package/ios/Navigation/ModalScreen.swift +13 -11
- package/ios/Navigation/Navigation.swift +3 -9
- package/ios/Navigation/NavigationContainer.swift +4 -6
- package/ios/Navigation/Navigator.swift +12 -18
- package/ios/Navigation/StackScreen.swift +25 -40
- package/ios/Navigation/StackTransition.swift +7 -6
- package/ios/Skeleton/Skeleton.swift +3 -6
- package/ios/Steps/Steps.swift +20 -15
- package/ios/TabView/TabView.swift +2 -3
- package/ios/Title/Title.swift +1 -3
- package/ios/Typography/FontScale.swift +6 -9
- package/ios/Typography/Text.swift +2 -3
- package/ios/Typography/Typography.swift +3 -4
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -67
- package/ios/Layout/HeaderLayout.swift +0 -67
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -36,9 +36,8 @@ object DesignSystemKits {
|
|
|
36
36
|
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
|
37
37
|
private var observeJob: Job? = null
|
|
38
38
|
|
|
39
|
-
// Snapshot state
|
|
40
|
-
//
|
|
41
|
-
// global snapshot apply loop may never have started.
|
|
39
|
+
// Snapshot state recomposes Compose readers; the StateFlow serves non-Compose observers (the host
|
|
40
|
+
// SwiftUI bridge), where Compose's global snapshot apply loop may never have started.
|
|
42
41
|
private var currentConfigs by mutableStateOf(DesignSystemKitsConfigs())
|
|
43
42
|
private val mutableConfigsFlow = MutableStateFlow(currentConfigs)
|
|
44
43
|
val configsFlow: StateFlow<DesignSystemKitsConfigs> = mutableConfigsFlow.asStateFlow()
|
|
@@ -512,11 +512,13 @@ private class StandardPhoneLiteScreenGeometry : LiteScreenGeometry {
|
|
|
512
512
|
insetRight: Int,
|
|
513
513
|
) = (width - insetLeft - insetRight).coerceAtLeast(0)
|
|
514
514
|
|
|
515
|
-
override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int)
|
|
516
|
-
insetLeft + spacing
|
|
515
|
+
override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int): Int {
|
|
516
|
+
return insetLeft + spacing
|
|
517
|
+
}
|
|
517
518
|
|
|
518
|
-
override fun MeasureScope.headerHeight(screenLayout: ScreenLayout, statusBar: Int, rowHeight: Int)
|
|
519
|
-
statusBar + rowHeight
|
|
519
|
+
override fun MeasureScope.headerHeight(screenLayout: ScreenLayout, statusBar: Int, rowHeight: Int): Int {
|
|
520
|
+
return statusBar + rowHeight
|
|
521
|
+
}
|
|
520
522
|
override fun MeasureScope.collapsedHeaderHeight(
|
|
521
523
|
screenLayout: ScreenLayout,
|
|
522
524
|
statusBar: Int,
|
|
@@ -553,8 +555,9 @@ private class IPhoneDuoLiteScreenGeometry : LiteScreenGeometry {
|
|
|
553
555
|
).coerceAtLeast(0)
|
|
554
556
|
}
|
|
555
557
|
|
|
556
|
-
override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int)
|
|
557
|
-
insetLeft + (screenLayout.statusBarClearance?.left?.roundToPx() ?: 0) + spacing
|
|
558
|
+
override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int): Int {
|
|
559
|
+
return insetLeft + (screenLayout.statusBarClearance?.left?.roundToPx() ?: 0) + spacing
|
|
560
|
+
}
|
|
558
561
|
|
|
559
562
|
override fun MeasureScope.headerHeight(screenLayout: ScreenLayout, statusBar: Int, rowHeight: Int): Int {
|
|
560
563
|
val rowTop = screenLayout.headerStatusBarHeight +
|
|
@@ -642,19 +645,17 @@ private class LiteScreenLayoutPolicy(
|
|
|
642
645
|
minHeight = 0,
|
|
643
646
|
maxWidth = (safeLayoutWidth - spacing12 * 2).coerceAtLeast(0),
|
|
644
647
|
)
|
|
645
|
-
val backIconPlaceable =
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
realConstraints.copy(
|
|
650
|
-
maxWidth = realConstraints.maxWidth / 2,
|
|
651
|
-
)
|
|
652
|
-
)
|
|
648
|
+
val backIconPlaceable = measurables.find { it.layoutId == HeaderId.BACK_ID }?.measure(realConstraints)
|
|
649
|
+
val headerRightPlaceable = measurables.find { it.layoutId == HeaderId.HEADER_RIGHT_ID }?.measure(
|
|
650
|
+
realConstraints.copy(maxWidth = realConstraints.maxWidth / 2)
|
|
651
|
+
)
|
|
653
652
|
val headerBackWidth = if (screenLayout.sideBar == null) backIconPlaceable.safeWidth else 0
|
|
654
653
|
val baseInputSearchConstraints = if (isHeaderExtend) {
|
|
655
|
-
val minWidth =
|
|
656
|
-
|
|
657
|
-
|
|
654
|
+
val minWidth = if (useAnimationSearch) {
|
|
655
|
+
realConstraints.maxWidth - headerBackWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
|
|
656
|
+
} else {
|
|
657
|
+
realConstraints.maxWidth
|
|
658
|
+
}
|
|
658
659
|
realConstraints.copy(
|
|
659
660
|
maxWidth = (realConstraints.maxWidth * (1 - scrollPercent)).toInt()
|
|
660
661
|
.coerceAtLeast(minWidth)
|
|
@@ -941,8 +942,7 @@ private fun LiteInputSearch(
|
|
|
941
942
|
val interactionSource = remember { MutableInteractionSource() }
|
|
942
943
|
val textState by remember { inputSearchProps.textFieldState }
|
|
943
944
|
|
|
944
|
-
val isShowBtnText = inputSearchProps.isShowBtnText &&
|
|
945
|
-
!inputSearchProps.btnText.isNullOrEmpty()
|
|
945
|
+
val isShowBtnText = inputSearchProps.isShowBtnText && !inputSearchProps.btnText.isNullOrEmpty()
|
|
946
946
|
val inputFieldFontFamily = getFontFamily(theme.font, Typography.bodyDefaultRegular.fontWeight)
|
|
947
947
|
val inputFieldStyle = remember(theme, inputFieldFontFamily) {
|
|
948
948
|
Typography.bodyDefaultRegular.copy(
|
|
@@ -36,10 +36,11 @@ class Localize(translations: LocalizationObject = LocalizationObject()) {
|
|
|
36
36
|
return dictionary[key]?.takeIf { it.isNotEmpty() } ?: key
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
fun translateData(data: Map<String, String>): String
|
|
40
|
-
data[language] ?: data.entries.joinToString(prefix = "{", postfix = "}") {
|
|
39
|
+
fun translateData(data: Map<String, String>): String {
|
|
40
|
+
return data[language] ?: data.entries.joinToString(prefix = "{", postfix = "}") {
|
|
41
41
|
"\"${it.key}\":\"${it.value}\""
|
|
42
42
|
}
|
|
43
|
+
}
|
|
43
44
|
|
|
44
45
|
fun translateData(vi: String, en: String): String = if (language == EN) en else vi
|
|
45
46
|
|
|
@@ -47,12 +47,11 @@ fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Mod
|
|
|
47
47
|
return label
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
var badgeColor =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
50
|
+
var badgeColor = if (isNumber(label)) {
|
|
51
|
+
AppTheme.current.colors.error.primary
|
|
52
|
+
} else {
|
|
53
|
+
AppTheme.current.colors.warning.primary
|
|
54
|
+
}
|
|
56
55
|
|
|
57
56
|
if (backgroundColor != null && badgePrimaryColors.contains(backgroundColor)) {
|
|
58
57
|
badgeColor = backgroundColor
|
|
@@ -244,8 +244,7 @@ fun getButtonBackgroundColor(
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
private fun Color.withLoading(loading: Boolean): Color =
|
|
248
|
-
this.copy(alpha = if (loading) 0.75f else 1f)
|
|
247
|
+
private fun Color.withLoading(loading: Boolean): Color = this.copy(alpha = if (loading) 0.75f else 1f)
|
|
249
248
|
|
|
250
249
|
@Composable
|
|
251
250
|
fun Button(
|
|
@@ -284,21 +283,20 @@ fun Button(
|
|
|
284
283
|
label = "buttonPressAlpha"
|
|
285
284
|
)
|
|
286
285
|
|
|
287
|
-
val clickableModifier =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
286
|
+
val clickableModifier = if (isEnabled && !loading) {
|
|
287
|
+
modifier
|
|
288
|
+
.clip(RoundedCornerShape(radius))
|
|
289
|
+
.clickable(
|
|
290
|
+
enabled = isEnabled && !loading,
|
|
291
|
+
interactionSource = interactionSource,
|
|
292
|
+
indication = null,
|
|
293
|
+
onClick = onClick
|
|
294
|
+
)
|
|
295
|
+
.alpha(alpha)
|
|
296
|
+
} else {
|
|
297
|
+
modifier
|
|
298
|
+
.clip(RoundedCornerShape(radius))
|
|
299
|
+
}
|
|
302
300
|
|
|
303
301
|
val bgColor = getButtonBackgroundColor(loading, type)
|
|
304
302
|
val textColor = getTextColor(loading, type)
|
|
@@ -49,8 +49,10 @@ fun Chip(
|
|
|
49
49
|
ChipSize.LARGE -> ChipDefaults.Large
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
val
|
|
53
|
-
|
|
52
|
+
val height = scaleSize(dims.height)
|
|
53
|
+
val horizontal = scaleSize(dims.horizontal)
|
|
54
|
+
val iconSize = scaleSize(dims.iconSize)
|
|
55
|
+
val iconSpacing = scaleSize(dims.iconSpacing)
|
|
54
56
|
|
|
55
57
|
val radius = scaleSize(Radius.L)
|
|
56
58
|
|
|
@@ -9,20 +9,13 @@ import androidx.compose.runtime.Composable
|
|
|
9
9
|
import androidx.compose.runtime.remember
|
|
10
10
|
import androidx.compose.ui.Modifier
|
|
11
11
|
import androidx.compose.ui.draw.clip
|
|
12
|
-
import androidx.compose.ui.text.AnnotatedString
|
|
13
|
-
import androidx.compose.ui.text.SpanStyle
|
|
14
|
-
import androidx.compose.ui.text.buildAnnotatedString
|
|
15
|
-
import androidx.compose.ui.text.font.FontSynthesis
|
|
16
12
|
import androidx.compose.ui.text.style.TextAlign
|
|
17
|
-
import androidx.compose.ui.text.withStyle
|
|
18
13
|
import androidx.compose.ui.unit.dp
|
|
19
14
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
20
|
-
import vn.momo.kits.const.AppTheme
|
|
21
15
|
import vn.momo.kits.const.Colors
|
|
22
16
|
import vn.momo.kits.const.Radius
|
|
23
17
|
import vn.momo.kits.const.Spacing
|
|
24
18
|
import vn.momo.kits.const.Typography
|
|
25
|
-
import vn.momo.kits.const.getFontFamily
|
|
26
19
|
import vn.momo.kits.modifier.conditional
|
|
27
20
|
import vn.momo.kits.modifier.setAutomationId
|
|
28
21
|
|
|
@@ -69,7 +62,7 @@ fun Information(
|
|
|
69
62
|
iconSource = "24_notifications_alert_octagon"
|
|
70
63
|
}
|
|
71
64
|
|
|
72
|
-
val annotatedDescription =
|
|
65
|
+
val annotatedDescription = rememberHighlightedText(description, highlightText)
|
|
73
66
|
|
|
74
67
|
Column(
|
|
75
68
|
modifier = Modifier.border(
|
|
@@ -142,54 +135,3 @@ fun Information(
|
|
|
142
135
|
}
|
|
143
136
|
|
|
144
137
|
}
|
|
145
|
-
|
|
146
|
-
// Highlighted keywords keep the caller's text size; only the weight changes.
|
|
147
|
-
@Composable
|
|
148
|
-
internal fun rememberHighlightDescription(description: String, highlightText: List<String>): AnnotatedString {
|
|
149
|
-
// Host fonts are one file per weight: swap fontFamily and disable synthesis so the SemiBold file isn't
|
|
150
|
-
// faux-bolded again; fontWeight still applies when no host font is bundled and the system font is used.
|
|
151
|
-
val highlightWeight = Typography.headerXsSemibold.fontWeight
|
|
152
|
-
val highlightFontFamily = getFontFamily(AppTheme.current.font, highlightWeight)
|
|
153
|
-
return remember(description, highlightText, highlightFontFamily) {
|
|
154
|
-
highlightDescription(
|
|
155
|
-
description,
|
|
156
|
-
highlightText,
|
|
157
|
-
SpanStyle(
|
|
158
|
-
fontFamily = highlightFontFamily,
|
|
159
|
-
fontWeight = highlightWeight,
|
|
160
|
-
fontSynthesis = FontSynthesis.None,
|
|
161
|
-
),
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Whole-word matches only; the longest keyword wins when keywords overlap (RN parity).
|
|
167
|
-
private fun highlightDescription(
|
|
168
|
-
description: String,
|
|
169
|
-
highlightText: List<String>,
|
|
170
|
-
style: SpanStyle,
|
|
171
|
-
): AnnotatedString {
|
|
172
|
-
val keywords = highlightText.filter { it.isNotEmpty() }
|
|
173
|
-
if (keywords.isEmpty()) return AnnotatedString(description)
|
|
174
|
-
val regex = Regex(keywords.sortedByDescending { it.length }.joinToString("|") { Regex.escape(it) })
|
|
175
|
-
fun isWordChar(index: Int) = description.getOrNull(index)?.let { it.isLetterOrDigit() || it == '_' } == true
|
|
176
|
-
|
|
177
|
-
return buildAnnotatedString {
|
|
178
|
-
var lastIndex = 0
|
|
179
|
-
var searchFrom = 0
|
|
180
|
-
while (true) {
|
|
181
|
-
val match = regex.find(description, searchFrom) ?: break
|
|
182
|
-
val start = match.range.first
|
|
183
|
-
val end = match.range.last + 1
|
|
184
|
-
if (isWordChar(start - 1) || isWordChar(end)) {
|
|
185
|
-
searchFrom = start + 1
|
|
186
|
-
continue
|
|
187
|
-
}
|
|
188
|
-
append(description.substring(lastIndex, start))
|
|
189
|
-
withStyle(style) { append(match.value) }
|
|
190
|
-
lastIndex = end
|
|
191
|
-
searchFrom = end
|
|
192
|
-
}
|
|
193
|
-
append(description.substring(lastIndex))
|
|
194
|
-
}
|
|
195
|
-
}
|
|
@@ -44,8 +44,8 @@ fun InputDropDown(
|
|
|
44
44
|
) {
|
|
45
45
|
val isFocused by remember { mutableStateOf(false) }
|
|
46
46
|
|
|
47
|
-
val (
|
|
48
|
-
|
|
47
|
+
val colors = getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
|
|
48
|
+
val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) = colors
|
|
49
49
|
|
|
50
50
|
val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
|
|
51
51
|
|
|
@@ -58,8 +58,10 @@ private fun normalizeDigits(text: String) = digitsOf(text).let { digits ->
|
|
|
58
58
|
digits.trimStart('0').ifEmpty { digits.take(1) }
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
private fun moneyDisplay(digits: String)
|
|
62
|
-
if (digits.isEmpty())
|
|
61
|
+
private fun moneyDisplay(digits: String): String {
|
|
62
|
+
if (digits.isEmpty()) return ""
|
|
63
|
+
return digits.reversed().chunked(3).joinToString(".").reversed() + MONEY_CURRENCY
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
// Caret position right after the `digitIndex`-th digit of `display`.
|
|
65
67
|
private fun caretFromDigitIndex(display: String, digitIndex: Int): Int {
|
|
@@ -78,19 +80,16 @@ private fun detectEdit(old: String, next: String, caret: Int): MoneyEdit {
|
|
|
78
80
|
while (prefix < minOf(caret, old.length - tail) && old[prefix] == next[prefix]) prefix++
|
|
79
81
|
return MoneyEdit(prefix, old.length - tail, next.substring(prefix, caret))
|
|
80
82
|
}
|
|
83
|
+
val minLength = minOf(old.length, next.length)
|
|
81
84
|
var prefix = 0
|
|
82
|
-
while (prefix <
|
|
85
|
+
while (prefix < minLength && old[prefix] == next[prefix]) prefix++
|
|
83
86
|
var suffix = 0
|
|
84
|
-
while (suffix <
|
|
85
|
-
old[old.length - 1 - suffix] == next[next.length - 1 - suffix]
|
|
86
|
-
) suffix++
|
|
87
|
+
while (suffix < minLength - prefix && old[old.length - 1 - suffix] == next[next.length - 1 - suffix]) suffix++
|
|
87
88
|
return MoneyEdit(prefix, old.length - suffix, next.substring(prefix, next.length - suffix))
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
// only the currency leaves the digits untouched.
|
|
93
|
-
// Returns the new digits and the caret as a digit index.
|
|
91
|
+
// Separators and currency are never deleted: removing a separator removes the digit before it, removing
|
|
92
|
+
// only the currency is a no-op. Returns the new digits and the caret as a digit index.
|
|
94
93
|
private fun applyEdit(display: String, edit: MoneyEdit): Pair<String, Int> {
|
|
95
94
|
val digits = digitsOf(display)
|
|
96
95
|
var left = digitsOf(display.substring(0, edit.start)).length
|
|
@@ -137,8 +136,8 @@ fun InputMoney(
|
|
|
137
136
|
val current = if (digitsOf(field.text) == digits) field else moneyDisplay(digits).let {
|
|
138
137
|
TextFieldValue(it, TextRange(caretFromDigitIndex(it, digits.length)))
|
|
139
138
|
}
|
|
140
|
-
val (
|
|
141
|
-
|
|
139
|
+
val colors = getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
|
|
140
|
+
val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) = colors
|
|
142
141
|
|
|
143
142
|
val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
|
|
144
143
|
|
|
@@ -103,10 +103,9 @@ fun InputOTP(
|
|
|
103
103
|
var isFocused by remember { mutableStateOf(false) }
|
|
104
104
|
|
|
105
105
|
val handleChangeText: (String) -> Unit = { text ->
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
) {
|
|
106
|
+
val fitsLength = text.length <= maxLength
|
|
107
|
+
val matchesType = dataType != "number" || text.all { it.isDigit() }
|
|
108
|
+
if (fitsLength && matchesType && text.length != value.length) {
|
|
110
109
|
onChangeText(text)
|
|
111
110
|
}
|
|
112
111
|
}
|
|
@@ -178,12 +177,15 @@ fun InputOTP(
|
|
|
178
177
|
if (isFocused && value.length == i) {
|
|
179
178
|
OTPCaret()
|
|
180
179
|
} else {
|
|
181
|
-
val
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
val digit = value.getOrNull(i)
|
|
181
|
+
var textColor = AppTheme.current.colors.text.hint
|
|
182
|
+
var typo = Typography.descriptionDefaultRegular
|
|
183
|
+
if (digit != null) {
|
|
184
|
+
textColor = AppTheme.current.colors.text.default
|
|
185
|
+
typo = Typography.headerDefaultBold
|
|
186
|
+
}
|
|
185
187
|
Text(
|
|
186
|
-
text =
|
|
188
|
+
text = digit?.toString() ?: "-",
|
|
187
189
|
color = textColor,
|
|
188
190
|
style = typo
|
|
189
191
|
)
|
|
@@ -45,25 +45,16 @@ import vn.momo.kits.application.IsShowBaseLineDebug
|
|
|
45
45
|
import vn.momo.kits.const.Typography
|
|
46
46
|
import vn.momo.kits.const.getFontFamily
|
|
47
47
|
import vn.momo.kits.const.scaleSize
|
|
48
|
-
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
49
|
-
import vn.momo.kits.layout.HEADER_SEARCH_HEIGHT
|
|
50
48
|
import vn.momo.kits.modifier.conditional
|
|
51
49
|
import vn.momo.kits.utils.ifTrue
|
|
52
50
|
|
|
53
|
-
// Body searches keep 36 / 24; the header search matches the 32pt header buttons.
|
|
54
|
-
internal enum class InputSearchSize(val height: Dp, val iconSize: Dp) {
|
|
55
|
-
Default(36.dp, 24.dp),
|
|
56
|
-
Header(HEADER_SEARCH_HEIGHT, HEADER_ICON_SIZE),
|
|
57
|
-
}
|
|
58
|
-
|
|
59
51
|
@Composable
|
|
60
52
|
internal fun RenderRightIconSearch(
|
|
61
53
|
loading: Boolean,
|
|
62
54
|
icon: String,
|
|
63
55
|
color: Color?,
|
|
64
56
|
onClick: () -> Unit,
|
|
65
|
-
iconModifier: Modifier = Modifier
|
|
66
|
-
iconSize: Dp = InputSearchSize.Default.iconSize,
|
|
57
|
+
iconModifier: Modifier = Modifier
|
|
67
58
|
) {
|
|
68
59
|
if (loading) {
|
|
69
60
|
Box(Modifier.padding(horizontal = Spacing.S)) {
|
|
@@ -83,7 +74,7 @@ internal fun RenderRightIconSearch(
|
|
|
83
74
|
Icon(
|
|
84
75
|
source = icon,
|
|
85
76
|
color = color,
|
|
86
|
-
size =
|
|
77
|
+
size = 24.dp,
|
|
87
78
|
modifier = iconModifier.padding(start = Spacing.S, end = 0.dp).clickable(
|
|
88
79
|
onClick = onClick,
|
|
89
80
|
interactionSource = remember { MutableInteractionSource() },
|
|
@@ -128,11 +119,6 @@ fun InputSearch(
|
|
|
128
119
|
text = remember { mutableStateOf("") },
|
|
129
120
|
),
|
|
130
121
|
) {
|
|
131
|
-
InputSearch(inputSearchProps, InputSearchSize.Default)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
@Composable
|
|
135
|
-
internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSize) {
|
|
136
122
|
var isFocused by remember { mutableStateOf(false) }
|
|
137
123
|
val disabledColor = AppTheme.current.colors.text.disable
|
|
138
124
|
var textColor = AppTheme.current.colors.text.default
|
|
@@ -170,7 +156,7 @@ internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSi
|
|
|
170
156
|
Row(
|
|
171
157
|
verticalAlignment = Alignment.CenterVertically, modifier = Modifier
|
|
172
158
|
.fillMaxWidth()
|
|
173
|
-
.height(
|
|
159
|
+
.height(36.dp)
|
|
174
160
|
.conditional(IsShowBaseLineDebug) {
|
|
175
161
|
border(1.dp, Colors.blue_03)
|
|
176
162
|
}
|
|
@@ -217,7 +203,7 @@ internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSi
|
|
|
217
203
|
inputSearchProps.searchIcon?.invoke() ?: Icon(
|
|
218
204
|
source = "navigation_search",
|
|
219
205
|
modifier = Modifier.padding(end = Spacing.XS),
|
|
220
|
-
size =
|
|
206
|
+
size = 24.dp,
|
|
221
207
|
color = AppTheme.current.colors.text.hint
|
|
222
208
|
)
|
|
223
209
|
Box(Modifier.weight(1f)) {
|
|
@@ -256,8 +242,7 @@ internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSi
|
|
|
256
242
|
inputSearchProps.icon,
|
|
257
243
|
iconTintColor,
|
|
258
244
|
inputSearchProps.onRightIconPressed,
|
|
259
|
-
iconModifier = inputSearchProps.iconModifier
|
|
260
|
-
iconSize = size.iconSize,
|
|
245
|
+
iconModifier = inputSearchProps.iconModifier
|
|
261
246
|
)
|
|
262
247
|
}
|
|
263
248
|
}
|
|
@@ -57,8 +57,8 @@ fun InputTextArea(
|
|
|
57
57
|
keyboardType: KeyboardType = KeyboardType.Text,
|
|
58
58
|
) {
|
|
59
59
|
var isFocused by remember { mutableStateOf(false) }
|
|
60
|
-
val (
|
|
61
|
-
|
|
60
|
+
val colors = getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
|
|
61
|
+
val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) = colors
|
|
62
62
|
|
|
63
63
|
val fontSize = 16.sp
|
|
64
64
|
val lineHeight = 24.sp
|
|
@@ -98,16 +98,15 @@ fun LazyColumnWithBouncing(
|
|
|
98
98
|
}.collect()
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
val measureLayout =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
p.place(IntOffset.Zero)
|
|
108
|
-
}
|
|
101
|
+
val measureLayout = remember<MeasureScope.(Measurable, Constraints) -> MeasureResult>(maxConstraint) {
|
|
102
|
+
{ m, c ->
|
|
103
|
+
val p = m.measure(c.copy(minHeight = 0))
|
|
104
|
+
maxConstraint.value = c.maxHeight
|
|
105
|
+
layout(p.width, p.height) {
|
|
106
|
+
p.place(IntOffset.Zero)
|
|
109
107
|
}
|
|
110
108
|
}
|
|
109
|
+
}
|
|
111
110
|
|
|
112
111
|
if (getPlatformName() == "iOS") {
|
|
113
112
|
|
|
@@ -45,8 +45,7 @@ internal fun popupMaxWidth(): Dp {
|
|
|
45
45
|
|
|
46
46
|
// The placement already keeps foldable popups off the edges, so their own side padding goes.
|
|
47
47
|
@Composable
|
|
48
|
-
internal fun popupHorizontalPadding(padding: Dp): Dp =
|
|
49
|
-
if (rememberModalLayout().isFoldable) 0.dp else padding
|
|
48
|
+
internal fun popupHorizontalPadding(padding: Dp): Dp = if (rememberModalLayout().isFoldable) 0.dp else padding
|
|
50
49
|
|
|
51
50
|
// Tallest a popup gets on foldables; null on phones.
|
|
52
51
|
@Composable
|
|
@@ -99,7 +98,7 @@ fun PopupNotify(
|
|
|
99
98
|
|
|
100
99
|
val density = LocalDensity.current
|
|
101
100
|
var scrollHeight: Dp by remember { mutableStateOf(0.dp) }
|
|
102
|
-
val description =
|
|
101
|
+
val description = rememberHighlightedText(props.description, props.highlightText)
|
|
103
102
|
|
|
104
103
|
LaunchedEffect(layoutResult.value) {
|
|
105
104
|
if ((layoutResult.value?.lineCount ?: 0) > 3) {
|
|
@@ -103,15 +103,12 @@ private fun ProgressInfoHorizontal(
|
|
|
103
103
|
ProgressInfoAlign.Center -> TextAlign.Center
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
val
|
|
107
|
-
|
|
108
|
-
align != ProgressInfoAlign.Stretch
|
|
109
|
-
) Spacing.XS else 0.dp
|
|
106
|
+
val isSideAligned = align != ProgressInfoAlign.Center && align != ProgressInfoAlign.Stretch
|
|
107
|
+
val endPadding = if (!isLast && isSideAligned) Spacing.XS else 0.dp
|
|
110
108
|
|
|
111
|
-
val
|
|
112
|
-
|
|
113
|
-
val hideLineRight = align == ProgressInfoAlign.Right ||
|
|
114
|
-
(align == ProgressInfoAlign.Stretch && isLast)
|
|
109
|
+
val isStretch = align == ProgressInfoAlign.Stretch
|
|
110
|
+
val hideLineLeft = align == ProgressInfoAlign.Left || (isStretch && isFirst)
|
|
111
|
+
val hideLineRight = align == ProgressInfoAlign.Right || (isStretch && isLast)
|
|
115
112
|
|
|
116
113
|
Column(
|
|
117
114
|
modifier = Modifier
|
|
@@ -31,8 +31,7 @@ private val LABEL_PAD_V = Spacing.XXS
|
|
|
31
31
|
private val LABEL_GAP = Spacing.XS // space between label and thumb top
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
private fun clamp(value: Float, min: Float, max: Float): Float =
|
|
35
|
-
min(kotlin.math.max(value, min), max)
|
|
34
|
+
private fun clamp(value: Float, min: Float, max: Float): Float = min(kotlin.math.max(value, min), max)
|
|
36
35
|
|
|
37
36
|
private fun getValueForPosition(
|
|
38
37
|
positionInView: Float,
|
|
@@ -65,9 +64,12 @@ private fun valueToFraction(value: Float, min: Float, max: Float): Float {
|
|
|
65
64
|
return clamp((value - min) / (max - min), 0f, 1f)
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
private fun formatLabel(value: Float): String
|
|
69
|
-
if (value == value.toLong().toFloat())
|
|
70
|
-
|
|
67
|
+
private fun formatLabel(value: Float): String {
|
|
68
|
+
if (value == value.toLong().toFloat()) {
|
|
69
|
+
return value.toLong().toString()
|
|
70
|
+
}
|
|
71
|
+
return ((value * 10).toLong() / 10.0).toString()
|
|
72
|
+
}
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
75
|
* Range slider ported from RN; [disableRange] keeps only the low thumb.
|
|
@@ -63,8 +63,7 @@ private fun StepperButton(
|
|
|
63
63
|
val specs = remember(size) { stepperSizeSpecs[size] ?: stepperSizeSpecs[StepperSize.LARGE]!! }
|
|
64
64
|
|
|
65
65
|
val iconColor: Color = if (disabled) theme.colors.text.disable else theme.colors.primary
|
|
66
|
-
val iconName: String =
|
|
67
|
-
if (sign == "-") "24_navigation_minus_circle" else "24_navigation_plus_circle"
|
|
66
|
+
val iconName: String = if (sign == "-") "24_navigation_minus_circle" else "24_navigation_plus_circle"
|
|
68
67
|
|
|
69
68
|
val clickableModifier: Modifier = if (!disabled) {
|
|
70
69
|
Modifier.activeOpacityClickable(onClick = onPress)
|
|
@@ -101,8 +100,7 @@ private fun StepperNumberView(
|
|
|
101
100
|
val specs = remember(size) { stepperSizeSpecs[size] ?: stepperSizeSpecs[StepperSize.LARGE]!! }
|
|
102
101
|
|
|
103
102
|
val textColor: Color = if (disabled) theme.colors.text.disable else theme.colors.text.default
|
|
104
|
-
val borderColor: Color =
|
|
105
|
-
if (disabled) theme.colors.border.disable else theme.colors.border.default
|
|
103
|
+
val borderColor: Color = if (disabled) theme.colors.border.disable else theme.colors.border.default
|
|
106
104
|
|
|
107
105
|
val scaledFontSize = scaleSize(12.sp)
|
|
108
106
|
|
|
@@ -186,10 +186,9 @@ private fun StepsHorizontal(
|
|
|
186
186
|
StepsAlign.CENTER -> TextAlign.Center
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
val
|
|
190
|
-
|
|
191
|
-
val hideLineRight = align == StepsAlign.RIGHT ||
|
|
192
|
-
(align == StepsAlign.STRETCH && index == steps.size - 1)
|
|
189
|
+
val isStretch = align == StepsAlign.STRETCH
|
|
190
|
+
val hideLineLeft = align == StepsAlign.LEFT || (isStretch && index == 0)
|
|
191
|
+
val hideLineRight = align == StepsAlign.RIGHT || (isStretch && index == steps.size - 1)
|
|
193
192
|
|
|
194
193
|
val lineLeft = when {
|
|
195
194
|
index == 0 -> Color.Transparent
|