@momo-kits/native-kits 0.168.1-beta.37-debug → 0.168.1-beta.38-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 (47) hide show
  1. package/CLAUDE.md +2 -3
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +81 -72
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +13 -8
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +163 -54
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +12 -17
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +34 -27
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +319 -167
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +93 -326
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -2
  18. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +3 -2
  19. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +3 -9
  20. package/ios/Input/Input.swift +1 -3
  21. package/ios/Input/InputTextArea.swift +1 -3
  22. package/ios/Layout/ScreenLayout.swift +24 -28
  23. package/ios/Navigation/BottomSheet.swift +157 -29
  24. package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
  25. package/ios/Navigation/BottomTab/BottomTabBar.swift +280 -132
  26. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  27. package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
  28. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  29. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  30. package/ios/Navigation/ModalScreen.swift +7 -18
  31. package/ios/Navigation/StackScreen.swift +3 -1
  32. package/ios/Popup/PopupDisplay.swift +2 -4
  33. package/ios/Popup/PopupInput.swift +2 -4
  34. package/ios/Popup/PopupLayout.swift +9 -10
  35. package/ios/Popup/PopupNotify.swift +23 -26
  36. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  37. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  38. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  39. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -103
  40. package/package.json +1 -1
  41. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  45. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  46. package/ios/Layout/ModalLayout.swift +0 -152
  47. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
@@ -8,6 +8,7 @@ import androidx.compose.foundation.border
8
8
  import androidx.compose.foundation.gestures.detectDragGestures
9
9
  import androidx.compose.foundation.layout.Arrangement
10
10
  import androidx.compose.foundation.layout.Box
11
+ import androidx.compose.foundation.layout.BoxScope
11
12
  import androidx.compose.foundation.layout.BoxWithConstraints
12
13
  import androidx.compose.foundation.layout.Column
13
14
  import androidx.compose.foundation.layout.Row
@@ -18,6 +19,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
18
19
  import androidx.compose.foundation.layout.height
19
20
  import androidx.compose.foundation.layout.heightIn
20
21
  import androidx.compose.foundation.layout.offset
22
+ import androidx.compose.foundation.layout.PaddingValues
21
23
  import androidx.compose.foundation.layout.padding
22
24
  import androidx.compose.foundation.layout.size
23
25
  import androidx.compose.foundation.layout.width
@@ -31,17 +33,21 @@ import androidx.compose.runtime.mutableStateOf
31
33
  import androidx.compose.runtime.remember
32
34
  import androidx.compose.runtime.setValue
33
35
  import androidx.compose.runtime.rememberCoroutineScope
36
+ import androidx.compose.ui.AbsoluteAlignment
34
37
  import androidx.compose.ui.Alignment
35
38
  import androidx.compose.ui.Modifier
36
39
  import androidx.compose.ui.graphics.Brush
37
40
  import androidx.compose.ui.graphics.Color
38
41
  import androidx.compose.ui.input.pointer.pointerInput
42
+ import androidx.compose.ui.layout.layout
39
43
  import androidx.compose.ui.platform.LocalDensity
40
- import androidx.compose.ui.unit.Density
44
+ import androidx.compose.ui.unit.Dp
41
45
  import androidx.compose.ui.unit.IntOffset
46
+ import androidx.compose.ui.unit.constrainHeight
42
47
  import androidx.compose.ui.unit.dp
43
48
  import kotlinx.coroutines.launch
44
49
  import vn.momo.kits.components.Divider
50
+ import vn.momo.kits.components.Icon
45
51
  import vn.momo.kits.components.Text
46
52
  import vn.momo.kits.const.AppTheme
47
53
  import vn.momo.kits.const.Colors
@@ -56,25 +62,23 @@ import vn.momo.kits.modifier.conditional
56
62
  import vn.momo.kits.modifier.noFeedbackClickable
57
63
  import vn.momo.kits.platform.BackHandler
58
64
  import vn.momo.kits.platform.getScreenHeight
