@momo-kits/native-kits 0.168.1-sizescale.1-debug → 0.169.1-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 (64) hide show
  1. package/CLAUDE.md +4 -3
  2. package/PUBLISH_GUIDE.md +29 -658
  3. package/compose/build.gradle.kts +2 -2
  4. package/compose/compose.podspec +1 -1
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +4 -5
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +2 -2
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +21 -15
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +76 -83
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +3 -3
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +1 -1
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +11 -14
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +3 -4
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +8 -13
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +57 -163
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +17 -12
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +5 -7
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +34 -23
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +321 -149
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +87 -261
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +2 -0
  30. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +1 -2
  31. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +3 -2
  32. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  33. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +9 -3
  34. package/gradle.properties +1 -3
  35. package/ios/Input/Input.swift +3 -1
  36. package/ios/Input/InputTextArea.swift +3 -1
  37. package/ios/Layout/ModalLayout.swift +152 -0
  38. package/ios/Layout/ScreenLayout.swift +28 -24
  39. package/ios/Navigation/BottomSheet.swift +29 -156
  40. package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
  41. package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
  42. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  43. package/ios/Navigation/BottomTab/DuoTabBar.swift +62 -195
  44. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  45. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  46. package/ios/Navigation/ModalScreen.swift +18 -7
  47. package/ios/Navigation/StackScreen.swift +3 -1
  48. package/ios/Popup/PopupDisplay.swift +4 -2
  49. package/ios/Popup/PopupInput.swift +4 -2
  50. package/ios/Popup/PopupLayout.swift +10 -9
  51. package/ios/Popup/PopupNotify.swift +32 -25
  52. package/ios/Typography/Text.swift +2 -2
  53. package/ios/native-kits.podspec +1 -1
  54. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  55. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  56. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  57. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  58. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
  59. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  60. package/local.properties +8 -0
  61. package/package.json +1 -1
  62. package/publish.sh +170 -513
  63. package/compose/build.gradle.kts.backup +0 -198
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitSizeScale.kt +0 -45
@@ -10,6 +10,7 @@ import androidx.compose.ui.platform.LocalDensity
10
10
  import androidx.compose.ui.platform.LocalLayoutDirection
11
11
  import androidx.compose.ui.platform.LocalWindowInfo
12
12
  import androidx.compose.ui.unit.Dp
13
+ import androidx.compose.ui.unit.DpRect
13
14
  import androidx.compose.ui.unit.dp
14
15
  import vn.momo.kits.const.Spacing
15
16
  import vn.momo.kits.navigation.component.HEADER_HEIGHT
@@ -59,6 +60,8 @@ data class ScreenLayout(
59
60
  val duoTopInset: Dp = insetTop,
60
61
  // iPhone Duo inner display in portrait: the header row shares the status bar band, between its clusters.
61
62
  val statusBarClearance: StatusBarClearance? = null,
63
+ // Half-folded iPhone Duo: the hinge in window coordinates, running top to bottom; null while flat.
64
+ val hinge: DpRect? = null,
62
65
  ) {
63
66
  val headerBarHeight: Dp get() = headerHeight - headerStatusBarHeight
64
67
  }
@@ -91,11 +94,6 @@ internal object DuoMetrics {
91
94
  val floatingTabBarHeight = 62.dp
92
95
  val floatingTabBarMargin = 20.dp
93
96
  val floatingTabBarInsetOverlap = 13.dp
94
- // Width of a system alert on the inner display, in both orientations.
95
- val modalMaxWidth = 440.dp
96
- // Fits a PopupNotify with image, scrolled description and actions at the max width (RN
97
- // Application/device.ts); taller content scrolls instead of filling the inner display.
98
- val modalMaxHeight = 640.dp
99
97
  }
100
98
 
101
99
  private val IPHONE_HEADER_MIN_HEIGHT = 72.dp
@@ -153,19 +151,12 @@ internal fun calculateScreenLayout(topInset: Dp, parent: ScreenLayout? = null):
153
151
  asymmetricInsets = leftPx != rightPx,
154
152
  isDuoDevice = isPhone && reservedRegions.isFoldable,
155
153
  reservedRegions = reservedRegions.occlusion,
