@momo-kits/native-kits 0.168.1-beta.4-debug → 0.168.1-beta.40-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 (100) hide show
  1. package/CLAUDE.md +15 -10
  2. package/README.md +2 -10
  3. package/build.gradle.kts +1 -3
  4. package/compose/build.gradle.kts +20 -19
  5. package/compose/build.gradle.kts.backup +19 -18
  6. package/compose/compose.podspec +1 -1
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +4 -3
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +1 -1
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -14
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +14 -23
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +21 -15
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +84 -82
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -1
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +18 -14
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +20 -13
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +117 -62
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +22 -6
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -26
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +54 -36
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +1 -6
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +35 -29
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +321 -149
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +2 -3
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +89 -198
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +1 -1
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +30 -44
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +2 -2
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +32 -40
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +12 -3
  43. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +3 -1
  44. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -6
  45. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -10
  46. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  47. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +60 -10
  48. package/gradle/libs.versions.toml +4 -11
  49. package/gradle/wrapper/gradle-wrapper.properties +1 -3
  50. package/gradle.properties +3 -3
  51. package/ios/Application/ApplicationEnvironment.swift +7 -6
  52. package/ios/Application/DesignSystemKits.swift +163 -0
  53. package/ios/Application/DesignSystemKitsPayload.swift +68 -0
  54. package/ios/Badge/BadgeRibbon.swift +8 -1
  55. package/ios/Extensions/Color++.swift +2 -4
  56. package/ios/Input/Input.swift +16 -4
  57. package/ios/Input/InputPhoneNumber.swift +1 -3
  58. package/ios/Input/InputSearch.swift +1 -2
  59. package/ios/Input/InputTextArea.swift +8 -4
  60. package/ios/InputMoney/InputMoney.swift +6 -7
  61. package/ios/Layout/ModalLayout.swift +152 -0
  62. package/ios/Layout/ScreenLayout.swift +77 -18
  63. package/ios/Navigation/BottomSheet.swift +56 -53
  64. package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
  65. package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
  66. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  67. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  68. package/ios/Navigation/BottomTab/DuoTabBar.swift +64 -172
  69. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  70. package/ios/Navigation/Component/HeaderBackground.swift +22 -1
  71. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  72. package/ios/Navigation/Component/SnackBar.swift +4 -0
  73. package/ios/Navigation/ModalScreen.swift +20 -5
  74. package/ios/Navigation/StackScreen.swift +6 -8
  75. package/ios/Popup/PopupDisplay.swift +6 -4
  76. package/ios/Popup/PopupInput.swift +6 -4
  77. package/ios/Popup/PopupLayout.swift +17 -11
  78. package/ios/Popup/PopupNotify.swift +32 -25
  79. package/ios/Stepper/Stepper.swift +1 -2
  80. package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
  81. package/ios/Typography/FontScale.swift +29 -15
  82. package/ios/Typography/Text.swift +88 -14
  83. package/ios/Typography/Typography.swift +2 -2
  84. package/ios/native-kits.podspec +1 -1
  85. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  86. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  87. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  88. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  89. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
  90. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  91. package/package.json +1 -1
  92. package/publish.sh +2 -33
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
  97. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
  98. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
  99. package/ios/Typography/FontScaleStore.swift +0 -58
  100. package/ios/Typography/KitDesignSystem.swift +0 -17
@@ -6,6 +6,7 @@ import androidx.compose.animation.core.tween
6
6
  import androidx.compose.foundation.background
7
7
  import androidx.compose.foundation.border
8
8
  import androidx.compose.foundation.gestures.detectDragGestures
9
+ import androidx.compose.foundation.layout.Arrangement
9
10
  import androidx.compose.foundation.layout.Box
10
11
  import androidx.compose.foundation.layout.BoxWithConstraints
11
12
  import androidx.compose.foundation.layout.Column
@@ -25,7 +26,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape
25
26
  import androidx.compose.runtime.Composable
26
27
  import androidx.compose.runtime.DisposableEffect
27
28
  import androidx.compose.runtime.LaunchedEffect
29
+ import androidx.compose.runtime.getValue
30
+ import androidx.compose.runtime.mutableStateOf
28
31
  import androidx.compose.runtime.remember
