@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
@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.width
15
15
  import androidx.compose.foundation.shape.CircleShape
16
16
  import androidx.compose.foundation.shape.RoundedCornerShape
17
17
  import androidx.compose.runtime.Composable
18
+ import androidx.compose.runtime.CompositionLocalProvider
18
19
  import androidx.compose.runtime.LaunchedEffect
19
20
  import androidx.compose.ui.AbsoluteAlignment
20
21
  import androidx.compose.ui.Alignment
@@ -52,10 +53,18 @@ internal fun BoxScope.HeaderSideBar(bottomInset: Dp, modifier: Modifier = Modifi
52
53
  val navigator = LocalNavigator.current
53
54
  val screenLayout = getScreenLayout()
54
55
  val sideBar = screenLayout.sideBar ?: return
55
- val toolkit = options.headerRight as? HeaderRight.Toolkit
56
- val empty = options.headerType == HeaderType.None || (options.hiddenBack && toolkit == null)
56
+ val headerRight = options.headerRight
57
+ val toolkit = headerRight as? HeaderRight.Toolkit
58
+ // a custom header right also lives in the side column on Duo, where the toolkit does
59
+ val hasRight = toolkit != null || headerRight is HeaderRight.Custom
60
+ val empty = options.headerType == HeaderType.None || (options.hiddenBack && !hasRight)
57
61
  val compression = LocalDuoBarCompression.current
58
- val fullHeight = if (empty) 0.dp else DuoMetrics.controlSize + (toolkit?.let { Spacing.M + toolkitColumnHeight(it) } ?: 0.dp)
62
+ val rightHeight = toolkit?.let { toolkitColumnHeight(it) }
63
+ ?: if (headerRight is HeaderRight.Custom) DuoMetrics.controlSize else 0.dp
64
+ // with the back button hidden the header right rises to the top of the column, so drop the back slot and its gap
65
+ val backHeight = if (options.hiddenBack) 0.dp else DuoMetrics.controlSize
66
+ val gap = if (!options.hiddenBack && hasRight) Spacing.M else 0.dp
67
+ val fullHeight = if (empty) 0.dp else backHeight + gap + (if (hasRight) rightHeight else 0.dp)
59
68
  LaunchedEffect(fullHeight, compression.setToolbarHeight) { compression.setToolbarHeight(fullHeight) }
60
69
  if (empty) return
61
70
 
@@ -78,10 +87,7 @@ internal fun BoxScope.HeaderSideBar(bottomInset: Dp, modifier: Modifier = Modifi
78
87
  horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
79
88
  verticalArrangement = Arrangement.spacedBy(Spacing.M),
80
89
  ) {
81
- if (options.hiddenBack) {
82
- // keep the slot so the toolkit does not jump between root and pushed screens
83
- Spacer(Modifier.size(DuoMetrics.controlSize))
84
- } else {
90
+ if (!options.hiddenBack) {
85
91
  SideBarButton(
86
92
  icon = "arrow-back",
87
93
  headerColor = headerColor,
@@ -90,7 +96,13 @@ internal fun BoxScope.HeaderSideBar(bottomInset: Dp, modifier: Modifier = Modifi
90
96
  )
91
97
  }
92
98
  when {
93
- toolkit == null || compression.toolbarHidden -> Unit
99
+ !hasRight || compression.toolbarHidden -> Unit
100
+ // a custom header right follows the header colors, centered on the control lane so it lines up with the back button
101
+ toolkit == null -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
102
+ Box(Modifier.width(DuoMetrics.controlSize), contentAlignment = Alignment.Center) {
103
+ HeaderRight(headerRight, options.tintColor, headerColor)
104
+ }
105
+ }
94
106
  // HIG "Toolbar compressed": tools fold into one button, distinct from the useMore icon
95
107
  compression.toolbarCompressed -> SideBarButton(
96
108
  icon = "navigation_menu",
@@ -138,25 +150,18 @@ internal fun SideBarButton(
138
150
  }
139
151
  }
140
152
 
141
- // Capsule grouping related controls, one item per 50pt: vertical in the side bar, horizontal on a header row.
153
+ // Vertical capsule grouping related side bar controls, one item per 50pt.
142
154
  @Composable
143
155
  internal fun SideBarGroup(
144
156
  headerColor: HeaderColor,
145
157
  itemCount: Int,
146
- horizontal: Boolean = false,
147
158
  content: @Composable (itemModifier: Modifier) -> Unit,
148
159
  ) {
149
160
  val length = if (itemCount > 1) DuoMetrics.itemPitch * itemCount else DuoMetrics.controlSize
150
161
  val item = length / itemCount.coerceAtLeast(1)
151
162
  val glass = Modifier.sideBarGlass(headerColor, RoundedCornerShape(Radius.XL))
152
- if (horizontal) {
153
- Row(Modifier.size(width = length, height = DuoMetrics.controlSize).then(glass)) {
154
- content(Modifier.size(width = item, height = DuoMetrics.controlSize))
155
- }
156
- } else {
157
- Column(Modifier.size(width = DuoMetrics.controlSize, height = length).then(glass)) {
158
- content(Modifier.size(width = DuoMetrics.controlSize, height = item))
159
- }
163
+ Column(Modifier.size(width = DuoMetrics.controlSize, height = length).then(glass)) {
164
+ content(Modifier.size(width = DuoMetrics.controlSize, height = item))
160
165
  }
161
166
  }
162
167
 
@@ -180,13 +185,13 @@ internal fun SideBarGroupItem(
180
185
 
181
186
  // Dark glass under light icons (banner headers), light glass otherwise. The light one is opaque:
182
187
  // Compose has no backdrop blur and a translucent fill shows its own shadow through (RN uses 85% white).
183
- private fun Modifier.sideBarGlass(headerColor: HeaderColor, shape: Shape): Modifier =
188
+ private fun Modifier.sideBarGlass(headerColor: HeaderColor, shape: Shape): Modifier {
184
189
  if (headerColor.tintIconColor == Colors.black_01) {
185
- clip(shape)
190
+ return clip(shape)
186
191
  .background(Colors.black_20.copy(alpha = 0.5f))
187
192
  .border(0.5.dp, Colors.black_01.copy(alpha = 0.2f), shape)
188
- } else {
189
- shadow(3.dp, shape)
190
- .background(Colors.black_01)
191
- .border(0.5.dp, Colors.black_20.copy(alpha = 0.08f), shape)
192
193
  }
194
+ return shadow(3.dp, shape)
195
+ .background(Colors.black_01)
196
+ .border(0.5.dp, Colors.black_20.copy(alpha = 0.08f), shape)
197
+ }
@@ -1,19 +1,18 @@
1
1
  // File: ToolkitRequests.kt
2
2
  // Created At: 2026-10-12 +07:00 | Created By: AI | AI Agent: Codex | Model: GPT-6
3
- // AI-GENERATED START: cancel only toolkit requests owned by this composition
4
3
  package vn.momo.kits.navigation.component
5
4
 
6
- import vn.momo.maxapi.runtime.ApiCallback
7
- import vn.momo.maxapi.runtime.ApiRequestHandle
5
+ import vn.momo.kits.application.KitsRequest
8
6
 
7
+ // Cancels only the toolkit requests owned by this composition and drops their late callbacks.
9
8
  internal class ToolkitRequests {
10
9
  private var active = true
11
- private val handles = mutableSetOf<ApiRequestHandle>()
10
+ private val handles = mutableSetOf<KitsRequest>()
12
11
 
13
- fun <T> launch(request: (ApiCallback<T>) -> ApiRequestHandle, onResult: ApiCallback<T>) {
12
+ fun <T> launch(request: ((T) -> Unit) -> KitsRequest, onResult: (T) -> Unit) {
14
13
  if (!active) return
15
14
  var completed = false
16
- var handle: ApiRequestHandle? = null
15
+ var handle: KitsRequest? = null
17
16
  val created = request { result ->
18
17
  completed = true
19
18
  handle?.let(handles::remove)
@@ -23,13 +22,12 @@ internal class ToolkitRequests {
23
22
  if (!active) created.cancel() else if (!completed) handles.add(created)
24
23
  }
25
24
 
26
- // AI-GENERATED START: retain subscriptions across nonterminal sheet events
27
- fun <T> observe(request: (ApiCallback<T>) -> ApiRequestHandle, onResult: ApiCallback<T>) {
25
+ // Subscriptions outlive nonterminal sheet events, so they are released only on close.
26
+ fun observe(request: () -> KitsRequest) {
28
27
  if (!active) return
29
- val handle = request { result -> if (active) onResult(result) }
28
+ val handle = request()
30
29
  if (active) handles.add(handle) else handle.cancel()
31
30
  }
32
- // AI-GENERATED END: retain subscriptions across nonterminal sheet events
33
31
 
34
32
  fun close() {
35
33
  active = false
@@ -38,4 +36,3 @@ internal class ToolkitRequests {
38
36
  pending.forEach { it.cancel() }
39
37
  }
40
38
  }
41
- // AI-GENERATED END: cancel only toolkit requests owned by this composition
@@ -1,7 +1,7 @@
1
1
  package vn.momo.kits.navigation.tracking
2
2
 
3
3
  import vn.momo.kits.application.MiniAppContext
4
- import vn.momo.maxapi.IMaxApi
4
+ import vn.momo.kits.application.KitsBinding
5
5
  // AI-GENERATED START: serialize tracking attributes with their existing value types
6
6
  import kotlinx.serialization.json.JsonNull
7
7
  import kotlinx.serialization.json.JsonElement
@@ -27,7 +27,7 @@ object ScreenTracker {
27
27
  private var lastScreenName: String? = null
28
28
 
29
29
  fun trackScreenNavigated(
30
- maxApi: IMaxApi?,
30
+ binding: KitsBinding?,
31
31
  context: MiniAppContext?,
32
32
  screenName: String,
33
33
  action: String,
@@ -38,7 +38,7 @@ object ScreenTracker {
38
38
  val previousScreen = lastScreenName
39
39
  lastScreenName = screenName
40
40
 
41
- maxApi?.trackEvent(
41
+ binding?.trackEvent(
42
42
  eventName = "auto_screen_navigated",
43
43
  attributes = JsonObject(buildBaseParams(context, screenName).apply {
44
44
  put("pre_screen_name", JsonPrimitive(previousScreen))
@@ -52,7 +52,7 @@ object ScreenTracker {
52
52
  }
53
53
 
54
54
  fun trackScreenDisplayed(
55
- maxApi: IMaxApi?,
55
+ binding: KitsBinding?,
56
56
  context: MiniAppContext?,
57
57
  screenName: String,
58
58
  duration: Long,
@@ -60,7 +60,7 @@ object ScreenTracker {
60
60
  ) {
61
61
  if (state.releaseLoad) return
62
62
 
63
- maxApi?.trackEvent(
63
+ binding?.trackEvent(
64
64
  eventName = "auto_screen_displayed",
65
65
  attributes = JsonObject(buildBaseParams(context, screenName).apply {
66
66
  put("state", JsonPrimitive("load"))
@@ -72,7 +72,7 @@ object ScreenTracker {
72
72
  }
73
73
 
74
74
  fun trackScreenInteracted(
75
- maxApi: IMaxApi?,
75
+ binding: KitsBinding?,
76
76
  context: MiniAppContext?,
77
77
  screenName: String,
78
78
  duration: Long,
@@ -81,7 +81,7 @@ object ScreenTracker {
81
81
  ) {
82
82
  if (state.releaseInteraction) return
83
83
 
84
- maxApi?.trackEvent(
84
+ binding?.trackEvent(
85
85
  eventName = "auto_screen_interacted",
86
86
  attributes = JsonObject(buildBaseParams(context, screenName).apply {
87
87
  put("state", JsonPrimitive("interaction"))
@@ -108,11 +108,11 @@ object ScreenTracker {
108
108
  }
109
109
 
110
110
  fun trackPopupDisplayed(
111
- maxApi: IMaxApi?,
111
+ binding: KitsBinding?,
112
112
  context: MiniAppContext?,
113
113
  parentScreenName: String?
114
114
  ) {
115
- maxApi?.trackEvent(
115
+ binding?.trackEvent(
116
116
  eventName = "auto_popup_displayed",
117
117
  attributes = JsonObject(mapOf(
118
118
  "screen_name" to JsonPrimitive(parentScreenName),
@@ -7,8 +7,12 @@ import androidx.compose.foundation.layout.fillMaxSize
7
7
  import androidx.compose.runtime.Composable
8
8
  import androidx.compose.runtime.LaunchedEffect
9
9
  import androidx.compose.runtime.getValue
10
+ import androidx.compose.runtime.produceState
10
11
  import androidx.compose.runtime.rememberUpdatedState
11
12
  import androidx.compose.runtime.snapshotFlow
13
+ import io.ktor.client.HttpClient
14
+ import io.ktor.client.request.get
15
+ import io.ktor.client.statement.bodyAsText
12
16
  import androidx.compose.ui.Modifier
13
17
  import androidx.compose.ui.graphics.Color
14
18
  import io.github.alexzhirkevich.compottie.ExperimentalCompottieApi
@@ -29,8 +33,14 @@ internal fun ComposeLottieAnimation(
29
33
  isPlaying: Boolean,
30
34
  onEvent: ((String) -> Unit)?,
31
35
  modifier: Modifier,
36
+ progress: (() -> Float)? = null,
32
37
  ) {
33
- val json = readJson(path)
38
+ // a URL is fetched from the CDN (like the Swift LottieView(url:)); otherwise it is a bundled resource
39
+ val json = if (path.startsWith("http", ignoreCase = true)) {
40
+ produceState("", path) { value = fetchLottieJson(path) }.value
41
+ } else {
42
+ readJson(path)
43
+ }
34
44
 
35
45
  if (json.isEmpty()) {
36
46
  Box(modifier.background(bgColor ?: Color.Transparent))
@@ -55,7 +65,7 @@ internal fun ComposeLottieAnimation(
55
65
  val lottieState = animateLottieCompositionAsState(
56
66
  composition = composition,
57
67
  iterations = iterations,
58
- isPlaying = isPlaying,
68
+ isPlaying = isPlaying && progress == null,
59
69
  restartOnPlay = false,
60
70
  )
61
71
 
@@ -77,7 +87,7 @@ internal fun ComposeLottieAnimation(
77
87
  Image(
78
88
  painter = rememberLottiePainter(
79
89
  composition = composition,
80
- progress = lottieState::value,
90
+ progress = progress ?: lottieState::value,
81
91
  dynamicProperties = dynamicProperties,
82
92
  enableExpressions = false,
83
93
  expressionEngineFactory = { _, _ ->
@@ -89,3 +99,16 @@ internal fun ComposeLottieAnimation(
89
99
  )
90
100
  }
91
101
  }
102
+
103
+ private val lottieHttpClient by lazy { HttpClient() }
104
+ private val lottieUrlCache = mutableMapOf<String, String>()
105
+
106
+ /** Downloads a Lottie JSON once per URL (cached); empty on failure so the view just renders nothing. */
107
+ internal suspend fun fetchLottieJson(url: String): String {
108
+ lottieUrlCache[url]?.let { return it }
109
+ return try {
110
+ lottieHttpClient.get(url).bodyAsText().also { lottieUrlCache[url] = it }
111
+ } catch (_: Exception) {
112
+ ""
113
+ }
114
+ }
@@ -2,8 +2,6 @@ package vn.momo.kits.platform
2
2
 
3
3
  import androidx.compose.runtime.Composable
4
4
 
5
- // Overrides LocalDensity.fontScale with the live OS Dynamic Type scale so text re-scales while a
6
- // screen is visible. Wrapped inside the containers so every screen is covered, not just callers of
7
- // the app-level wrappers.
5
+ // Keeps LocalDensity.fontScale on the live OS text size; the containers wrap every screen in it.
8
6
  @Composable
9
7
  expect fun ProvideOsFontScale(content: @Composable () -> Unit)
@@ -66,7 +66,9 @@ expect fun LottieAnimation(
66
66
  isPlaying: Boolean = true,
67
67
  onEvent: ((String) -> Unit)? = null,
68
68
  modifier: Modifier = Modifier,
69
- useCompose: Boolean = false
69
+ useCompose: Boolean = false,
70
+ // drives the animation instead of playing it, so several animations stay in sync; needs useCompose
71
+ progress: (() -> Float)? = null,
70
72
  )
71
73
 
72
74
  expect fun NativePaint.setColor(
@@ -0,0 +1,7 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import androidx.compose.runtime.Composable
4
+
5
+ // OS "Reduce Motion" (iOS) / animations off (Android), live.
6
+ @Composable
7
+ expect fun rememberReduceMotion(): Boolean
@@ -7,13 +7,14 @@ import androidx.compose.ui.unit.Dp
7
7
  @Immutable
8
8
  internal data class ReservedRegion(val x: Dp, val y: Dp, val width: Dp, val height: Dp)
9
9
 
10
- // occlusion: regions the system occludes (iOS 27.1+), in the coordinates of the Compose root view:
11
- // the iPhone Duo camera, and the status bar cluster as it grows for a call or a Live Activity.
12
- // isFoldable: the device reports a `.division` (hinge) region, Apple's foldable check.
13
10
  @Immutable
14
11
  internal data class ReservedRegions(
12
+ // iOS 27.1+, root-view coordinates: the Duo camera, the status bar cluster grown by a call / Live Activity
15
13
  val occlusion: List<ReservedRegion> = emptyList(),
14
+ // a `.division` (hinge) region exists: Apple's foldable check
16
15
  val isFoldable: Boolean = false,
16
+ // the hinge while half folded; null while flat
17
+ val division: ReservedRegion? = null,
17
18
  )
18
19
 
19
20
  @Composable
@@ -47,8 +47,7 @@ internal fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed(
47
47
  )
48
48
 
49
49
  fun <T> Boolean.ifTrue(trueCase: T, falseCase: T): T = if (this) trueCase else falseCase
50
- fun <T> String.ifNotNull(trueCase: T, falseCase: T): T =
51
- if (this.isBlank()) falseCase else trueCase
50
+ fun <T> String.ifNotNull(trueCase: T, falseCase: T): T = if (this.isBlank()) falseCase else trueCase
52
51
 
53
52
  fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
54
53
  if (number == 0L) {
@@ -61,7 +60,7 @@ fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
61
60
  if (number < 0) {
62
61
  isNegative = true
63
62
  }
64
- val numberString = abs(number).toString() // Convert to Int to avoid decimal places
63
+ val numberString = abs(number).toString()
65
64
  if (numberString.length < 3) {
66
65
  return numberString + currency
67
66
  }
@@ -0,0 +1,44 @@
1
+ package vn.momo.kits.application
2
+
3
+ import kotlinx.serialization.json.JsonObject
4
+ import kotlin.test.AfterTest
5
+ import kotlin.test.Test
6
+ import kotlin.test.assertEquals
7
+ import kotlin.test.assertSame
8
+
9
+ class KitsHostTest {
10
+ @AfterTest
11
+ fun reset() = KitsHost.uninstall()
12
+
13
+ @Test
14
+ fun withoutAnInstallTheBindingDoesNothing() {
15
+ val binding = KitsHost.binding
16
+ binding.dismiss(KitsDismissTarget.Current)
17
+ binding.trackEvent("event", JsonObject(emptyMap()))
18
+ var called = false
19
+ assertSame(KitsRequest.None, binding.getLanguage { called = true })
20
+ assertEquals(false, called)
21
+ }
22
+
23
+ @Test
24
+ fun theLastInstalledBindingIsUsedUntilUninstalled() {
25
+ val first = RecordingBinding()
26
+ val second = RecordingBinding()
27
+ KitsHost.install(first)
28
+ KitsHost.install(second)
29
+ KitsHost.binding.dismiss(KitsDismissTarget.All)
30
+ assertEquals(emptyList(), first.dismissed)
31
+ assertEquals(listOf(KitsDismissTarget.All), second.dismissed)
32
+ KitsHost.uninstall()
33
+ assertSame(NoOpKitsBinding, KitsHost.binding)
34
+ }
35
+
36
+ private class RecordingBinding : KitsBinding {
37
+ val dismissed = mutableListOf<KitsDismissTarget>()
38
+ override fun dismiss(target: KitsDismissTarget) {
39
+ dismissed += target
40
+ }
41
+ override fun trackEvent(eventName: String, attributes: JsonObject) = Unit
42
+ override fun getLanguage(callback: (String) -> Unit): KitsRequest = KitsRequest.None
43
+ }
44
+ }
@@ -1,7 +1,6 @@
1
1
  // File: HelpCenterRequestTest.kt
2
2
  // Created At: 2026-10-19 +07:00
3
3
  // Created By: AI | AI Agent: Codex | Model: GPT-6
4
- // AI-GENERATED START: verify Help Center identity and localized payload preservation
5
4
  package vn.momo.kits.navigation.component
6
5
 
7
6
  import kotlinx.serialization.json.JsonObject
@@ -21,7 +20,7 @@ class HelpCenterRequestTest {
21
20
  appName = mapOf("vi" to "Tên ứng dụng", "en" to "App name"),
22
21
  description = mapOf("vi" to "Mô tả", "en" to "Description"),
23
22
  )
24
- val request = context.helpCenterRequest().context
23
+ val request = context.helpCenterRequest()
25
24
  assertEquals(context.appId, request.appId)
26
25
  assertEquals(context.appCode, request.code)
27
26
  assertEquals(context.appIcon, request.icon)
@@ -29,16 +28,12 @@ class HelpCenterRequestTest {
29
28
  "en" to JsonPrimitive("App name"))), request.name)
30
29
  assertEquals(JsonObject(mapOf("vi" to JsonPrimitive("Mô tả"),
31
30
  "en" to JsonPrimitive("Description"))), request.description)
32
- assertNull(request.support)
33
- assertNull(request.toolkitConfig)
34
- assertNull(request.permissions)
35
31
  }
36
32
 
37
33
  @Test
38
34
  fun preservesPlainStringsAndAbsentValues() {
39
- val request = MiniAppContext(appName = "App name").helpCenterRequest().context
35
+ val request = MiniAppContext(appName = "App name").helpCenterRequest()
40
36
  assertEquals(JsonPrimitive("App name"), request.name)
41
37
  assertNull(request.description)
42
38
  }
43
39
  }
44
- // AI-GENERATED END: verify Help Center identity and localized payload preservation
@@ -1,25 +1,22 @@
1
1
  // File: ToolkitRequestsTest.kt
2
2
  // Created At: 2026-10-12 +07:00 | Created By: AI | AI Agent: Codex | Model: GPT-6
3
- // AI-GENERATED START: verify cancellation and late callback suppression for toolkit UI
4
3
  package vn.momo.kits.navigation.component
5
4
 
6
5
  import kotlin.test.Test
7
6
  import kotlin.test.assertEquals
8
- import vn.momo.maxapi.runtime.ApiCallback
9
- import vn.momo.maxapi.runtime.ApiRequestHandle
10
- import vn.momo.maxapi.runtime.ApiResult
7
+ import vn.momo.kits.application.KitsRequest
11
8
 
12
9
  class ToolkitRequestsTest {
13
10
  @Test
14
11
  fun closingCancelsPendingRequestsAndSuppressesLateCallbacks() {
15
12
  val owner = ToolkitRequests()
16
13
  val handle = Handle()
17
- var callback: ApiCallback<Boolean> = {}
14
+ var callback: (Boolean) -> Unit = {}
18
15
  var results = 0
19
16
  owner.launch<Boolean>({ callback = it; handle }) { results++ }
20
17
  owner.close()
21
18
  owner.close()
22
- callback(ApiResult.Success(true))
19
+ callback(true)
23
20
  assertEquals(1, handle.cancellations)
24
21
  assertEquals(0, results)
25
22
  }
@@ -30,7 +27,7 @@ class ToolkitRequestsTest {
30
27
  val handle = Handle()
31
28
  var starts = 0
32
29
  var results = 0
33
- owner.launch<Boolean>({ callback -> starts++; callback(ApiResult.Success(false)); handle }) { results++ }
30
+ owner.launch<Boolean>({ callback -> starts++; callback(false); handle }) { results++ }
34
31
  owner.close()
35
32
  owner.launch<Boolean>({ starts++; handle }) { results++ }
36
33
  assertEquals(0, handle.cancellations)
@@ -39,24 +36,18 @@ class ToolkitRequestsTest {
39
36
  }
40
37
 
41
38
  @Test
42
- fun sheetEventsKeepTheirSubscriptionUntilTheOwnerCloses() {
39
+ fun subscriptionsStayOpenUntilTheOwnerCloses() {
43
40
  val owner = ToolkitRequests()
44
41
  val handle = Handle()
45
- var callback: ApiCallback<Boolean> = {}
46
- var results = 0
47
- owner.observe<Boolean>({ callback = it; handle }) { results++ }
48
- callback(ApiResult.Success(true))
49
- callback(ApiResult.Success(false))
42
+ owner.observe { handle }
43
+ assertEquals(0, handle.cancellations)
50
44
  owner.close()
51
- callback(ApiResult.Success(true))
52
- assertEquals(2, results)
45
+ owner.observe { handle }
53
46
  assertEquals(1, handle.cancellations)
54
47
  }
55
48
 
56
- private class Handle : ApiRequestHandle {
57
- override val requestId = "toolkit-test"
49
+ private class Handle : KitsRequest {
58
50
  var cancellations = 0
59
51
  override fun cancel() { cancellations++ }
60
52
  }
61
53
  }
62
- // AI-GENERATED END: verify cancellation and late callback suppression for toolkit UI
@@ -19,7 +19,7 @@ import platform.posix.memcpy
19
19
  internal actual fun hostFontFamily(fileName: String, weight: FontWeight): FontFamily? = remember(fileName, weight) {
20
20
  val name = fileName.substringBeforeLast('.')
21
21
  val ext = fileName.substringAfterLast('.', "")
22
- // Font từ font-source nằm rời ở bundle root, không nằm trong compose-resources.
22
+ // Host fonts sit loose at the bundle root, not in compose-resources.
23
23
  val path = NSBundle.mainBundle.pathForResource(name, ext) ?: return@remember null
24
24
  FontFamily(
25
25
  Font(
@@ -6,15 +6,13 @@ import platform.Foundation.NSNotification
6
6
  import platform.Foundation.NSNotificationCenter
7
7
  import platform.Foundation.NSOperationQueue
8
8
  import platform.darwin.NSObjectProtocol
9
- import vn.momo.maxapi.contract.observability.logging.model.LogLevel
10
9
 
11
10
  private const val STATUS_BAR_TAPPED_NOTIFICATION = "statusBarSelected"
12
11
 
13
12
  @Composable
14
13
  internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
15
- val maxApi = LocalMaxApi.current
16
- DisposableEffect(callback, maxApi) {
17
- val logger = if (callback != null) maxApi?.openLogger() else null
14
+ val binding = LocalKitsBinding.current
15
+ DisposableEffect(callback, binding) {
18
16
  val token: NSObjectProtocol? = if (callback != null) {
19
17
  NSNotificationCenter.defaultCenter.addObserverForName(
20
18
  name = STATUS_BAR_TAPPED_NOTIFICATION,
@@ -22,13 +20,12 @@ internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
22
20
  queue = NSOperationQueue.mainQueue,
23
21
  ) { _: NSNotification? ->
24
22
  runCatching { callback() }.onFailure {
25
- logger?.log(LogLevel.ERROR, "[ScrollToTop] callback failed")
23
+ binding?.logError("[ScrollToTop] callback failed")
26
24
  }
27
25
  }
28
26
  } else null
29
27
  onDispose {
30
28
  token?.let { NSNotificationCenter.defaultCenter.removeObserver(it) }
31
- logger?.close()
32
29
  }
33
30
  }
34
31
  }
@@ -17,15 +17,14 @@ import platform.UIKit.UIFont
17
17
  import platform.UIKit.UIFontTextStyleBody
18
18
  import platform.darwin.NSObject
19
19
 
20
- // Compose MP iOS reads LocalDensity.fontScale once at ComposeUIViewController creation and does not
21
- // recompose it when UIContentSizeCategory changes (Android tracks Configuration.fontScale live). We
22
- // observe the notification and override LocalDensity.fontScale so scaleSize() recomposes live. The
23
- // formula matches the SwiftUI kit (UIFont body point size / 17) so both iOS surfaces scale alike.
20
+ // Body point size / 17, as in the SwiftUI kit, so both iOS surfaces scale alike.
24
21
  private const val DEFAULT_BODY_POINT_SIZE = 17.0
25
22
 
26
- private fun currentOsFontScale(): Float =
27
- (UIFont.preferredFontForTextStyle(UIFontTextStyleBody).pointSize / DEFAULT_BODY_POINT_SIZE).toFloat()
23
+ private fun currentOsFontScale(): Float {
24
+ return (UIFont.preferredFontForTextStyle(UIFontTextStyleBody).pointSize / DEFAULT_BODY_POINT_SIZE).toFloat()
25
+ }
28
26
 
27
+ // Compose MP iOS reads fontScale only once, at ComposeUIViewController creation.
29
28
  @OptIn(ExperimentalForeignApi::class)
30
29
  @Composable
31
30
  actual fun ProvideOsFontScale(content: @Composable () -> Unit) {
@@ -21,6 +21,8 @@ import androidx.compose.ui.backhandler.BackHandler as ComposeBackHandler
21
21
  import androidx.compose.ui.graphics.Color
22
22
  import androidx.compose.ui.graphics.NativePaint
23
23
  import androidx.compose.ui.graphics.toArgb
24
+ import androidx.compose.ui.platform.LocalDensity
25
+ import androidx.compose.ui.platform.LocalWindowInfo
24
26
  import androidx.compose.ui.unit.Dp
25
27
  import androidx.compose.ui.unit.dp
26
28
  import androidx.compose.ui.viewinterop.UIKitInteropProperties
@@ -29,8 +31,6 @@ import cocoapods.lottie_ios.CompatibleAnimation
29
31
  import cocoapods.lottie_ios.CompatibleAnimationKeypath
30
32
  import cocoapods.lottie_ios.CompatibleAnimationView
31
33
  import kotlinx.cinterop.ExperimentalForeignApi
32
- import kotlinx.cinterop.get
33
- import kotlinx.cinterop.memScoped
34
34
  import androidx.navigationevent.NavigationEventDispatcher
35
35
  import androidx.navigationevent.NavigationEventDispatcherOwner
36
36
  import org.jetbrains.skia.FilterBlurMode
@@ -38,23 +38,22 @@ import org.jetbrains.skia.MaskFilter
38
38
  import platform.Foundation.NSBundle
39
39
  import platform.UIKit.UIColor
40
40
  import platform.UIKit.UIDevice
41
- import platform.UIKit.UIScreen
42
41
  import platform.UIKit.UIUserInterfaceIdiomPhone
43
42
  import vn.momo.kits.navigation.AttachHostBackGesture
44
43
  import vn.momo.kits.navigation.Navigator
45
44
 
46
45
  actual fun getPlatformName(): String = "iOS"
47
46
 
48
- actual fun isPhoneIdiom(): Boolean =
49
- UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
47
+ actual fun isPhoneIdiom(): Boolean = UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
50
48
 
51
- @OptIn(ExperimentalForeignApi::class)
49
+ // Window size, not UIScreen.main (which stays on one display on iPhone Duo); recomposes on fold/unfold.
52
50
  @Composable
53
- actual fun getScreenDimensions(): ScreenDimension = memScoped {
54
- val config = UIScreen.mainScreen.bounds.ptr[0]
51
+ actual fun getScreenDimensions(): ScreenDimension {
52
+ val density = LocalDensity.current
53
+ val size = LocalWindowInfo.current.containerSize
55
54
  return ScreenDimension(
56
- config.size.width.toInt(),
57
- config.size.height.toInt()
55
+ (size.width / density.density).toInt(),
56
+ (size.height / density.density).toInt()
58
57
  )
59
58
  }
60
59
 
@@ -111,10 +110,11 @@ actual fun LottieAnimation(
111
110
  isPlaying: Boolean,
112
111
  onEvent: ((String) -> Unit)?,
113
112
  modifier: Modifier,
114
- useCompose: Boolean
113
+ useCompose: Boolean,
114
+ progress: (() -> Float)?,
115
115
  ) {
116
116
  if (useCompose) {
117
- ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
117
+ ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier, progress)
118
118
  return
119
119
  }
120
120