59
- import vn.momo.kits.layout.MODAL_ICON_BUTTON_SIZE
60
- import vn.momo.kits.layout.ModalIconButton
65
+ import vn.momo.kits.layout.DuoMetrics
66
+ import vn.momo.kits.layout.SideBarEdge
67
+ import vn.momo.kits.layout.SideBarLayout
61
68
  import vn.momo.kits.layout.getScreenLayout
62
- import vn.momo.kits.layout.rememberModalLayout
69
+ import vn.momo.kits.modifier.setAutomationId
70
+ import vn.momo.kits.navigation.component.HeaderType
71
+ import vn.momo.kits.navigation.component.SideBarButton
72
+ import vn.momo.kits.navigation.component.getHeaderColor
73
+
74
+ // iPhone Duo inner display: center the sheet instead of spanning the width (RN BottomSheet).
75
+ private val DUO_REGULAR_MIN_WIDTH = 600.dp
63
76
 
64
77
  private val INDICATOR_HEIGHT = 16.dp
65
78
  private val HEADER_ROW_HEIGHT = 56.dp
66
79
 
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
- }
80
+ // Side column controls line up with the header row while the sheet is short.
81
+ private val SIDE_COLUMN_OFFSET = INDICATOR_HEIGHT + (HEADER_ROW_HEIGHT - DuoMetrics.controlSize) / 2
78
82
 
79
83
  @Composable
