@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.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 (202) hide show
  1. package/CLAUDE.md +12 -8
  2. package/README.md +8 -7
  3. package/compose/build.gradle.kts +2 -4
  4. package/compose/build.gradle.kts.backup +1 -3
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
  84. package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
  85. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
  86. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
  87. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
  88. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
  89. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
  90. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
  91. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  92. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
  93. package/gradle/libs.versions.toml +1 -3
  94. package/gradle.properties +1 -3
  95. package/ios/Application/ApplicationEnvironment.swift +6 -4
  96. package/ios/Application/DesignSystemKits.swift +59 -13
  97. package/ios/Application/DesignSystemKitsPayload.swift +0 -8
  98. package/ios/Application/LanguageSource.swift +2 -11
  99. package/ios/Application/Localize.swift +8 -35
  100. package/ios/Application/LocalizeModifier.swift +2 -11
  101. package/ios/Application/MaxApi.swift +3 -11
  102. package/ios/Avatar/Avatar.swift +0 -1
  103. package/ios/Badge/Badge.swift +5 -8
  104. package/ios/Badge/BadgeRibbon.swift +2 -5
  105. package/ios/Button/Button.swift +4 -8
  106. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
  107. package/ios/Carousel/Carousel.swift +4 -17
  108. package/ios/Checkbox/Checkbox.swift +0 -2
  109. package/ios/Collapse/Collapse.swift +17 -11
  110. package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
  111. package/ios/DateTimePicker/DateTimePicker.swift +4 -10
  112. package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
  113. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
  114. package/ios/DateTimePicker/WheelPicker.swift +2 -4
  115. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  116. package/ios/Extensions/Color++.swift +2 -4
  117. package/ios/Extensions/SkeletonUICompat.swift +0 -8
  118. package/ios/Icon/Icon.swift +3 -6
  119. package/ios/IconButton/IconButton.swift +2 -5
  120. package/ios/Input/ErrorView.swift +0 -7
  121. package/ios/Input/Input.swift +9 -20
  122. package/ios/Input/InputPhoneNumber.swift +37 -20
  123. package/ios/Input/InputSearch.swift +23 -12
  124. package/ios/Input/InputTextArea.swift +4 -13
  125. package/ios/InputDropDown/InputDropDown.swift +1 -11
  126. package/ios/InputMoney/InputMoney.swift +9 -28
  127. package/ios/InputOTP/InputOTP.swift +2 -9
  128. package/ios/Layout/HeaderLayout.swift +72 -0
  129. package/ios/Layout/Item.swift +1 -2
  130. package/ios/Layout/ModalLayout.swift +144 -0
  131. package/ios/Layout/ScreenLayout.swift +48 -31
  132. package/ios/Layout/Section.swift +2 -3
  133. package/ios/Loader/Loader.swift +3 -12
  134. package/ios/Lottie/LottieView.swift +0 -11
  135. package/ios/Navigation/BottomSheet.swift +73 -94
  136. package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
  137. package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
  138. package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
  139. package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
  140. package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
  141. package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
  142. package/ios/Navigation/Component/FloatingButton.swift +4 -11
  143. package/ios/Navigation/Component/Header.swift +35 -54
  144. package/ios/Navigation/Component/HeaderBackground.swift +2 -8
  145. package/ios/Navigation/Component/HeaderJourney.swift +4 -8
  146. package/ios/Navigation/Component/HeaderLocation.swift +4 -8
  147. package/ios/Navigation/Component/HeaderRight.swift +20 -22
  148. package/ios/Navigation/Component/HeaderTitle.swift +1 -6
  149. package/ios/Navigation/Component/HeaderUser.swift +4 -10
  150. package/ios/Navigation/Component/SideBar.swift +6 -21
  151. package/ios/Navigation/Component/SnackBar.swift +9 -13
  152. package/ios/Navigation/HostBackGestureBridge.swift +2 -9
  153. package/ios/Navigation/ModalScreen.swift +24 -13
  154. package/ios/Navigation/Navigation.swift +35 -19
  155. package/ios/Navigation/NavigationContainer.swift +4 -15
  156. package/ios/Navigation/Navigator.swift +21 -39
  157. package/ios/Navigation/StackScreen.swift +64 -51
  158. package/ios/Navigation/StackTransition.swift +7 -14
  159. package/ios/Navigation/SwipeBackHaptic.swift +2 -7
  160. package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
  161. package/ios/Pagination/PaginationDot.swift +0 -9
  162. package/ios/Pagination/PaginationNumber.swift +1 -9
  163. package/ios/Pagination/PaginationScroll.swift +2 -14
  164. package/ios/Pagination/PaginationWhiteDot.swift +1 -10
  165. package/ios/Popup/PopupDisplay.swift +7 -5
  166. package/ios/Popup/PopupInput.swift +6 -4
  167. package/ios/Popup/PopupLayout.swift +17 -9
  168. package/ios/Popup/PopupNotify.swift +32 -25
  169. package/ios/PopupView/FullscreenPopup.swift +3 -4
  170. package/ios/PopupView/PopupView.swift +2 -2
  171. package/ios/PopupView/Utils++.swift +1 -2
  172. package/ios/ProgressInfo/ProgressInfo.swift +2 -13
  173. package/ios/Skeleton/Skeleton.swift +5 -16
  174. package/ios/Slider/Slider.swift +5 -12
  175. package/ios/StatusBarTap/StatusBarTap.h +2 -3
  176. package/ios/StatusBarTap/StatusBarTap.m +3 -16
  177. package/ios/Stepper/Stepper.swift +8 -27
  178. package/ios/Steps/Steps.swift +29 -26
  179. package/ios/Swipeable/SwipeCell.swift +2 -2
  180. package/ios/Swipeable/SwipeCellModel.swift +3 -6
  181. package/ios/TabView/TabView.swift +14 -28
  182. package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
  183. package/ios/Title/Title.swift +1 -3
  184. package/ios/Tooltip/Tooltip.swift +4 -9
  185. package/ios/Typography/FontScale.swift +79 -24
  186. package/ios/Typography/Text.swift +6 -12
  187. package/ios/Typography/Typography.swift +8 -11
  188. package/ios/Uploader/Uploader.swift +2 -17
  189. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  190. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  191. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
  192. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
  193. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
  194. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
  195. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
  196. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  197. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
  198. package/package.json +1 -1
  199. package/publish.sh +8 -2
  200. package/scripts/ci/build-swiftui.sh +22 -0
  201. package/scripts/ci/resolve-version.mjs +144 -0
  202. package/settings.gradle.kts +0 -1