32
+ import androidx.compose.runtime.setValue
29
33
  import androidx.compose.runtime.rememberCoroutineScope
30
34
  import androidx.compose.ui.Alignment
31
35
  import androidx.compose.ui.Modifier
@@ -33,11 +37,11 @@ import androidx.compose.ui.graphics.Brush
33
37
  import androidx.compose.ui.graphics.Color
34
38
  import androidx.compose.ui.input.pointer.pointerInput
35
39
  import androidx.compose.ui.platform.LocalDensity
40
+ import androidx.compose.ui.unit.Density
36
41
  import androidx.compose.ui.unit.IntOffset
37
42
  import androidx.compose.ui.unit.dp
38
43
  import kotlinx.coroutines.launch
39
44
  import vn.momo.kits.components.Divider
40
- import vn.momo.kits.components.Icon
41
45
  import vn.momo.kits.components.Text
42
46
  import vn.momo.kits.const.AppTheme
43
47
  import vn.momo.kits.const.Colors
@@ -52,10 +56,25 @@ import vn.momo.kits.modifier.conditional
52
56
  import vn.momo.kits.modifier.noFeedbackClickable
53
57
  import vn.momo.kits.platform.BackHandler
54
58
  import vn.momo.kits.platform.getScreenHeight
59
+ import vn.momo.kits.layout.MODAL_ICON_BUTTON_SIZE
60
+ import vn.momo.kits.layout.ModalIconButton
55
61
  import vn.momo.kits.layout.getScreenLayout
62
+ import vn.momo.kits.layout.rememberModalLayout
56
63
 
57
- // iPhone Duo inner display: center the sheet instead of spanning the width (RN BottomSheet).
58
- private val DUO_REGULAR_MIN_WIDTH = 600.dp
64
+ private val INDICATOR_HEIGHT = 16.dp
65
+ private val HEADER_ROW_HEIGHT = 56.dp
66
+
67
+ // A sheet held at its min height keeps the footer at the bottom; the room goes above it.
68
+ private object FooterAtBottom : Arrangement.Vertical {
69
+ override fun Density.arrange(totalSize: Int, sizes: IntArray, outPositions: IntArray) {
70
+ var y = 0
71
+ sizes.forEachIndexed { index, size ->
72
+ outPositions[index] = y
73
+ y += size
74
+ }
75
+ if (sizes.isNotEmpty()) outPositions[sizes.lastIndex] = maxOf(y - sizes.last(), totalSize - sizes.last())
76
+ }
77
+ }
59
78
 
60
79
  @Composable