80
84
  internal fun BottomSheet(
@@ -88,19 +92,30 @@ internal fun BottomSheet(
88
92
  onDismiss: (() -> Unit)?
89
93
  ) {
90
94
  val layout = getScreenLayout()
91
- val modal = rememberModalLayout()
92
- val isFoldable = modal.isFoldable
93
- val sheet = modal.sheet
95
+ val isDuo = layout.isIPhoneDuoDevice
96
+ val isDuoCentered = isDuo && minOf(layout.width, layout.height) >= DUO_REGULAR_MIN_WIDTH
97
+ val isDuoFloating = isDuo && !isDuoCentered
94
98
  val title = header as? BottomHeader.Title
99
+ val sideColumn = layout.sideBar?.takeIf {
100
+ isDuoFloating && title != null && it.width - Spacing.M >= DuoMetrics.controlSize + Spacing.M
101
+ }
102
+ // the floating sheet spans the side safe area, its content stays clear of it
103
+ val sidePadding = if (isDuoFloating) {
104
+ PaddingValues.Absolute(
105
+ left = (layout.insetLeft - Spacing.M).coerceAtLeast(0.dp),
106
+ right = (layout.insetRight - Spacing.M).coerceAtLeast(0.dp),
107
+ )
108
+ } else {
109
+ PaddingValues()
110
+ }
95
111
  // the screen is the outer display on iPhone Duo, even when unfolded
96
- val screenHeightDp = if (isFoldable) layout.height else getScreenHeight()
112
+ val screenHeightDp = if (isDuo) layout.height else getScreenHeight()
97
113
  val screenHeightPx = with(LocalDensity.current) { screenHeightDp.toPx() }
98
114
  val sheetOffset = remember { Animatable(screenHeightPx) }
99
115
 
100
- // half the scrim fades in first, the other half follows the sheet
101
116
  val backgroundAlpha = remember { Animatable(0f) }
102
- val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.5f
103
- val alpha = (backgroundAlpha.value + dynamicAlpha) * modal.scrimOpacity
117
+ val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.3f
118
+ val alpha = backgroundAlpha.value + dynamicAlpha
104
119
 
105
120
  val sheetCloseOffset = with(LocalDensity.current) { 100.dp.toPx() }
106
121
 
@@ -125,7 +140,7 @@ internal fun BottomSheet(
125
140
 
126
141
  suspend fun openEvent(){
127
142
  backgroundAlpha.animateTo(
128
- targetValue = 0.5f,
143
+ targetValue = 0.3f,
129
144
  animationSpec = tween(
130
145
  durationMillis = 100,
131
146
  easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
@@ -187,28 +202,40 @@ internal fun BottomSheet(
187
202
  BoxWithConstraints(
188
203
  modifier = Modifier
189
204
  .fillMaxSize()
190
- // full screen on foldables too, over the iPhone Duo control column
191
- .background(Colors.black_20.copy(alpha = alpha))
205
+ .background(Color.Black.copy(alpha = alpha))
192
206
  .noFeedbackClickable {
193
207
  if(barrierDismissible) closeEvent()
194
208
  }
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
- }
199
209
  ) {
200
210
  val parentHeight = with(LocalDensity.current) { constraints.maxHeight.toDp() }
201
- val maxHeight = sheet.maxHeight ?: (parentHeight - 90.dp)
211
+ val maxHeight = if (isDuo) {
212
+ parentHeight - maxOf(layout.duoTopInset, Spacing.XL)
213
+ } else {
214
+ parentHeight - 90.dp
215
+ }
216
+ val radius = if (isDuo) Radius.XL else Radius.M
202
217
 
203
218
  Box(
204
219
  modifier = Modifier
205
220
  .align(Alignment.BottomCenter)
206
221
  .offset { IntOffset(x = 0, y = sheetOffset.value.toInt()) }
207
- .then(if (sheet.width != null) Modifier.width(sheet.width) else Modifier.fillMaxWidth())
222
+ .then(
223
+ when {
224
+ // keeps the portrait width in landscape, like system sheets
225
+ isDuoCentered -> Modifier.width(
226
+ minOf(
227
+ minOf(layout.width, layout.height) - Spacing.L * 2,
228
+ layout.width - maxOf(layout.insetLeft, layout.insetRight, Spacing.L) * 2,
229
+ )
230
+ )
231
+ isDuoFloating -> Modifier.fillMaxWidth().padding(horizontal = Spacing.M)
232
+ else -> Modifier.fillMaxWidth()
233
+ }
234
+ )
208
235
  .heightIn(max = maxHeight)
209
236
  .background(
210
237
  color = if (isSurface) AppTheme.current.colors.background.surface else AppTheme.current.colors.background.default,
211
- shape = RoundedCornerShape(topStart = sheet.radius, topEnd = sheet.radius)
238
+ shape = RoundedCornerShape(topStart = radius, topEnd = radius)
212
239
  )
213
240
  .conditional(IsShowBaseLineDebug) {
214
241
  border(1.dp, Colors.blue_03)
@@ -219,10 +246,7 @@ internal fun BottomSheet(
219
246
  val bottomInset = if (useBottomInset) {
220
247
  (AppNavigationBar.current - keyboardSizeState().value).coerceAtLeast(0.dp)
221
248
  } else 0.dp
222
- Column(
223
- modifier = Modifier.heightIn(min = sheet.minHeight).padding(bottom = bottomInset),
224
- verticalArrangement = if (footerComponent != null) FooterAtBottom else Arrangement.Top,
225
- ) {
249
+ Column(Modifier.padding(bottom = bottomInset)) {
226
250
  Box(
227
251
  modifier = Modifier
228
252
  .height(INDICATOR_HEIGHT + HEADER_ROW_HEIGHT)
@@ -252,6 +276,7 @@ internal fun BottomSheet(
252
276
  }
253
277
  }
254
278
  ) {
279
+ // the indicator centers on the whole sheet, only the header row keeps clear of the strip
255
280
  Column(
256
281
  modifier = Modifier
257
282
  .fillMaxSize()
@@ -270,13 +295,15 @@ internal fun BottomSheet(
270
295
  )
271
296
  Spacer(Modifier.height(4.dp))
272
297
  Box(
273
- Modifier.fillMaxWidth().height(HEADER_ROW_HEIGHT),
298
+ Modifier.padding(sidePadding).fillMaxWidth().height(HEADER_ROW_HEIGHT),
274
299
  contentAlignment = Alignment.Center
275
300
  ) {
276
301
  when (header) {
277
302
  is BottomHeader.Title -> BottomSheetTitle(
278
303
  text = header.data,
279
304
  backIcon = header.backIcon,
305
+ // the side column holds back and close, the row keeps only the title
306
+ showButtons = sideColumn == null,
280
307
  onBack = onBack,
281
308
  onClose = { closeEvent() },
282
309
  )
@@ -287,21 +314,32 @@ internal fun BottomSheet(
287
314
  }
288
315
  }
289
316
  }
290
- Divider()
317
+ Box(Modifier.padding(sidePadding)) {
318
+ Divider()
319
+ }
291
320
  if (footerComponent != null) {
292
- Box(Modifier.weight(1f, fill = false)) {
321
+ Box(Modifier.weight(1f, fill = false).padding(sidePadding)) {
293
322
  content()
294
323
  }
295
- BottomSheetFooter(footerComponent)
296
- } else if (isFoldable) {
324
+ BottomSheetFooter(footerComponent, sidePadding)
325
+ } else if (isDuo) {
297
326
  // content shrinks so a tall sheet keeps its header
298
- Box(Modifier.weight(1f, fill = false)) {
327
+ Box(Modifier.weight(1f, fill = false).padding(sidePadding)) {
299
328
  content()
300
329
  }
301
330
  } else {
302
331
  content()
303
332
  }
304
333
  }
334
+ if (sideColumn != null && title != null) {
335
+ BottomSheetSideColumn(
336
+ sideBar = sideColumn,
337
+ parentHeight = parentHeight,
338
+ backIcon = title.backIcon,
339
+ onBack = onBack,
340
+ onClose = { closeEvent() },
341
+ )
342
+ }
305
343
  }
306
344
  }
307
345
  }
@@ -310,23 +348,23 @@ internal fun BottomSheet(
310
348
  private fun BottomSheetTitle(
311
349
  text: String,
312
350
  backIcon: String,
351
+ showButtons: Boolean,
313
352
  onBack: (() -> Unit)?,
314
353
  onClose: () -> Unit,
315
354
  ) {
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))
355
+ Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
356
+ if (showButtons) {
357
+ if (onBack != null) {
358
+ BottomSheetHeaderButton(icon = backIcon, automationId = "btn_bottom_sheet_back", onClick = onBack)
359
+ } else {
360
+ Box(Modifier.size(24.dp))
361
+ }
325
362
  }
326
363
  Box(
327
364
  Modifier
328
365
  .fillMaxHeight()
329
- .weight(1f),
366
+ .weight(1f)
367
+ .conditional(!showButtons) { padding(horizontal = Spacing.M) },
330
368
  contentAlignment = Alignment.Center
331
369
  ) {
332
370
  Text(
@@ -335,12 +373,82 @@ private fun BottomSheetTitle(
335
373
  style = Typography.headerDefaultBold
336
374
  )
337
375
  }
338
- ModalIconButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
376
+ if (showButtons) {
377
+ BottomSheetHeaderButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
378
+ }
379
+ }
380
+ }
381
+
382
+ @Composable
383
+ private fun BottomSheetHeaderButton(icon: String, automationId: String, onClick: () -> Unit) {
384
+ Box(
385
+ Modifier
386
+ .size(24.dp)
387
+ .noFeedbackClickable(onClick = onClick)
388
+ .setAutomationId(automationId),
389
+ contentAlignment = Alignment.Center
390
+ ) {
391
+ Icon(source = icon)
392
+ }
393
+ }
394
+
395
+ // iPhone Duo outer display: back and close sit on the part of the sheet under the side safe area,
396
+ // 12pt from the strip's inner edge like the screen side bar. They follow the header row while the
397
+ // sheet is short and stay below the status bar cluster while it is tall.
398
+ @Composable
399
+ private fun BoxScope.BottomSheetSideColumn(
400
+ sideBar: SideBarLayout,
401
+ parentHeight: Dp,
402
+ backIcon: String,
403
+ onBack: (() -> Unit)?,
404
+ onClose: () -> Unit,
405
+ ) {
406
+ val isRight = sideBar.edge == SideBarEdge.RIGHT
407
+ val headerColor = getHeaderColor(HeaderType.None, 1f, null, AppTheme.current.colors.text.default)
408
+
409
+ Box(Modifier.matchParentSize()) {
410
+ Column(
411
+ modifier = Modifier
412
+ .align(if (isRight) AbsoluteAlignment.TopRight else AbsoluteAlignment.TopLeft)
413
+ .width(sideBar.width - Spacing.M)
414
+ .layout { measurable, constraints ->
415
+ val placeable = measurable.measure(constraints.copy(minHeight = 0))
416
+ val sheetHeight = constraints.maxHeight
417
+ // the sheet rests on the bottom of the overlay, which starts at the window top
418
+ val sheetTop = parentHeight.roundToPx() - sheetHeight
419
+ // clear of a camera at the bottom end of the strip when it can
420
+ val lowest = sheetHeight - sideBar.bottom.roundToPx() - placeable.height
421
+ val y = maxOf(sideBar.top.roundToPx() - sheetTop, SIDE_COLUMN_OFFSET.roundToPx())
422
+ .coerceAtMost(lowest)
423
+ .coerceAtLeast(0)
424
+ layout(placeable.width, constraints.constrainHeight(y + placeable.height)) {
425
+ placeable.place(0, y)
426
+ }
427
+ }
428
+ .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M),
429
+ horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
430
+ verticalArrangement = Arrangement.spacedBy(Spacing.M),
431
+ ) {
432
+ if (onBack != null) {
433
+ SideBarButton(
434
+ icon = backIcon,
435
+ headerColor = headerColor,
436
+ automationId = "btn_bottom_sheet_back",
437
+ onClick = onBack,
438
+ )
439
+ }
440
+ SideBarButton(
441
+ icon = "navigation_close",
442
+ headerColor = headerColor,
443
+ automationId = "btn_bottom_sheet_close",
444
+ onClick = onClose,
445
+ )
446
+ }
339
447
  }
340
448
  }
341
449
 
342
450
  @Composable
343
- private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
451
+ private fun BottomSheetFooter(footerComponent: @Composable () -> Unit, sidePadding: PaddingValues) {
344
452
  val shadowBrush = remember {
345
453
  Brush.verticalGradient(
346
454
  colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
@@ -355,6 +463,7 @@ private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
355
463
  .conditional(IsShowBaseLineDebug) {
356
464
  border(1.dp, Colors.blue_03)
357
465
  }
466
+ .padding(sidePadding)
358
467
  .padding(vertical = Spacing.S)
359
468
  ) {
360
469
  footerComponent()
@@ -17,8 +17,8 @@ import androidx.compose.ui.Alignment
17
17
  import androidx.compose.ui.Modifier
18
18
  import androidx.compose.ui.draw.alpha
19
19
  import androidx.compose.ui.draw.scale
20
+ import androidx.compose.ui.graphics.Color
20
21
  import androidx.compose.ui.unit.dp
21
- import androidx.compose.ui.unit.height
22
22
  import kotlinx.coroutines.launch
23
23
  import vn.momo.kits.application.LocalContext
24
24
  import vn.momo.kits.application.IsShowBaseLineDebug
@@ -27,8 +27,9 @@ import vn.momo.kits.modifier.conditional
27
27
  import vn.momo.kits.modifier.noFeedbackClickable
28
28
  import vn.momo.kits.navigation.tracking.ScreenTracker
29
29
  import vn.momo.kits.platform.BackHandler
30
+ import vn.momo.kits.layout.duoModalMaxHeight
31
+ import vn.momo.kits.layout.duoModalMaxWidth
30
32
  import vn.momo.kits.layout.getScreenLayout
31
- import vn.momo.kits.layout.rememberModalLayout
32
33
 
33
34
  @Composable
34
35
  internal fun ModalScreen(
@@ -105,24 +106,21 @@ internal fun ModalScreen(
105
106
  }
106
107
 
107
108
  val layout = getScreenLayout()
108
- val modal = rememberModalLayout()
109
- val placement = modal.placement
110
109
 
111
110
  Box(
112
111
  modifier = Modifier
113
112
  .fillMaxSize()
114
- // full screen on foldables too, over the iPhone Duo control column
115
- .background(Colors.black_20.copy(alpha = modal.scrimOpacity * alpha.value))
113
+ .background(Color.Black.copy(alpha = 0.6f * alpha.value))
116
114
  .noFeedbackClickable {
117
115
  if(barrierDismissible) closeEvent()
118
116
  }
119
- // center in the placement: the safe area, or the right half of a half-folded iPhone Duo
120
- .conditional(modal.isFoldable) {
117
+ // center in the safe area, clear of the side toolbar strip and the home indicator
118
+ .conditional(layout.isIPhoneDuoDevice) {
121
119
  absolutePadding(
122
- left = placement.left,
123
- top = placement.top,
124
- right = layout.width - placement.right,
125
- bottom = layout.height - placement.bottom,
120
+ left = layout.insetLeft,
121
+ top = layout.insetTop,
122
+ right = layout.insetRight,
123
+ bottom = layout.insetBottom,
126
124
  )
127
125
  },
128
126
  contentAlignment = Alignment.Center
@@ -131,11 +129,8 @@ internal fun ModalScreen(
131
129
  modifier = Modifier
132
130
  .scale(scale.value)
133
131
  .alpha(alpha.value)
134
- .conditional(modal.isFoldable) {
135
- sizeIn(
136
- maxWidth = modal.popup.maxWidth,
137
- maxHeight = modal.popup.maxHeight ?: placement.height,
138
- )
132
+ .conditional(layout.isIPhoneDuoDevice) {
133
+ sizeIn(maxWidth = layout.duoModalMaxWidth, maxHeight = layout.duoModalMaxHeight)
139
134
  }
140
135
  .wrapContentSize()
141
136
  .conditional(IsShowBaseLineDebug) {
@@ -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,
@@ -29,6 +29,7 @@ import androidx.compose.foundation.verticalScroll
29
29
  import androidx.compose.material.ExperimentalMaterialApi
30
30
  import androidx.compose.runtime.Composable
31
31
  import androidx.compose.runtime.CompositionLocalProvider
32
+ import androidx.compose.foundation.layout.PaddingValues
32
33
  import androidx.compose.runtime.LaunchedEffect
33
34
  import androidx.compose.runtime.State
34
35
  import androidx.compose.runtime.getValue
@@ -61,7 +62,6 @@ import vn.momo.kits.const.Colors
61
62
  import vn.momo.kits.const.Spacing
62
63
  import vn.momo.kits.modifier.conditional
63
64
  import vn.momo.kits.modifier.hideKeyboardOnTap
64
- import vn.momo.kits.navigation.bottomtab.BOTTOM_TAB_BAR_HEIGHT
65
65
  import vn.momo.kits.navigation.component.FABPosition
66
66
  import vn.momo.kits.navigation.component.FloatingButton
67
67
  import vn.momo.kits.navigation.component.HEADER_HEIGHT
@@ -70,6 +70,7 @@ import vn.momo.kits.navigation.component.HeaderBackground
70
70
  import vn.momo.kits.navigation.component.HeaderRight
71
71
  import vn.momo.kits.navigation.component.HeaderSideBar
72
72
  import vn.momo.kits.navigation.bottomtab.LocalDuoRailReserve
73
+ import vn.momo.kits.navigation.bottomtab.LocalTabBarHasCenterAction
73
74
  import vn.momo.kits.navigation.bottomtab.duoFloatingTabBarInset
74
75
  import vn.momo.kits.navigation.component.HeaderType
75
76
  import vn.momo.kits.navigation.component.InputSearchType
@@ -90,21 +91,27 @@ import kotlin.time.Clock
90
91
  import kotlin.time.Duration.Companion.milliseconds
91
92
  import kotlin.time.ExperimentalTime
92
93
 
94
+ @Composable
95
+ fun floatingTabBarContentPadding(): PaddingValues {
96
+ val navigation = LocalNavigation.current
97
+ LaunchedEffect(navigation) { navigation.bottomTabEdgeToEdge = true }
98
+ val reserve = navigation.bottomTabIndex != -1 && navigation.bottomTabEdgeToEdge
99
+ return PaddingValues(bottom = if (reserve) bottomTabChildInset() else 0.dp)
100
+ }
101
+
93
102
  internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
94
103
  internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
95
104
 
96
- // Space a tab's content leaves for the tab bar and home indicator. On iPhone Duo the floating bar
97
- // overlays the content and the rail lives in the side strip, so only their own inset applies.
105
+ // Space a tab's content leaves for the tab bar and home indicator: the horizontal bar floats over the
106
+ // content (phone and unfolded Duo); the Duo rail lives in the side strip, so only the home indicator.
98
107
  @Composable
99
108
  private fun bottomTabChildInset(): Dp {
100
109
  val keyboard = keyboardSizeState().value
101
110
  val navigationBar = AppNavigationBar.current
102
111
  val layout = getScreenLayout()
103
112
  return when {
104
- layout.isIPhoneDuo && layout.sideBar == null -> (duoFloatingTabBarInset(layout) - keyboard).coerceAtLeast(0.dp)
105
- layout.isIPhoneDuo -> (navigationBar - keyboard).coerceAtLeast(0.dp)
106
- else -> (BOTTOM_TAB_BAR_HEIGHT.dp + Spacing.S - keyboard).coerceAtLeast(0.dp) +
107
- (navigationBar - keyboard).coerceAtLeast(0.dp)
113
+ layout.isIPhoneDuo && layout.sideBar != null -> (navigationBar - keyboard).coerceAtLeast(0.dp)
114
+ else -> (duoFloatingTabBarInset(layout, LocalTabBarHasCenterAction.current) - keyboard).coerceAtLeast(0.dp)
108
115
  }
109
116
  }
110
117
 
@@ -333,7 +340,6 @@ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTa
333
340
 
334
341
  Spacer(Modifier.height((HEADER_HEIGHT.dp - scrollDp).coerceIn(0.dp, HEADER_HEIGHT.dp)))
335
342
  }
336
- // a bottom tab root stays full width: the tab bar and each tab's own StackScreen handle the insets
337
343
  val insetContent = !isBottomTabRoot
338
344
  Column(
339
345
  Modifier
@@ -351,7 +357,8 @@ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTa
351
357
  .padding(
352
358
  bottom = when {
353
359
  options.hasFooter() || isBottomTabRoot -> 0.dp
354
- isBottomTabChild -> bottomTabChildInset()
360
+ // 0 when the tab pads itself via floatingTabBarContentPadding(), else the kit reserves the bar space
361
+ isBottomTabChild -> if (LocalNavigation.current.bottomTabEdgeToEdge) 0.dp else bottomTabChildInset()
355
362
  !options.scrollData.scrollable && options.scrollData.scrollState == null -> 0.dp
356
363
  else -> navigationBar
357
364
  }
@@ -401,8 +408,8 @@ internal fun FooterContent() {
401
408
  val options = LocalOptions.current
402
409
  if (options.hasFooter()) {
403
410
  val keyboardSize = keyboardSizeState()
404
- // the Duo floating tab bar overlays tab content, so a tab's footer sits above it
405
- val duoTabInset = if (LocalNavigation.current.bottomTabIndex != -1) duoFloatingTabBarInset(getScreenLayout()) else 0.dp
411
+ // the floating tab bar overlays tab content, so a tab's footer sits above it
412
+ val duoTabInset = if (LocalNavigation.current.bottomTabIndex != -1) duoFloatingTabBarInset(getScreenLayout(), LocalTabBarHasCenterAction.current) else 0.dp
406
413
  val bottomPadding = (maxOf(AppNavigationBar.current, duoTabInset) - keyboardSize.value).coerceAtLeast(0.dp)
407
414
  Footer(
408
415
  footerComponent = options.footerComponent,