@@ -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,19 +26,23 @@ 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
36
+ import androidx.compose.ui.draw.clip
32
37
  import androidx.compose.ui.graphics.Brush
33
38
  import androidx.compose.ui.graphics.Color
34
39
  import androidx.compose.ui.input.pointer.pointerInput
35
40
  import androidx.compose.ui.platform.LocalDensity
41
+ import androidx.compose.ui.unit.Density
36
42
  import androidx.compose.ui.unit.IntOffset
37
43
  import androidx.compose.ui.unit.dp
38
44
  import kotlinx.coroutines.launch
39
45
  import vn.momo.kits.components.Divider
40
- import vn.momo.kits.components.Icon
41
46
  import vn.momo.kits.components.Text
42
47
  import vn.momo.kits.const.AppTheme
43
48
  import vn.momo.kits.const.Colors
@@ -52,10 +57,25 @@ import vn.momo.kits.modifier.conditional
52
57
  import vn.momo.kits.modifier.noFeedbackClickable
53
58
  import vn.momo.kits.platform.BackHandler
54
59
  import vn.momo.kits.platform.getScreenHeight
60
+ import vn.momo.kits.layout.MODAL_ICON_BUTTON_SIZE
61
+ import vn.momo.kits.layout.ModalIconButton
55
62
  import vn.momo.kits.layout.getScreenLayout
63
+ import vn.momo.kits.layout.rememberModalLayout
56
64
 
57
- // iPhone Duo inner display: center the sheet instead of spanning the width (RN BottomSheet).
58
- private val DUO_REGULAR_MIN_WIDTH = 600.dp
65
+ private val INDICATOR_HEIGHT = 16.dp
66
+ private val HEADER_ROW_HEIGHT = 56.dp
67
+
68
+ // A sheet held at its min height keeps the footer at the bottom; the room goes above it.
69
+ private object FooterAtBottom : Arrangement.Vertical {
70
+ override fun Density.arrange(totalSize: Int, sizes: IntArray, outPositions: IntArray) {
71
+ var y = 0
72
+ sizes.forEachIndexed { index, size ->
73
+ outPositions[index] = y
74
+ y += size
75
+ }
76
+ if (sizes.isNotEmpty()) outPositions[sizes.lastIndex] = maxOf(y - sizes.last(), totalSize - sizes.last())
77
+ }
78
+ }
59
79
 