61
80
  internal fun BottomSheet(
@@ -69,16 +88,19 @@ internal fun BottomSheet(
69
88
  onDismiss: (() -> Unit)?
70
89
  ) {
71
90
  val layout = getScreenLayout()
72
- val isDuo = layout.isIPhoneDuoDevice
73
- val isDuoCentered = isDuo && layout.width >= DUO_REGULAR_MIN_WIDTH
91
+ val modal = rememberModalLayout()
92
+ val isFoldable = modal.isFoldable
93
+ val sheet = modal.sheet
94
+ val title = header as? BottomHeader.Title
74
95
  // the screen is the outer display on iPhone Duo, even when unfolded
75
- val screenHeightDp = if (isDuo) layout.height else getScreenHeight()
96
+ val screenHeightDp = if (isFoldable) layout.height else getScreenHeight()
76
97
  val screenHeightPx = with(LocalDensity.current) { screenHeightDp.toPx() }
77
98
  val sheetOffset = remember { Animatable(screenHeightPx) }
78
99
 
100
+ // half the scrim fades in first, the other half follows the sheet
79
101
  val backgroundAlpha = remember { Animatable(0f) }
80
- val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.3f
81
- val alpha = backgroundAlpha.value + dynamicAlpha
102
+ val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.5f
103
+ val alpha = (backgroundAlpha.value + dynamicAlpha) * modal.scrimOpacity
82
104
 
83
105
  val sheetCloseOffset = with(LocalDensity.current) { 100.dp.toPx() }
84
106
 
@@ -96,14 +118,20 @@ internal fun BottomSheet(
96
118
  onDispose { }
97
119
  }
98
120
 
121
+ // a closing sheet keeps going: a second close, the open slide or a drag would cancel its animation
122
+ var isClosing by remember { mutableStateOf(false) }
123
+ // runs once the sheet has closed itself, after its onDismiss
124
+ var afterDismiss by remember { mutableStateOf<(() -> Unit)?>(null) }
125
+
99
126
  suspend fun openEvent(){
100
127
  backgroundAlpha.animateTo(
101
- targetValue = 0.3f,
128
+ targetValue = 0.5f,
102
129
  animationSpec = tween(
103
130
  durationMillis = 100,
104
131
  easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
105
132
  )
106
133
  )
134
+ if (isClosing) return
107
135
  sheetOffset.animateTo(
108
136
  targetValue = 0f,
109
137
  animationSpec = tween(
@@ -113,7 +141,9 @@ internal fun BottomSheet(
113
141
  )
114
142
  }
115
143
 
116
- fun closeEvent(){
144
+ fun closeEvent(then: (() -> Unit)? = null){
145
+ if (isClosing) return
146
+ isClosing = true
117
147
  coroutineScope.launch {
118
148
  sheetOffset.animateTo(
119
149
  targetValue = screenHeightPx,
@@ -129,10 +159,15 @@ internal fun BottomSheet(
129
159
  easing = CubicBezierEasing(0.3f, 0.0f, 0.8f, 0.15f)
130
160
  )
131
161
  )
162
+ // not reached when a newer overlay replaced this one, so its back is dropped
163
+ afterDismiss = then
132
164
  OverplayComponentRegistry.hardClearAfterDismiss()
133
165
  }
134
166
  }
135
167
 
168
+ // RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs
169
+ val onBack = title?.onBack?.let { back -> { closeEvent(then = back) } }
170
+
136
171
  LaunchedEffect(Unit) {
137
172
  openEvent()
138
173
  }
@@ -141,6 +176,7 @@ internal fun BottomSheet(
141
176
  OverplayComponentRegistry.bindClose { closeEvent() }
142
177
  onDispose {
143
178
  onDismiss?.invoke()
179
+ afterDismiss?.invoke()
144
180
  }
145
181
  }
146
182
 
@@ -151,41 +187,28 @@ internal fun BottomSheet(
151
187
  BoxWithConstraints(
152
188
  modifier = Modifier
153
189
  .fillMaxSize()
154
- .background(Color.Black.copy(alpha = alpha))
190
+ // full screen on foldables too, over the iPhone Duo control column
191
+ .background(Colors.black_20.copy(alpha = alpha))
155
192
  .noFeedbackClickable {
156
193
  if(barrierDismissible) closeEvent()
157
194
  }
195
+ // centered in the placement: off the iPhone Duo control column, the right half when half folded
196
+ .conditional(isFoldable) {
197
+ absolutePadding(left = modal.placement.left, right = layout.width - modal.placement.right)
198
+ }
158
199
  ) {
159
200
  val parentHeight = with(LocalDensity.current) { constraints.maxHeight.toDp() }
160
- val maxHeight = if (isDuo) {
161
- parentHeight - maxOf(layout.duoTopInset, Spacing.XL)
162
- } else {
163
- parentHeight - 90.dp
164
- }
165
- // landscape side buttons span the full height; in portrait the side status bar only covers the top
166
- val sideInset = isDuo && !isDuoCentered && layout.width > layout.height
201
+ val maxHeight = sheet.maxHeight ?: (parentHeight - 90.dp)
167
202
 
168
203
  Box(
169
204
  modifier = Modifier
170
205
  .align(Alignment.BottomCenter)
171
206
  .offset { IntOffset(x = 0, y = sheetOffset.value.toInt()) }
172
- .then(
173
- if (isDuoCentered) {
174
- // keeps the portrait width in landscape, like system sheets
175
- Modifier.width(
176
- minOf(
177
- minOf(layout.width, layout.height) - Spacing.L * 2,
178
- layout.width - maxOf(layout.insetLeft, layout.insetRight, Spacing.L) * 2,
179
- )
180
- )
181
- } else {
182
- Modifier.fillMaxWidth()
183
- }
184
- )
207
+ .then(if (sheet.width != null) Modifier.width(sheet.width) else Modifier.fillMaxWidth())
185
208
  .heightIn(max = maxHeight)
186
209
  .background(
187
210
  color = if (isSurface) AppTheme.current.colors.background.surface else AppTheme.current.colors.background.default,
188
- shape = RoundedCornerShape(topStart = Radius.M, topEnd = Radius.M)
211
+ shape = RoundedCornerShape(topStart = sheet.radius, topEnd = sheet.radius)
189
212
  )
190
213
  .conditional(IsShowBaseLineDebug) {
191
214
  border(1.dp, Colors.blue_03)
@@ -197,27 +220,26 @@ internal fun BottomSheet(
197
220
  (AppNavigationBar.current - keyboardSizeState().value).coerceAtLeast(0.dp)
198
221
  } else 0.dp
199
222
  Column(
200
- Modifier
201
- .padding(bottom = bottomInset)
202
- .conditional(sideInset) {
203
- absolutePadding(left = layout.insetLeft, right = layout.insetRight)
204
- }
223
+ modifier = Modifier.heightIn(min = sheet.minHeight).padding(bottom = bottomInset),
224
+ verticalArrangement = if (footerComponent != null) FooterAtBottom else Arrangement.Top,
205
225
  ) {
206
226
  Box(
207
227
  modifier = Modifier
208
- .height(72.dp)
228
+ .height(INDICATOR_HEIGHT + HEADER_ROW_HEIGHT)
209
229
  .fillMaxWidth()
210
230
  .conditional(draggable) {
211
231
  pointerInput(Unit) {
212
232
  detectDragGestures(
213
233
  onDrag = { change, dragAmount ->
214
234
  change.consume()
235
+ if (isClosing) return@detectDragGestures
215
236
  coroutineScope.launch {
216
237
  val newOffset = (sheetOffset.value + dragAmount.y).coerceAtLeast(0f)
217
238
  sheetOffset.snapTo(newOffset)
218
239
  }
219
240
  },
220
241
  onDragEnd = {
242
+ if (isClosing) return@detectDragGestures
221
243
  coroutineScope.launch {
222
244
  if (sheetOffset.value > sheetCloseOffset) {
223
245
  closeEvent()
@@ -247,29 +269,17 @@ internal fun BottomSheet(
247
269
  )
248
270
  )
249
271
  Spacer(Modifier.height(4.dp))
250
- Box(Modifier.fillMaxWidth().height(56.dp), contentAlignment = Alignment.Center){
272
+ Box(
273
+ Modifier.fillMaxWidth().height(HEADER_ROW_HEIGHT),
274
+ contentAlignment = Alignment.Center
275
+ ) {
251
276
  when (header) {
252
- is BottomHeader.Title -> {
253
- Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
254
- Box(Modifier.size(24.dp))
255
- Box(Modifier.fillMaxHeight().weight(1f), contentAlignment = Alignment.Center){
256
- Text(
257
- text = header.data,
258
- color = Colors.black_17,
259
- style = Typography.headerDefaultBold
260
- )
261
- }
262
- Box(Modifier
263
- .size(24.dp)
264
- .noFeedbackClickable {
265
- closeEvent()
266
- },
267
- contentAlignment = Alignment.Center
268
- ){
269
- Icon(source = "navigation_close")
270
- }
271
- }
272
- }
277
+ is BottomHeader.Title -> BottomSheetTitle(
278
+ text = header.data,
279
+ backIcon = header.backIcon,
280
+ onBack = onBack,
281
+ onClose = { closeEvent() },
282
+ )
273
283
  is BottomHeader.Custom -> {
274
284
  header.content()
275
285
  }
@@ -283,7 +293,7 @@ internal fun BottomSheet(
283
293
  content()
284
294
  }
285
295
  BottomSheetFooter(footerComponent)
286
- } else if (isDuo) {
296
+ } else if (isFoldable) {
287
297
  // content shrinks so a tall sheet keeps its header
288
298
  Box(Modifier.weight(1f, fill = false)) {
289
299
  content()
@@ -296,6 +306,39 @@ internal fun BottomSheet(
296
306
  }
297
307
  }
298
308
 
309
+ @Composable
310
+ private fun BottomSheetTitle(
311
+ text: String,
312
+ backIcon: String,
313
+ onBack: (() -> Unit)?,
314
+ onClose: () -> Unit,
315
+ ) {
316
+ Row(
317
+ modifier = Modifier.fillMaxSize(),
318
+ horizontalArrangement = Arrangement.spacedBy(Spacing.S),
319
+ verticalAlignment = Alignment.CenterVertically,
320
+ ) {
321
+ if (onBack != null) {
322
+ ModalIconButton(icon = backIcon, automationId = "btn_bottom_sheet_back", onClick = onBack)
323
+ } else {
324
+ Box(Modifier.size(MODAL_ICON_BUTTON_SIZE))
325
+ }
326
+ Box(
327
+ Modifier
328
+ .fillMaxHeight()
329
+ .weight(1f),
330
+ contentAlignment = Alignment.Center
331
+ ) {
332
+ Text(
333
+ text = text,
334
+ color = Colors.black_17,
335
+ style = Typography.headerDefaultBold
336
+ )
337
+ }
338
+ ModalIconButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
339
+ }
340
+ }
341
+
299
342
  @Composable
300
343
  private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
301
344
  val shadowBrush = remember {
@@ -330,7 +373,19 @@ private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
330
373
  sealed class BottomHeader {
331
374
  data class Title(
332
375
  val data: String = "Bottom Sheet Title",
333
- ) : BottomHeader()
376
+ ) : BottomHeader() {
377
+ // Outside the primary constructor so code built against older kits keeps Title() and copy().
378
+ // onBack shows a back button: the sheet closes (onDismiss fires), then it runs.
379
+ var onBack: (() -> Unit)? = null
380
+ private set
381
+ var backIcon: String = "arrow-back"
382
+ private set
383
+
384
+ constructor(data: String, onBack: (() -> Unit)?, backIcon: String = "arrow-back") : this(data) {
385
+ this.onBack = onBack
386
+ this.backIcon = backIcon
387
+ }
388
+ }
334
389
 
335
390
  data class Custom(
336
391
  val content: @Composable () -> Unit
@@ -8,16 +8,17 @@ import androidx.compose.foundation.border
8
8
  import androidx.compose.foundation.clickable
9
9
  import androidx.compose.foundation.interaction.MutableInteractionSource
10
10
  import androidx.compose.foundation.layout.Box
11
+ import androidx.compose.foundation.layout.absolutePadding
11
12
  import androidx.compose.foundation.layout.fillMaxSize
12
- import androidx.compose.foundation.layout.padding
13
+ import androidx.compose.foundation.layout.sizeIn
13
14
  import androidx.compose.foundation.layout.wrapContentSize
14
15
  import androidx.compose.runtime.*
15
16
  import androidx.compose.ui.Alignment
16
17
  import androidx.compose.ui.Modifier
17
18
  import androidx.compose.ui.draw.alpha
18
19
  import androidx.compose.ui.draw.scale
19
- import androidx.compose.ui.graphics.Color
20
20
  import androidx.compose.ui.unit.dp
21
+ import androidx.compose.ui.unit.height
21
22
  import kotlinx.coroutines.launch
22
23
  import vn.momo.kits.application.LocalContext
23
24
  import vn.momo.kits.application.IsShowBaseLineDebug
@@ -27,6 +28,7 @@ import vn.momo.kits.modifier.noFeedbackClickable
27
28
  import vn.momo.kits.navigation.tracking.ScreenTracker
28
29
  import vn.momo.kits.platform.BackHandler
29
30
  import vn.momo.kits.layout.getScreenLayout
31
+ import vn.momo.kits.layout.rememberModalLayout
30
32
 
31
33
  @Composable
32
34
  internal fun ModalScreen(
@@ -103,17 +105,25 @@ internal fun ModalScreen(
103
105
  }
104
106
 
105
107
  val layout = getScreenLayout()
108
+ val modal = rememberModalLayout()
109
+ val placement = modal.placement
106
110
 
107
111
  Box(
108
112
  modifier = Modifier
109
113
  .fillMaxSize()
110
- .background(Color.Black.copy(alpha = 0.6f * alpha.value))
114
+ // full screen on foldables too, over the iPhone Duo control column
115
+ .background(Colors.black_20.copy(alpha = modal.scrimOpacity * alpha.value))
111
116
  .noFeedbackClickable {
112
117
  if(barrierDismissible) closeEvent()
113
118
  }
114
- // center below the side status bar and above the home indicator
115
- .conditional(layout.isIPhoneDuoDevice) {
116
- padding(top = layout.duoTopInset, bottom = layout.insetBottom)
119
+ // center in the placement: the safe area, or the right half of a half-folded iPhone Duo
120
+ .conditional(modal.isFoldable) {
121
+ absolutePadding(
122
+ left = placement.left,
123
+ top = placement.top,
124
+ right = layout.width - placement.right,
125
+ bottom = layout.height - placement.bottom,
126
+ )
117
127
  },
118
128
  contentAlignment = Alignment.Center
119
129
  ) {
@@ -121,6 +131,12 @@ internal fun ModalScreen(
121
131
  modifier = Modifier
122
132
  .scale(scale.value)
123
133
  .alpha(alpha.value)
134
+ .conditional(modal.isFoldable) {
135
+ sizeIn(
136
+ maxWidth = modal.popup.maxWidth,
137
+ maxHeight = modal.popup.maxHeight ?: placement.height,
138
+ )
139
+ }
124
140
  .wrapContentSize()
125
141
  .conditional(IsShowBaseLineDebug) {
126
142
  border(1.dp, Colors.blue_03)
@@ -20,6 +20,10 @@ class Navigation(
20
20
  internal val isBottomTabRoot: Boolean get() = _isBottomTabRoot.value
21
21
  internal fun markAsBottomTabRoot() { _isBottomTabRoot.value = true }
22
22
 
23
+ // A self-scrolling tab asks (via floatingTabBarContentPadding) to run edge to edge behind the
24
+ // floating bar; the kit then stops reserving the bar space as outer padding. Not in NavigationOptions.
25
+ internal var bottomTabEdgeToEdge by mutableStateOf(false)
26
+
23
27
  fun setOptions(
24
28
  onBackHandler: (() -> Unit)? = null,
25
29
  hiddenBack: Boolean? = null,
@@ -30,9 +34,7 @@ class Navigation(
30
34
  headerType: HeaderType? = null,
31
35
  scrollData: ScrollData? = null,
32
36
  backgroundColor: Color? = null,
33
- // AI-GENERATED START: custom screen background
34
37
  backgroundComponent: (@Composable () -> Unit)? = null,
35
- // AI-GENERATED END: custom screen background
36
38
  tintColor: Color? = null,
37
39
  footerComponent: (@Composable () -> Unit)? = null,
38
40
  footerTransparent: Boolean? = null,
@@ -51,9 +53,7 @@ class Navigation(
51
53
  headerType = headerType ?: options.headerType,
52
54
  scrollData = scrollData ?: options.scrollData,
53
55
  backgroundColor = backgroundColor ?: options.backgroundColor,
54
- // AI-GENERATED START: custom screen background
55
56
  backgroundComponent = backgroundComponent ?: options.backgroundComponent,
56
- // AI-GENERATED END: custom screen background
57
57
  tintColor = tintColor ?: options.tintColor,
58
58
  footerComponent = footerComponent ?: options.footerComponent,
59
59
  footerTransparent = footerTransparent ?: options.footerTransparent,
@@ -91,10 +91,7 @@ data class NavigationOptions(
91
91
  val headerType: HeaderType = HeaderType.Default(),
92
92
  val scrollData: ScrollData = ScrollData(),
93
93
  val backgroundColor: Color? = null,
94
- // AI-GENERATED START: custom screen background (SwiftUI `NavigationOptions.background`)
95
- /** Drawn instead of `backgroundColor` over the whole screen: under the header, outside the keyboard padding. */
96
94
  val backgroundComponent: @Composable (() -> Unit)? = null,
97
- // AI-GENERATED END: custom screen background (SwiftUI `NavigationOptions.background`)
98
95
  val tintColor: Color? = null,
99
96
  val footerComponent: @Composable (() -> Unit)? = null,
100
97
  val footerTransparent: Boolean = false,
@@ -20,7 +20,7 @@ import androidx.navigation.toRoute
20
20
  import kotlinx.coroutines.delay
21
21
  import kotlinx.coroutines.flow.collectLatest
22
22
  import vn.momo.kits.application.DesignSystemConfig
23
- import vn.momo.kits.application.KitDesignSystemConfig
23
+ import vn.momo.kits.application.DesignSystemKits
24
24
  import vn.momo.kits.application.LocalContext
25
25
  import vn.momo.kits.application.LocalDesignSystemConfig
26
26
  import vn.momo.kits.application.LocalLocalize
@@ -37,10 +37,7 @@ import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
37
37
  import vn.momo.kits.platform.ProvideOsFontScale
38
38
  import vn.momo.kits.utils.getAppStatusBarHeight
39
39
  import vn.momo.kits.utils.getNavigationBarHeight
40
- // AI-GENERATED START: consume typed NativeMaxApi results
41
40
  import vn.momo.maxapi.IMaxApi
42
- import vn.momo.maxapi.runtime.ApiResult
43
- // AI-GENERATED END: consume typed NativeMaxApi results
44
41
  import kotlin.time.Duration.Companion.milliseconds
45
42
 
46
43
  @Composable
@@ -58,11 +55,7 @@ fun NavigationContainer(
58
55
  ) {
59
56
  val navController = rememberNavController()
60
57
  val registry = remember { DynamicScreenRegistry() }
61
- // AI-GENERATED START: retain the current host client after recomposition
62
- val navigator = remember(navController, maxApi, registry) {
63
- Navigator(navController = navController, maxApi = maxApi, registry = registry)
64
- }
65
- // AI-GENERATED END: retain the current host client after recomposition
58
+ val navigator = remember { Navigator(navController = navController, maxApi = maxApi, registry = registry) }
66
59
  val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
67
60
  val navigationBarHeight = getNavigationBarHeight()
68
61
  val screenLayout = calculateScreenLayout(statusBarHeight, parent = LocalScreenLayout.current)
@@ -73,7 +66,7 @@ fun NavigationContainer(
73
66
  val stackTransition = remember { StackTransitionCoordinator() }
74
67
  val theme = remember { mutableStateOf(initialTheme) }
75
68
  val resolvedDesignSystemConfig =
76
- designSystemConfig ?: LocalDesignSystemConfig.current ?: KitDesignSystemConfig.config
69
+ designSystemConfig ?: LocalDesignSystemConfig.current ?: DesignSystemKits.getConfigs().designSystemConfig
77
70
  val headerBar = resolvedDesignSystemConfig?.headerBar
78
71
  // RN parity: the theme's own header image wins; config headerBar is only the fallback.
79
72
  val resolvedTheme = remember(theme.value, headerBar) {
@@ -87,25 +80,16 @@ fun NavigationContainer(
87
80
 
88
81
  val resolvedLocalize = localize ?: fallbackLocalize
89
82
 
90
- // AI-GENERATED START: cancel language delivery when its composition owner changes
91
- DisposableEffect(maxApi, resolvedLocalize) {
92
- val api = maxApi
93
- val target = resolvedLocalize
94
- var active = true
95
- val handle = runCatching {
96
- api.getLanguage { result ->
97
- if (active && result is ApiResult.Success &&
98
- result.value.trim().lowercase().startsWith(Localize.EN)) {
99
- target.changeLanguage(Localize.EN)
83
+ LaunchedEffect(maxApi, resolvedLocalize) {
84
+ val api = maxApi ?: return@LaunchedEffect
85
+ runCatching {
86
+ api.getLanguage(callback = { data ->
87
+ if (parseLanguage(data) == Localize.EN) {
88
+ resolvedLocalize.changeLanguage(Localize.EN)
100
89
  }
101
- }
102
- }.getOrNull()
103
- onDispose {
104
- active = false
105
- handle?.cancel()
90
+ })
106
91
  }
107
92
  }
108
- // AI-GENERATED END: cancel language delivery when its composition owner changes
109
93
 
110
94
  val screenId = rememberSaveable { registry.nextId() }
111
95
  registry.bind(screenId, initialScreenName, initialScreen, options)
@@ -213,3 +197,9 @@ fun NavigationContainer(
213
197
 
214
198
  val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> { null }
215
199
 
200
+ private fun parseLanguage(raw: Map<String, Any?>?): String? {
201
+ val code = (raw?.get("response") as? String)?.trim()?.lowercase()
202
+ if (code.isNullOrEmpty()) return null
203
+ return if (code.startsWith(Localize.EN)) Localize.EN else Localize.VI
204
+ }
205
+