154
+ division = reservedRegions.division,
156
155
  )
157
156
  }
158
157
  }
159
158
  }
160
159
 
161
- // Room for a dialog on iPhone Duo: inside the safe area, so clear of the side toolbar strip, and
162
- // capped so it stays a dialog on the inner display.
163
- internal val ScreenLayout.duoModalMaxWidth: Dp
164
- get() = minOf(width - insetLeft - insetRight - Spacing.XL * 2, DuoMetrics.modalMaxWidth)
165
-
166
- internal val ScreenLayout.duoModalMaxHeight: Dp
167
- get() = minOf(height - insetTop - insetBottom - Spacing.XL * 2, DuoMetrics.modalMaxHeight)
168
-
169
160
  // Content inside the safe-area padding: the insets are spent and the side bar belongs to the screen.
170
161
  internal fun ScreenLayout.consumeHorizontalInsets(): ScreenLayout =
171
162
  copy(width = contentWidth, insetLeft = 0.dp, insetRight = 0.dp, sideBar = null)
@@ -256,6 +247,7 @@ private fun screenLayoutOf(
256
247
  asymmetricInsets: Boolean,
257
248
  isDuoDevice: Boolean,
258
249
  reservedRegions: List<ReservedRegion>,
250
+ division: ReservedRegion?,
259
251
  ): ScreenLayout {
260
252
  val isIPhoneDuo = isPhone && isIPhoneDuoWindow(width, height, asymmetricInsets)
261
253
  val isInnerPortrait = height > width && width >= DuoMetrics.innerMinHeight
@@ -317,5 +309,8 @@ private fun screenLayoutOf(
317
309
  isIPhoneDuoDevice = isDuoDevice || (isPhone && asymmetricInsets),
318
310
  duoTopInset = maxOf(topInset, if (height > width) sideInset * 2 else 0.dp),
319
311
  statusBarClearance = statusBarClearance,
312
+ // only a hinge splitting the window into left and right halves moves overlays
313
+ hinge = division?.takeIf { isPhone && it.height > it.width }
314
+ ?.let { DpRect(it.x, it.y, it.x + it.width, it.y + it.height) },
320
315
  )
321
316
  }
@@ -8,7 +8,6 @@ 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
12
11
  import androidx.compose.foundation.layout.BoxWithConstraints
13
12
  import androidx.compose.foundation.layout.Column
14
13
  import androidx.compose.foundation.layout.Row
@@ -19,7 +18,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
19
18
  import androidx.compose.foundation.layout.height
20
19
  import androidx.compose.foundation.layout.heightIn
21
20
  import androidx.compose.foundation.layout.offset
22
- import androidx.compose.foundation.layout.PaddingValues
23
21
  import androidx.compose.foundation.layout.padding
24
22
  import androidx.compose.foundation.layout.size
25
23
  import androidx.compose.foundation.layout.width
@@ -33,21 +31,17 @@ import androidx.compose.runtime.mutableStateOf
33
31
  import androidx.compose.runtime.remember
34
32
  import androidx.compose.runtime.setValue
35
33
  import androidx.compose.runtime.rememberCoroutineScope
36
- import androidx.compose.ui.AbsoluteAlignment
37
34
  import androidx.compose.ui.Alignment
38
35
  import androidx.compose.ui.Modifier
39
36
  import androidx.compose.ui.graphics.Brush
40
37
  import androidx.compose.ui.graphics.Color
41
38
  import androidx.compose.ui.input.pointer.pointerInput
42
- import androidx.compose.ui.layout.layout
43
39
  import androidx.compose.ui.platform.LocalDensity
44
- import androidx.compose.ui.unit.Dp
40
+ import androidx.compose.ui.unit.Density
45
41
  import androidx.compose.ui.unit.IntOffset
46
- import androidx.compose.ui.unit.constrainHeight
47
42
  import androidx.compose.ui.unit.dp
48
43
  import kotlinx.coroutines.launch
49
44
  import vn.momo.kits.components.Divider
50
- import vn.momo.kits.components.Icon
51
45
  import vn.momo.kits.components.Text
52
46
  import vn.momo.kits.const.AppTheme
53
47
  import vn.momo.kits.const.Colors
