@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.
Files changed (96) hide show
  1. package/compose/build.gradle.kts +1 -1
  2. package/compose/compose.podspec +1 -1
  3. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +19 -19
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +3 -2
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +5 -6
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -17
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -59
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -2
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +5 -20
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +2 -2
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +2 -3
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +5 -8
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +7 -5
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +3 -4
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +18 -20
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +1 -2
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +6 -7
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +2 -7
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +3 -2
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +2 -3
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +27 -44
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +1 -3
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +13 -10
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +7 -6
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +14 -13
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +39 -29
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +35 -32
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +16 -9
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +3 -4
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +1 -2
  42. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
  43. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +1 -2
  44. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +2 -3
  45. package/gradle.properties +1 -1
  46. package/ios/Application/DesignSystemKits.swift +2 -3
  47. package/ios/Application/LanguageSource.swift +2 -3
  48. package/ios/Application/Localize.swift +4 -7
  49. package/ios/Application/LocalizeModifier.swift +2 -3
  50. package/ios/Badge/Badge.swift +5 -7
  51. package/ios/Button/Button.swift +2 -3
  52. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +3 -5
  53. package/ios/Carousel/Carousel.swift +2 -3
  54. package/ios/Collapse/Collapse.swift +17 -11
  55. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  56. package/ios/Icon/Icon.swift +2 -3
  57. package/ios/IconButton/IconButton.swift +2 -3
  58. package/ios/Input/InputSearch.swift +6 -23
  59. package/ios/Layout/ModalLayout.swift +2 -3
  60. package/ios/Layout/ScreenLayout.swift +10 -12
  61. package/ios/Layout/Section.swift +2 -3
  62. package/ios/Navigation/BottomSheet.swift +6 -9
  63. package/ios/Navigation/BottomTab/BottomTab.swift +6 -9
  64. package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -6
  65. package/ios/Navigation/BottomTab/CurvedContainer.swift +2 -3
  66. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  67. package/ios/Navigation/BottomTab/DuoTabBar.swift +6 -6
  68. package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -6
  69. package/ios/Navigation/Component/Header.swift +46 -31
  70. package/ios/Navigation/Component/HeaderJourney.swift +1 -2
  71. package/ios/Navigation/Component/HeaderLocation.swift +1 -2
  72. package/ios/Navigation/Component/HeaderRight.swift +15 -18
  73. package/ios/Navigation/Component/HeaderUser.swift +1 -2
  74. package/ios/Navigation/Component/SideBar.swift +15 -7
  75. package/ios/Navigation/HostBackGestureBridge.swift +2 -3
  76. package/ios/Navigation/ModalScreen.swift +13 -11
  77. package/ios/Navigation/Navigation.swift +3 -9
  78. package/ios/Navigation/NavigationContainer.swift +4 -6
  79. package/ios/Navigation/Navigator.swift +12 -18
  80. package/ios/Navigation/StackScreen.swift +25 -40
  81. package/ios/Navigation/StackTransition.swift +7 -6
  82. package/ios/Skeleton/Skeleton.swift +3 -6
  83. package/ios/Steps/Steps.swift +20 -15
  84. package/ios/TabView/TabView.swift +2 -3
  85. package/ios/Title/Title.swift +1 -3
  86. package/ios/Typography/FontScale.swift +6 -9
  87. package/ios/Typography/Text.swift +2 -3
  88. package/ios/Typography/Typography.swift +3 -4
  89. package/ios/native-kits.podspec +1 -1
  90. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  91. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
  92. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
  93. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
  94. package/package.json +1 -1
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -67
  96. package/ios/Layout/HeaderLayout.swift +0 -67
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.169.10-beta.1-debug"
43
+ version = "0.169.10-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.169.10-beta.1-debug'
3
+ spec.version = '0.169.10-debug'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -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 so Compose readers recompose (including non-composable getters like defaultTheme);
40
- // the StateFlow is for non-Compose observers, e.g. the host's SwiftUI bridge, where Compose's
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
- measurables.find { it.layoutId == HeaderId.BACK_ID }?.measure(realConstraints)
647
- val headerRightPlaceable =
648
- measurables.find { it.layoutId == HeaderId.HEADER_RIGHT_ID }?.measure(
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
- if (useAnimationSearch) realConstraints.maxWidth - headerBackWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
657
- else realConstraints.maxWidth
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
- if (isNumber(label)) {
52
- AppTheme.current.colors.error.primary
53
- } else {
54
- AppTheme.current.colors.warning.primary
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
- if (isEnabled && !loading) {
289
- modifier
290
- .clip(RoundedCornerShape(radius))
291
- .clickable(
292
- enabled = isEnabled && !loading,
293
- interactionSource = interactionSource,
294
- indication = null,
295
- onClick = onClick
296
- )
297
- .alpha(alpha)
298
- } else {
299
- modifier
300
- .clip(RoundedCornerShape(radius))
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 (height, horizontal, iconSize, iconSpacing) =
53
- listOf(scaleSize(dims.height), scaleSize(dims.horizontal), scaleSize(dims.iconSize), scaleSize(dims.iconSpacing))
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 = rememberHighlightDescription(description, highlightText)
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 (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) =
48
- getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
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()) "" else digits.reversed().chunked(3).joinToString(".").reversed() + MONEY_CURRENCY
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 < minOf(old.length, next.length) && old[prefix] == next[prefix]) prefix++
85
+ while (prefix < minLength && old[prefix] == next[prefix]) prefix++
83
86
  var suffix = 0
84
- while (suffix < minOf(old.length, next.length) - prefix &&
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
- // Applies `edit` to the digits of `display`. Separators and currency are never
91
- // deleted: removing a separator deletes the digit before it instead, removing
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 (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) =
141
- getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
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
- if (text.length <= maxLength &&
107
- (dataType != "number" || !text.any { !it.isDigit() }) &&
108
- (text.length < value.length || value.length < text.length)
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 textColor =
182
- if (value.getOrNull(i) != null) AppTheme.current.colors.text.default else AppTheme.current.colors.text.hint
183
- val typo =
184
- if (value.getOrNull(i) != null) Typography.headerDefaultBold else Typography.descriptionDefaultRegular
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 = value.getOrNull(i)?.toString() ?: "-",
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 = iconSize,
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(size.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 = size.iconSize,
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 (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) =
61
- getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
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
- remember<MeasureScope.(Measurable, Constraints) -> MeasureResult>(maxConstraint) {
103
- { m, c ->
104
- val p = m.measure(c.copy(minHeight = 0))
105
- maxConstraint.value = c.maxHeight
106
- layout(p.width, p.height) {
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 = rememberHighlightDescription(props.description, props.highlightText)
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 endPadding = if (!isLast &&
107
- align != ProgressInfoAlign.Center &&
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 hideLineLeft = align == ProgressInfoAlign.Left ||
112
- (align == ProgressInfoAlign.Stretch && isFirst)
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()) value.toLong().toString()
70
- else ((value * 10).toLong() / 10.0).toString()
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 hideLineLeft = align == StepsAlign.LEFT ||
190
- (align == StepsAlign.STRETCH && index == 0)
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