60
80
  @Composable
61
81
  internal fun BottomSheet(
@@ -69,41 +89,51 @@ internal fun BottomSheet(
69
89
  onDismiss: (() -> Unit)?
70
90
  ) {
71
91
  val layout = getScreenLayout()
72
- val isDuo = layout.isIPhoneDuoDevice
73
- val isDuoCentered = isDuo && layout.width >= DUO_REGULAR_MIN_WIDTH
92
+ val modal = rememberModalLayout()
93
+ val isFoldable = modal.isFoldable
94
+ val sheet = modal.sheet
95
+ val sheetShape = RoundedCornerShape(topStart = sheet.radius, topEnd = sheet.radius)
96
+ val title = header as? BottomHeader.Title
74
97
  // the screen is the outer display on iPhone Duo, even when unfolded
75
- val screenHeightDp = if (isDuo) layout.height else getScreenHeight()
98
+ val screenHeightDp = if (isFoldable) layout.height else getScreenHeight()
76
99
  val screenHeightPx = with(LocalDensity.current) { screenHeightDp.toPx() }
77
100
  val sheetOffset = remember { Animatable(screenHeightPx) }
78
101
 
102
+ // half the scrim fades in first, the other half follows the sheet
79
103
  val backgroundAlpha = remember { Animatable(0f) }
80
- val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.3f
81
- val alpha = backgroundAlpha.value + dynamicAlpha
104
+ val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.5f
105
+ val alpha = (backgroundAlpha.value + dynamicAlpha) * modal.scrimOpacity
82
106
 
83
107
  val sheetCloseOffset = with(LocalDensity.current) { 100.dp.toPx() }
84
108
 
85
109
  val coroutineScope = rememberCoroutineScope()
86
110
 
87
- val maxApi = LocalMaxApi.current
111
+ val binding = LocalKitsBinding.current
88
112
  val context = LocalContext.current
89
113
 
90
114
  DisposableEffect(Unit) {
91
115
  ScreenTracker.trackPopupDisplayed(
92
- maxApi = maxApi,
116
+ binding = binding,
93
117
  context = context,
94
118
  parentScreenName = ScreenTracker.getLastScreenName()
95
119
  )
96
120
  onDispose { }
97
121
  }
98
122
 
123
+ // a closing sheet keeps going: a second close, the open slide or a drag would cancel its animation
124
+ var isClosing by remember { mutableStateOf(false) }
125
+ // runs once the sheet has closed itself, after its onDismiss
126
+ var afterDismiss by remember { mutableStateOf<(() -> Unit)?>(null) }
127
+
99
128
  suspend fun openEvent(){
100
129
  backgroundAlpha.animateTo(
101
- targetValue = 0.3f,
130
+ targetValue = 0.5f,
102
131
  animationSpec = tween(
103
132
  durationMillis = 100,
104
133
  easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
105
134
  )
106
135
  )
136
+ if (isClosing) return
107
137
  sheetOffset.animateTo(
108
138
  targetValue = 0f,
109
139
  animationSpec = tween(
@@ -113,7 +143,9 @@ internal fun BottomSheet(
113
143
  )
114
144
  }
115
145
 
116
- fun closeEvent(){
146
+ fun closeEvent(then: (() -> Unit)? = null){
147
+ if (isClosing) return
148
+ isClosing = true
117
149
  coroutineScope.launch {
118
150
  sheetOffset.animateTo(
119
151
  targetValue = screenHeightPx,
@@ -129,10 +161,15 @@ internal fun BottomSheet(
129
161
  easing = CubicBezierEasing(0.3f, 0.0f, 0.8f, 0.15f)
130
162
  )
131
163
  )
164
+ // not reached when a newer overlay replaced this one, so its back is dropped
165
+ afterDismiss = then
132
166
  OverplayComponentRegistry.hardClearAfterDismiss()
133
167
  }
134
168
  }
135
169
 
170
+ // RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs
171
+ val onBack = title?.onBack?.let { back -> { closeEvent(then = back) } }
172
+
136
173
  LaunchedEffect(Unit) {
137
174
  openEvent()
138
175
  }
@@ -141,6 +178,7 @@ internal fun BottomSheet(
141
178
  OverplayComponentRegistry.bindClose { closeEvent() }
142
179
  onDispose {
143
180
  onDismiss?.invoke()
181
+ afterDismiss?.invoke()
144
182
  }
145
183
  }
146
184
 
@@ -151,41 +189,30 @@ internal fun BottomSheet(
151
189
  BoxWithConstraints(
152
190
  modifier = Modifier
153
191
  .fillMaxSize()
154
- .background(Color.Black.copy(alpha = alpha))
192
+ // full screen on foldables too, over the iPhone Duo control column
193
+ .background(Colors.black_20.copy(alpha = alpha))
155
194
  .noFeedbackClickable {
156
195
  if(barrierDismissible) closeEvent()
157
196
  }
197
+ // centered in the placement: off the iPhone Duo control column, the right half when half folded
198
+ .conditional(isFoldable) {
199
+ absolutePadding(left = modal.placement.left, right = layout.width - modal.placement.right)
200
+ }
158
201
  ) {
159
202
  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
203
+ val maxHeight = sheet.maxHeight ?: (parentHeight - 90.dp)
167
204
 
168
205
  Box(
169
206
  modifier = Modifier
170
207
  .align(Alignment.BottomCenter)
171
208
  .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
- )
209
+ .then(if (sheet.width != null) Modifier.width(sheet.width) else Modifier.fillMaxWidth())
185
210
  .heightIn(max = maxHeight)
211
+ // clip too, so content (images, scrims) follows the corners like iOS clipShape
212
+ .clip(sheetShape)
186
213
  .background(
187
214
  color = if (isSurface) AppTheme.current.colors.background.surface else AppTheme.current.colors.background.default,
188
- shape = RoundedCornerShape(topStart = Radius.M, topEnd = Radius.M)
215
+ shape = sheetShape
189
216
  )
190
217
  .conditional(IsShowBaseLineDebug) {
191
218
  border(1.dp, Colors.blue_03)
@@ -197,27 +224,26 @@ internal fun BottomSheet(
197
224
  (AppNavigationBar.current - keyboardSizeState().value).coerceAtLeast(0.dp)
198
225
  } else 0.dp
199
226
  Column(
200
- Modifier
201
- .padding(bottom = bottomInset)
202
- .conditional(sideInset) {
203
- absolutePadding(left = layout.insetLeft, right = layout.insetRight)
204
- }
227
+ modifier = Modifier.heightIn(min = sheet.minHeight).padding(bottom = bottomInset),
228
+ verticalArrangement = if (footerComponent != null) FooterAtBottom else Arrangement.Top,
205
229
  ) {
206
230
  Box(
207
231
  modifier = Modifier
208
- .height(72.dp)
232
+ .height(INDICATOR_HEIGHT + HEADER_ROW_HEIGHT)
209
233
  .fillMaxWidth()
210
234
  .conditional(draggable) {
211
235
  pointerInput(Unit) {
212
236
  detectDragGestures(
213
237
  onDrag = { change, dragAmount ->
214
238
  change.consume()
239
+ if (isClosing) return@detectDragGestures
215
240
  coroutineScope.launch {
216
241
  val newOffset = (sheetOffset.value + dragAmount.y).coerceAtLeast(0f)
217
242
  sheetOffset.snapTo(newOffset)
218
243
  }
219
244
  },
220
245
  onDragEnd = {
246
+ if (isClosing) return@detectDragGestures
221
247
  coroutineScope.launch {
222
248
  if (sheetOffset.value > sheetCloseOffset) {
223
249
  closeEvent()
@@ -247,29 +273,17 @@ internal fun BottomSheet(
247
273
  )
248
274
  )
249
275
  Spacer(Modifier.height(4.dp))
250
- Box(Modifier.fillMaxWidth().height(56.dp), contentAlignment = Alignment.Center){
276
+ Box(
277
+ Modifier.fillMaxWidth().height(HEADER_ROW_HEIGHT),
278
+ contentAlignment = Alignment.Center
279
+ ) {
251
280
  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
- }
281
+ is BottomHeader.Title -> BottomSheetTitle(
282
+ text = header.data,
283
+ backIcon = header.backIcon,
284
+ onBack = onBack,
285
+ onClose = { closeEvent() },
286
+ )
273
287
  is BottomHeader.Custom -> {
274
288
  header.content()
275
289
  }
@@ -283,7 +297,7 @@ internal fun BottomSheet(
283
297
  content()
284
298
  }
285
299
  BottomSheetFooter(footerComponent)
286
- } else if (isDuo) {
300
+ } else if (isFoldable) {
287
301
  // content shrinks so a tall sheet keeps its header
288
302
  Box(Modifier.weight(1f, fill = false)) {
289
303
  content()
@@ -296,6 +310,39 @@ internal fun BottomSheet(
296
310
  }
297
311
  }
298
312
 
313
+ @Composable
314
+ private fun BottomSheetTitle(
315
+ text: String,
316
+ backIcon: String,
317
+ onBack: (() -> Unit)?,
318
+ onClose: () -> Unit,
319
+ ) {
320
+ Row(
321
+ modifier = Modifier.fillMaxSize(),
322
+ horizontalArrangement = Arrangement.spacedBy(Spacing.S),
323
+ verticalAlignment = Alignment.CenterVertically,
324
+ ) {
325
+ if (onBack != null) {
326
+ ModalIconButton(icon = backIcon, automationId = "btn_bottom_sheet_back", onClick = onBack)
327
+ } else {
328
+ Box(Modifier.size(MODAL_ICON_BUTTON_SIZE))
329
+ }
330
+ Box(
331
+ Modifier
332
+ .fillMaxHeight()
333
+ .weight(1f),
334
+ contentAlignment = Alignment.Center
335
+ ) {
336
+ Text(
337
+ text = text,
338
+ color = Colors.black_17,
339
+ style = Typography.headerDefaultBold
340
+ )
341
+ }
342
+ ModalIconButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
343
+ }
344
+ }
345
+
299
346
  @Composable
300
347
  private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
301
348
  val shadowBrush = remember {
@@ -330,7 +377,19 @@ private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
330
377
  sealed class BottomHeader {
331
378
  data class Title(
332
379
  val data: String = "Bottom Sheet Title",
333
- ) : BottomHeader()
380
+ ) : BottomHeader() {
381
+ // Outside the primary constructor so code built against older kits keeps Title() and copy().
382
+ // onBack shows a back button: the sheet closes (onDismiss fires), then it runs.
383
+ var onBack: (() -> Unit)? = null
384
+ private set
385
+ var backIcon: String = "arrow-back"
386
+ private set
387
+
388
+ constructor(data: String, onBack: (() -> Unit)?, backIcon: String = "arrow-back") : this(data) {
389
+ this.onBack = onBack
390
+ this.backIcon = backIcon
391
+ }
392
+ }
334
393
 
335
394
  data class Custom(
336
395
  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(
@@ -41,12 +43,12 @@ internal fun ModalScreen(
41
43
 
42
44
  val coroutineScope = rememberCoroutineScope()
43
45
 
44
- val maxApi = LocalMaxApi.current
46
+ val binding = LocalKitsBinding.current
45
47
  val context = LocalContext.current
46
48
 
47
49
  DisposableEffect(Unit) {
48
50
  ScreenTracker.trackPopupDisplayed(
49
- maxApi = maxApi,
51
+ binding = binding,
50
52
  context = context,
51
53
  parentScreenName = ScreenTracker.getLastScreenName()
52
54
  )
@@ -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)
@@ -3,6 +3,7 @@ package vn.momo.kits.navigation
3
3
  import androidx.compose.foundation.gestures.ScrollableState
4
4
  import androidx.compose.runtime.*
5
5
  import androidx.compose.ui.graphics.Color
6
+ import vn.momo.kits.layout.ContentLayout
6
7
  import vn.momo.kits.navigation.bottomtab.setBottomTabOption
7
8
  import vn.momo.kits.navigation.component.*
8
9
 
@@ -20,6 +21,10 @@ class Navigation(
20
21
  internal val isBottomTabRoot: Boolean get() = _isBottomTabRoot.value
21
22
  internal fun markAsBottomTabRoot() { _isBottomTabRoot.value = true }
22
23
 
24
+ // A self-scrolling tab asks (via floatingTabBarContentPadding) to run edge to edge behind the
25
+ // floating bar; the kit then stops reserving the bar space as outer padding. Not in NavigationOptions.
26
+ internal var bottomTabEdgeToEdge by mutableStateOf(false)
27
+
23
28
  fun setOptions(
24
29
  onBackHandler: (() -> Unit)? = null,
25
30
  hiddenBack: Boolean? = null,
@@ -30,15 +35,14 @@ class Navigation(
30
35
  headerType: HeaderType? = null,
31
36
  scrollData: ScrollData? = null,
32
37
  backgroundColor: Color? = null,
33
- // AI-GENERATED START: custom screen background
34
38
  backgroundComponent: (@Composable () -> Unit)? = null,
35
- // AI-GENERATED END: custom screen background
36
39
  tintColor: Color? = null,
37
40
  footerComponent: (@Composable () -> Unit)? = null,
38
41
  footerTransparent: Boolean? = null,
39
42
  footerUseMargin: Boolean? = null,
40
43
  floatingButtonProps: FloatingButtonProps? = null,
41
- keyboardOptions: KeyboardOptions? = null
44
+ keyboardOptions: KeyboardOptions? = null,
45
+ contentLayout: ContentLayout? = null,
42
46
  ) {
43
47
  updateOptions(
44
48
  options.copy(
@@ -51,15 +55,14 @@ class Navigation(
51
55
  headerType = headerType ?: options.headerType,
52
56
  scrollData = scrollData ?: options.scrollData,
53
57
  backgroundColor = backgroundColor ?: options.backgroundColor,
54
- // AI-GENERATED START: custom screen background
55
58
  backgroundComponent = backgroundComponent ?: options.backgroundComponent,
56
- // AI-GENERATED END: custom screen background
57
59
  tintColor = tintColor ?: options.tintColor,
58
60
  footerComponent = footerComponent ?: options.footerComponent,
59
61
  footerTransparent = footerTransparent ?: options.footerTransparent,
60
62
  footerUseMargin = footerUseMargin ?: options.footerUseMargin,
61
63
  floatingButtonProps = floatingButtonProps ?: options.floatingButtonProps,
62
64
  keyboardOptions = keyboardOptions ?: options.keyboardOptions,
65
+ contentLayout = contentLayout ?: options.contentLayout,
63
66
  )
64
67
  )
65
68
  }
@@ -91,16 +94,15 @@ data class NavigationOptions(
91
94
  val headerType: HeaderType = HeaderType.Default(),
92
95
  val scrollData: ScrollData = ScrollData(),
93
96
  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
97
  val backgroundComponent: @Composable (() -> Unit)? = null,
97
- // AI-GENERATED END: custom screen background (SwiftUI `NavigationOptions.background`)
98
98
  val tintColor: Color? = null,
99
99
  val footerComponent: @Composable (() -> Unit)? = null,
100
100
  val footerTransparent: Boolean = false,
101
101
  val footerUseMargin: Boolean = true,
102
102
  val floatingButtonProps: FloatingButtonProps? = null,
103
- val keyboardOptions: KeyboardOptions = KeyboardOptions()
103
+ val keyboardOptions: KeyboardOptions = KeyboardOptions(),
104
+ // Wide windows: Stretch puts the header row in the centered 600pt content frame.
105
+ val contentLayout: ContentLayout = ContentLayout.Grid,
104
106
  ) {
105
107
  internal fun hasFooter() : Boolean = footerComponent != null
106
108
  }
@@ -37,17 +37,15 @@ 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
- import vn.momo.maxapi.IMaxApi
42
- import vn.momo.maxapi.runtime.ApiResult
43
- // AI-GENERATED END: consume typed NativeMaxApi results
40
+ import vn.momo.kits.application.KitsBinding
41
+ import vn.momo.kits.application.KitsHost
44
42
  import kotlin.time.Duration.Companion.milliseconds
45
43
 
46
44
  @Composable
47
45
  fun NavigationContainer(
48
46
  initialScreenName: String,
49
47
  initialScreen: @Composable () -> Unit,
50
- maxApi: IMaxApi,
48
+ binding: KitsBinding? = null,
51
49
  options: NavigationOptions? = null,
52
50
  initialTheme: Theme = defaultTheme,
53
51
  miniAppContext: MiniAppContext? = null,
@@ -56,11 +54,13 @@ fun NavigationContainer(
56
54
  localize: Localize? = null,
57
55
  designSystemConfig: DesignSystemConfig? = null,
58
56
  ) {
57
+ // An explicit binding wins, then an enclosing container's, then the one the host installed.
58
+ val kitsBinding = binding ?: LocalKitsBinding.current ?: KitsHost.binding
59
59
  val navController = rememberNavController()
60
60
  val registry = remember { DynamicScreenRegistry() }
61
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)
62
+ val navigator = remember(navController, kitsBinding, registry) {
63
+ Navigator(navController = navController, binding = kitsBinding, registry = registry)
64
64
  }
65
65
  // AI-GENERATED END: retain the current host client after recomposition
66
66
  val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
@@ -72,8 +72,9 @@ fun NavigationContainer(
72
72
 
73
73
  val stackTransition = remember { StackTransitionCoordinator() }
74
74
  val theme = remember { mutableStateOf(initialTheme) }
75
- val resolvedDesignSystemConfig =
76
- designSystemConfig ?: LocalDesignSystemConfig.current ?: DesignSystemKits.getConfigs().designSystemConfig
75
+ val resolvedDesignSystemConfig = designSystemConfig
76
+ ?: LocalDesignSystemConfig.current
77
+ ?: DesignSystemKits.getConfigs().designSystemConfig
77
78
  val headerBar = resolvedDesignSystemConfig?.headerBar
78
79
  // RN parity: the theme's own header image wins; config headerBar is only the fallback.
79
80
  val resolvedTheme = remember(theme.value, headerBar) {
@@ -87,15 +88,12 @@ fun NavigationContainer(
87
88
 
88
89
  val resolvedLocalize = localize ?: fallbackLocalize
89
90
 
90
- // AI-GENERATED START: cancel language delivery when its composition owner changes
91
- DisposableEffect(maxApi, resolvedLocalize) {
92
- val api = maxApi
91
+ DisposableEffect(kitsBinding, resolvedLocalize) {
93
92
  val target = resolvedLocalize
94
93
  var active = true
95
94
  val handle = runCatching {
96
- api.getLanguage { result ->
97
- if (active && result is ApiResult.Success &&
98
- result.value.trim().lowercase().startsWith(Localize.EN)) {
95
+ kitsBinding.getLanguage { language ->
96
+ if (active && language.trim().lowercase().startsWith(Localize.EN)) {
99
97
  target.changeLanguage(Localize.EN)
100
98
  }
101
99
  }
@@ -105,7 +103,6 @@ fun NavigationContainer(
105
103
  handle?.cancel()
106
104
  }
107
105
  }
108
- // AI-GENERATED END: cancel language delivery when its composition owner changes
109
106
 
110
107
  val screenId = rememberSaveable { registry.nextId() }
111
108
  registry.bind(screenId, initialScreenName, initialScreen, options)
@@ -116,7 +113,7 @@ fun NavigationContainer(
116
113
  CompositionLocalProvider(
117
114
  LocalNavigator provides navigator,
118
115
  LocalDynamicScreenRegistry provides registry,
119
- LocalMaxApi provides maxApi,
116
+ LocalKitsBinding provides kitsBinding,
120
117
  AppTheme provides resolvedTheme,
121
118
  AppStatusBar provides statusBarHeight,
122
119
  AppNavigationBar provides navigationBarHeight,
@@ -130,7 +127,7 @@ fun NavigationContainer(
130
127
  setNavigator?.invoke(navigator)
131
128
  }
132
129
 
133
- SwipeBackHaptic(maxApi)
130
+ SwipeBackHaptic(kitsBinding)
134
131
 
135
132
  LaunchedEffect(navController, registry) {
136
133
  navController.currentBackStack.collectLatest { entries ->
@@ -211,5 +208,5 @@ fun NavigationContainer(
211
208
  }
212
209
  }
213
210
 
214
- val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> { null }
211
+ val LocalKitsBinding = staticCompositionLocalOf<KitsBinding?> { null }
215
212