@@ -62,23 +56,25 @@ import vn.momo.kits.modifier.conditional
62
56
  import vn.momo.kits.modifier.noFeedbackClickable
63
57
  import vn.momo.kits.platform.BackHandler
64
58
  import vn.momo.kits.platform.getScreenHeight
65
- import vn.momo.kits.layout.DuoMetrics
66
- import vn.momo.kits.layout.SideBarEdge
67
- import vn.momo.kits.layout.SideBarLayout
59
+ import vn.momo.kits.layout.MODAL_ICON_BUTTON_SIZE
60
+ import vn.momo.kits.layout.ModalIconButton
68
61
  import vn.momo.kits.layout.getScreenLayout
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
62
+ import vn.momo.kits.layout.rememberModalLayout
76
63
 
77
64
  private val INDICATOR_HEIGHT = 16.dp
78
65
  private val HEADER_ROW_HEIGHT = 56.dp
79
66
 
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
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
+ }
82
78
 
83
79
  @Composable
84
80
  internal fun BottomSheet(
@@ -92,30 +88,19 @@ internal fun BottomSheet(
92
88
  onDismiss: (() -> Unit)?
93
89
  ) {
94
90
  val layout = getScreenLayout()
95
- val isDuo = layout.isIPhoneDuoDevice
96
- val isDuoCentered = isDuo && minOf(layout.width, layout.height) >= DUO_REGULAR_MIN_WIDTH
97
- val isDuoFloating = isDuo && !isDuoCentered
91
+ val modal = rememberModalLayout()
92
+ val isFoldable = modal.isFoldable
93
+ val sheet = modal.sheet
98
94
  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
- }
111
95
  // the screen is the outer display on iPhone Duo, even when unfolded
112
- val screenHeightDp = if (isDuo) layout.height else getScreenHeight()
96
+ val screenHeightDp = if (isFoldable) layout.height else getScreenHeight()
113
97
  val screenHeightPx = with(LocalDensity.current) { screenHeightDp.toPx() }
114
98
  val sheetOffset = remember { Animatable(screenHeightPx) }
115
99
 
100
+ // half the scrim fades in first, the other half follows the sheet
116
101
  val backgroundAlpha = remember { Animatable(0f) }
117
- val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.3f
118
- 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
119
104
 
120
105
  val sheetCloseOffset = with(LocalDensity.current) { 100.dp.toPx() }
121
106
 
@@ -140,7 +125,7 @@ internal fun BottomSheet(
140
125
 
141
126
  suspend fun openEvent(){
142
127
  backgroundAlpha.animateTo(
143
- targetValue = 0.3f,
128
+ targetValue = 0.5f,
144
129
  animationSpec = tween(
145
130
  durationMillis = 100,
146
131
  easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
@@ -202,40 +187,28 @@ internal fun BottomSheet(
202
187
  BoxWithConstraints(
203
188
  modifier = Modifier
204
189
  .fillMaxSize()
205
- .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))
206
192
  .noFeedbackClickable {
207
193
  if(barrierDismissible) closeEvent()
208
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
+ }
209
199
  ) {
210
200
  val parentHeight = with(LocalDensity.current) { constraints.maxHeight.toDp() }
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
201
+ val maxHeight = sheet.maxHeight ?: (parentHeight - 90.dp)
217
202
 
218
203
  Box(
219
204
  modifier = Modifier
220
205
  .align(Alignment.BottomCenter)
221
206
  .offset { IntOffset(x = 0, y = sheetOffset.value.toInt()) }
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
- )
207
+ .then(if (sheet.width != null) Modifier.width(sheet.width) else Modifier.fillMaxWidth())
235
208
  .heightIn(max = maxHeight)
236
209
  .background(
237
210
  color = if (isSurface) AppTheme.current.colors.background.surface else AppTheme.current.colors.background.default,
238
- shape = RoundedCornerShape(topStart = radius, topEnd = radius)
211
+ shape = RoundedCornerShape(topStart = sheet.radius, topEnd = sheet.radius)
239
212
  )
240
213
  .conditional(IsShowBaseLineDebug) {
241
214
  border(1.dp, Colors.blue_03)
@@ -246,7 +219,10 @@ internal fun BottomSheet(
246
219
  val bottomInset = if (useBottomInset) {
247
220
  (AppNavigationBar.current - keyboardSizeState().value).coerceAtLeast(0.dp)
248
221
  } else 0.dp
249
- Column(Modifier.padding(bottom = bottomInset)) {
222
+ Column(
223
+ modifier = Modifier.heightIn(min = sheet.minHeight).padding(bottom = bottomInset),
224
+ verticalArrangement = if (footerComponent != null) FooterAtBottom else Arrangement.Top,
225
+ ) {
250
226
  Box(
251
227
  modifier = Modifier
252
228
  .height(INDICATOR_HEIGHT + HEADER_ROW_HEIGHT)
@@ -279,7 +255,6 @@ internal fun BottomSheet(
279
255
  Column(
280
256
  modifier = Modifier
281
257
  .fillMaxSize()
282
- .padding(sidePadding)
283
258
  .padding(horizontal = Spacing.M),
284
259
  horizontalAlignment = Alignment.CenterHorizontally
285
260
  ) {
@@ -294,13 +269,14 @@ internal fun BottomSheet(
294
269
  )
295
270
  )
296
271
  Spacer(Modifier.height(4.dp))
297
- Box(Modifier.fillMaxWidth().height(HEADER_ROW_HEIGHT), contentAlignment = Alignment.Center){
272
+ Box(
273
+ Modifier.fillMaxWidth().height(HEADER_ROW_HEIGHT),
274
+ contentAlignment = Alignment.Center
275
+ ) {
298
276
  when (header) {
299
277
  is BottomHeader.Title -> BottomSheetTitle(
300
278
  text = header.data,
301
279
  backIcon = header.backIcon,
302
- // the side column holds back and close, the row keeps only the title
303
- showButtons = sideColumn == null,
304
280
  onBack = onBack,
305
281
  onClose = { closeEvent() },
306
282
  )
@@ -311,32 +287,21 @@ internal fun BottomSheet(
311
287
  }
312
288
  }
313
289
  }
314
- Box(Modifier.padding(sidePadding)) {
315
- Divider()
316
- }
290
+ Divider()
317
291
  if (footerComponent != null) {
318
- Box(Modifier.weight(1f, fill = false).padding(sidePadding)) {
292
+ Box(Modifier.weight(1f, fill = false)) {
319
293
  content()
320
294
  }
321
- BottomSheetFooter(footerComponent, sidePadding)
322
- } else if (isDuo) {
295
+ BottomSheetFooter(footerComponent)
296
+ } else if (isFoldable) {
323
297
  // content shrinks so a tall sheet keeps its header
324
- Box(Modifier.weight(1f, fill = false).padding(sidePadding)) {
298
+ Box(Modifier.weight(1f, fill = false)) {
325
299
  content()
326
300
  }
327
301
  } else {
328
302
  content()
329
303
  }
330
304
  }
331
- if (sideColumn != null && title != null) {
332
- BottomSheetSideColumn(
333
- sideBar = sideColumn,
334
- parentHeight = parentHeight,
335
- backIcon = title.backIcon,
336
- onBack = onBack,
337
- onClose = { closeEvent() },
338
- )
339
- }
340
305
  }
341
306
  }
342
307
  }
@@ -345,23 +310,23 @@ internal fun BottomSheet(
345
310
  private fun BottomSheetTitle(
346
311
  text: String,
347
312
  backIcon: String,
348
- showButtons: Boolean,
349
313
  onBack: (() -> Unit)?,
350
314
  onClose: () -> Unit,
351
315
  ) {
352
- Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
353
- if (showButtons) {
354
- if (onBack != null) {
355
- BottomSheetHeaderButton(icon = backIcon, automationId = "btn_bottom_sheet_back", onClick = onBack)
356
- } else {
357
- Box(Modifier.size(24.dp))
358
- }
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))
359
325
  }
360
326
  Box(
361
327
  Modifier
362
328
  .fillMaxHeight()
363
- .weight(1f)
364
- .conditional(!showButtons) { padding(horizontal = Spacing.M) },
329
+ .weight(1f),
365
330
  contentAlignment = Alignment.Center
366
331
  ) {
367
332
  Text(
@@ -370,82 +335,12 @@ private fun BottomSheetTitle(
370
335
  style = Typography.headerDefaultBold
371
336
  )
372
337
  }
373
- if (showButtons) {
374
- BottomSheetHeaderButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
375
- }
376
- }
377
- }
378
-
379
- @Composable
380
- private fun BottomSheetHeaderButton(icon: String, automationId: String, onClick: () -> Unit) {
381
- Box(
382
- Modifier
383
- .size(24.dp)
384
- .noFeedbackClickable(onClick = onClick)
385
- .setAutomationId(automationId),
386
- contentAlignment = Alignment.Center
387
- ) {
388
- Icon(source = icon)
389
- }
390
- }
391
-
392
- // iPhone Duo outer display: back and close sit on the part of the sheet under the side safe area,
393
- // 12pt from the strip's inner edge like the screen side bar. They follow the header row while the
394
- // sheet is short and stay below the status bar cluster while it is tall.
395
- @Composable
396
- private fun BoxScope.BottomSheetSideColumn(
397
- sideBar: SideBarLayout,
398
- parentHeight: Dp,
399
- backIcon: String,
400
- onBack: (() -> Unit)?,
401
- onClose: () -> Unit,
402
- ) {
403
- val isRight = sideBar.edge == SideBarEdge.RIGHT
404
- val headerColor = getHeaderColor(HeaderType.None, 1f, null, AppTheme.current.colors.text.default)
405
-
406
- Box(Modifier.matchParentSize()) {
407
- Column(
408
- modifier = Modifier
409
- .align(if (isRight) AbsoluteAlignment.TopRight else AbsoluteAlignment.TopLeft)
410
- .width(sideBar.width - Spacing.M)
411
- .layout { measurable, constraints ->
412
- val placeable = measurable.measure(constraints.copy(minHeight = 0))
413
- val sheetHeight = constraints.maxHeight
414
- // the sheet rests on the bottom of the overlay, which starts at the window top
415
- val sheetTop = parentHeight.roundToPx() - sheetHeight
416
- // clear of a camera at the bottom end of the strip when it can
417
- val lowest = sheetHeight - sideBar.bottom.roundToPx() - placeable.height
418
- val y = maxOf(sideBar.top.roundToPx() - sheetTop, SIDE_COLUMN_OFFSET.roundToPx())
419
- .coerceAtMost(lowest)
420
- .coerceAtLeast(0)
421
- layout(placeable.width, constraints.constrainHeight(y + placeable.height)) {
422
- placeable.place(0, y)
423
- }
424
- }
425
- .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M),
426
- horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
427
- verticalArrangement = Arrangement.spacedBy(Spacing.M),
428
- ) {
429
- if (onBack != null) {
430
- SideBarButton(
431
- icon = backIcon,
432
- headerColor = headerColor,
433
- automationId = "btn_bottom_sheet_back",
434
- onClick = onBack,
435
- )
436
- }
437
- SideBarButton(
438
- icon = "navigation_close",
439
- headerColor = headerColor,
440
- automationId = "btn_bottom_sheet_close",
441
- onClick = onClose,
442
- )
443
- }
338
+ ModalIconButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
444
339
  }
445
340
  }
446
341
 
447
342
  @Composable
448
- private fun BottomSheetFooter(footerComponent: @Composable () -> Unit, sidePadding: PaddingValues) {
343
+ private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
449
344
  val shadowBrush = remember {
450
345
  Brush.verticalGradient(
451
346
  colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
@@ -460,7 +355,6 @@ private fun BottomSheetFooter(footerComponent: @Composable () -> Unit, sidePaddi
460
355
  .conditional(IsShowBaseLineDebug) {
461
356
  border(1.dp, Colors.blue_03)
462
357
  }
463
- .padding(sidePadding)
464
358
  .padding(vertical = Spacing.S)
465
359
  ) {
466
360
  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
21
20
  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,9 +27,8 @@ 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
32
30
  import vn.momo.kits.layout.getScreenLayout
31
+ import vn.momo.kits.layout.rememberModalLayout
33
32
 
34
33
  @Composable
35
34
  internal fun ModalScreen(
@@ -106,21 +105,24 @@ internal fun ModalScreen(
106
105
  }
107
106
 
108
107
  val layout = getScreenLayout()
108
+ val modal = rememberModalLayout()
109
+ val placement = modal.placement
109
110
 
110
111
  Box(
111
112
  modifier = Modifier
112
113
  .fillMaxSize()
113
- .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))
114
116
  .noFeedbackClickable {
115
117
  if(barrierDismissible) closeEvent()
116
118
  }
117
- // center in the safe area, clear of the side toolbar strip and the home indicator
118
- .conditional(layout.isIPhoneDuoDevice) {
119
+ // center in the placement: the safe area, or the right half of a half-folded iPhone Duo
120
+ .conditional(modal.isFoldable) {
119
121
  absolutePadding(
120
- left = layout.insetLeft,
121
- top = layout.insetTop,
122
- right = layout.insetRight,
123
- bottom = layout.insetBottom,
122
+ left = placement.left,
123
+ top = placement.top,
124
+ right = layout.width - placement.right,
125
+ bottom = layout.height - placement.bottom,
124
126
  )
125
127
  },
126
128
  contentAlignment = Alignment.Center
@@ -129,8 +131,11 @@ internal fun ModalScreen(
129
131
  modifier = Modifier
130
132
  .scale(scale.value)
131
133
  .alpha(alpha.value)
132
- .conditional(layout.isIPhoneDuoDevice) {
133
- sizeIn(maxWidth = layout.duoModalMaxWidth, maxHeight = layout.duoModalMaxHeight)
134
+ .conditional(modal.isFoldable) {
135
+ sizeIn(
136
+ maxWidth = modal.popup.maxWidth,
137
+ maxHeight = modal.popup.maxHeight ?: placement.height,
138
+ )
134
139
  }
135
140
  .wrapContentSize()
136
141
  .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,
@@ -30,12 +30,11 @@ import vn.momo.kits.const.AppNavigationBar
30
30
  import vn.momo.kits.const.AppStatusBar
31
31
  import vn.momo.kits.const.AppTheme
32
32
  import vn.momo.kits.const.Theme
33
- import vn.momo.kits.const.ProvideKitScale
34
33
  import vn.momo.kits.const.defaultTheme
35
- import vn.momo.kits.const.pendingSizeScale
36
34
  import vn.momo.kits.layout.LocalScreenLayout
37
35
  import vn.momo.kits.layout.calculateScreenLayout
38
36
  import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
37
+ import vn.momo.kits.platform.ProvideOsFontScale
39
38
  import vn.momo.kits.utils.getAppStatusBarHeight
40
39
  import vn.momo.kits.utils.getNavigationBarHeight
41
40
  import vn.momo.maxapi.IMaxApi
@@ -57,9 +56,9 @@ fun NavigationContainer(
57
56
  val navController = rememberNavController()
58
57
  val registry = remember { DynamicScreenRegistry() }
59
58
  val navigator = remember { Navigator(navController = navController, maxApi = maxApi, registry = registry) }
60
- val sizeScale = pendingSizeScale()
61
- val statusBarHeight = (statusBarHeight ?: getAppStatusBarHeight()) / sizeScale
62
- val navigationBarHeight = getNavigationBarHeight() / sizeScale
59
+ val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
60
+ val navigationBarHeight = getNavigationBarHeight()
61
+ val screenLayout = calculateScreenLayout(statusBarHeight, parent = LocalScreenLayout.current)
63
62
 
64
63
  val parentContext = LocalContext.current
65
64
  val mergedContext = MiniAppContext.merge(parentContext, miniAppContext)
@@ -96,8 +95,7 @@ fun NavigationContainer(
96
95
  registry.bind(screenId, initialScreenName, initialScreen, options)
97
96
  val startDestination = remember(screenId) { DynamicScreenRoute(screenId) }
98
97
 
99
- ProvideKitScale {
100
- val screenLayout = calculateScreenLayout(statusBarHeight, parent = LocalScreenLayout.current)
98
+ ProvideOsFontScale {
101
99
  ProvideNavigationEventDispatcherOwner(navigator) {
102
100
  CompositionLocalProvider(
103
101
  LocalNavigator provides navigator,
@@ -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,