@momo-kits/native-kits 0.162.2-sp.1-debug → 0.162.2-sp.10-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 (198) hide show
  1. package/.claude/settings.local.json +15 -1
  2. package/CLAUDE.md +78 -0
  3. package/compose/build.gradle.kts +12 -8
  4. package/compose/build.gradle.kts.backup +11 -7
  5. package/compose/compose.podspec +1 -1
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +2 -7
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +8 -11
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +6 -24
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +4 -19
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +1 -10
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +2 -2
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +1 -1
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +1 -1
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +5 -16
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +1 -1
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +6 -101
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +8 -19
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +8 -33
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +1 -1
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +22 -25
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +27 -29
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +3 -26
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +30 -31
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +3 -13
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -5
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +3 -11
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +3 -18
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +11 -11
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +42 -65
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +69 -26
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -5
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +84 -59
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +13 -71
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +10 -51
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +6 -1
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +4 -21
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +1 -1
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +16 -75
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +5 -26
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +1 -1
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +3 -11
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +16 -40
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -9
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -28
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +2 -13
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +4 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +4 -10
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +3 -28
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +8 -47
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +4 -25
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +2 -11
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +1 -17
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +1 -6
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +50 -111
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +1 -5
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +1 -5
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -12
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +4 -96
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +5 -7
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +2 -12
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +9 -21
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +2 -2
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +9 -14
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +8 -11
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +1 -1
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -20
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +1 -1
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -5
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -2
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +94 -4
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -2
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +2 -2
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +3 -7
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +12 -16
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +120 -93
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +48 -33
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +88 -63
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +9 -14
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +13 -31
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +1 -1
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +6 -24
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +11 -6
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +2 -1
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +9 -6
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +1 -1
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +3 -13
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +3 -2
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +1 -40
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -2
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -8
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +2 -17
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +1 -1
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +3 -3
  99. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -3
  100. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  101. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -2
  102. package/gradle/libs.versions.toml +2 -0
  103. package/gradle.properties +1 -1
  104. package/ios/Application/ApplicationEnvironment.swift +15 -2
  105. package/ios/Application/Components.swift +16 -0
  106. package/ios/Application/HeaderRight.swift +79 -45
  107. package/ios/Application/Localize.swift +277 -0
  108. package/ios/Application/MaxApi.swift +18 -0
  109. package/ios/Application/Navigation/BottomTab/BottomTab.swift +3 -1
  110. package/ios/Application/Navigation/NavigationContainer.swift +53 -4
  111. package/ios/Application/Navigation/Navigator.swift +54 -29
  112. package/ios/Application/Navigation/Overplay/BottomSheet.swift +98 -18
  113. package/ios/Application/Navigation/Overplay/ModalScreen.swift +6 -0
  114. package/ios/Application/Navigation/Tracking/ScreenTracker.swift +117 -0
  115. package/ios/Application/Screen.swift +2 -1
  116. package/ios/Application/StackScreen.swift +55 -3
  117. package/ios/Badge/BadgeRibbon.swift +80 -0
  118. package/ios/Button/Button.swift +67 -11
  119. package/ios/Carousel/Carousel.swift +16 -1
  120. package/ios/Checkbox/Checkbox.swift +14 -20
  121. package/ios/Chip/Chip.swift +35 -26
  122. package/ios/Collapse/Collapse.swift +11 -1
  123. package/ios/Colors+Radius+Spacing/Colors.swift +20 -17
  124. package/ios/Colors+Radius+Spacing/Spacing.swift +3 -1
  125. package/ios/Colors+Radius+Spacing/Theme.swift +15 -15
  126. package/ios/DateTimePicker/DateTimePicker.swift +4 -2
  127. package/ios/DateTimePicker/WheelPicker.swift +7 -3
  128. package/ios/Extensions/ActiveOpacityButtonStyle.swift +14 -0
  129. package/ios/Extensions/Color++.swift +32 -0
  130. package/ios/Icon/Icon.swift +5 -1
  131. package/ios/IconButton/IconButton.swift +35 -7
  132. package/ios/Image/Image.swift +16 -3
  133. package/ios/Information/Information.swift +3 -1
  134. package/ios/Input/ErrorView.swift +3 -1
  135. package/ios/Input/Input.swift +31 -8
  136. package/ios/Input/InputPhoneNumber.swift +14 -3
  137. package/ios/Input/InputSearch.swift +7 -1
  138. package/ios/Input/InputTextArea.swift +78 -34
  139. package/ios/InputDropDown/InputDropDown.swift +4 -1
  140. package/ios/InputMoney/InputMoney.swift +16 -4
  141. package/ios/Popup/PopupDisplay.swift +3 -4
  142. package/ios/Popup/PopupNotify.swift +3 -4
  143. package/ios/ProgressInfo/ProgressInfo.swift +4 -2
  144. package/ios/Radio/Radio.swift +12 -13
  145. package/ios/Rating/Rating.swift +1 -1
  146. package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +11 -0
  147. package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +38 -0
  148. package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +38 -0
  149. package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +38 -0
  150. package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +6 -0
  151. package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +38 -0
  152. package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +38 -0
  153. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +38 -0
  154. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +38 -0
  155. package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +38 -0
  156. package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +38 -0
  157. package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +38 -0
  158. package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +38 -0
  159. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +9 -0
  160. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +38 -0
  161. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +38 -0
  162. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +38 -0
  163. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +38 -0
  164. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +38 -0
  165. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +38 -0
  166. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +38 -0
  167. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +38 -0
  168. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +38 -0
  169. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +38 -0
  170. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +38 -0
  171. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +38 -0
  172. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +38 -0
  173. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +38 -0
  174. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +38 -0
  175. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +38 -0
  176. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +38 -0
  177. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +38 -0
  178. package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +38 -0
  179. package/ios/Stepper/Stepper.swift +2 -2
  180. package/ios/Steps/Steps.swift +22 -6
  181. package/ios/SuggestAction/SuggestAction.swift +5 -3
  182. package/ios/Swipeable/SwipeCell.swift +5 -3
  183. package/ios/Switch/Switch.swift +53 -28
  184. package/ios/TabView/TabView.swift +18 -14
  185. package/ios/Template/TrustBanner/TrustBanner.swift +6 -7
  186. package/ios/Tooltip/Tooltip.swift +3 -0
  187. package/ios/Typography/FontScaleStore.swift +19 -0
  188. package/ios/Typography/Text.swift +3 -0
  189. package/ios/Typography/Typography.swift +8 -5
  190. package/ios/Uploader/Uploader.swift +0 -9
  191. package/ios/native-kits.podspec +6 -3
  192. package/ios-demo/MoMoUIKitsDemo.podspec +5 -3
  193. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +9 -57
  194. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +21 -3
  195. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +188 -0
  196. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +2 -0
  197. package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +5 -4
  198. package/package.json +1 -1
@@ -1,14 +1,104 @@
1
1
  package vn.momo.kits.modifier
2
2
 
3
- import androidx.compose.foundation.background
3
+ import androidx.compose.animation.core.LinearEasing
4
+ import androidx.compose.animation.core.RepeatMode
5
+ import androidx.compose.animation.core.animateFloat
6
+ import androidx.compose.animation.core.infiniteRepeatable
7
+ import androidx.compose.animation.core.rememberInfiniteTransition
8
+ import androidx.compose.animation.core.tween
4
9
  import androidx.compose.runtime.Composable
10
+ import androidx.compose.runtime.getValue
5
11
  import androidx.compose.ui.Modifier
12
+ import androidx.compose.ui.draw.drawWithContent
13
+ import androidx.compose.ui.geometry.Offset
14
+ import androidx.compose.ui.graphics.Color
15
+ import androidx.compose.ui.graphics.drawscope.clipRect
16
+ import androidx.compose.ui.text.TextStyle
17
+ import androidx.compose.ui.text.drawText
18
+ import androidx.compose.ui.text.font.FontWeight
19
+ import androidx.compose.ui.text.rememberTextMeasurer
20
+ import androidx.compose.ui.unit.sp
6
21
  import vn.momo.kits.application.IsShowBaseLineDebug
7
22
  import vn.momo.kits.const.Colors
8
23
 
24
+ @Suppress("ExperimentalAnnotationRetention")
25
+ @RequiresOptIn(
26
+ message = "This is internal API of native-kits, become internal in next sprint",
27
+ level = RequiresOptIn.Level.WARNING,
28
+ )
29
+ @Retention(AnnotationRetention.BINARY)
30
+ @Target(
31
+ AnnotationTarget.CLASS,
32
+ AnnotationTarget.FUNCTION,
33
+ AnnotationTarget.PROPERTY,
34
+ )
35
+ annotation class InternalApi
36
+
37
+ @Composable
38
+ fun DeprecatedModifier(text: String = "Deprecated component"): Modifier = debugMarker(
39
+ label = text,
40
+ background = Colors.red_04.copy(alpha = 0.7f),
41
+ textColor = Colors.red_01,
42
+ animationLabel = "deprecatedMarquee",
43
+ )
44
+
9
45
  @Composable
10
- fun DeprecatedModifier(): Modifier {
11
- return Modifier.conditional(IsShowBaseLineDebug) {
12
- background(Colors.red_01.copy(alpha = 0.5f))
46
+ private fun debugMarker(
47
+ label: String,
48
+ background: Color,
49
+ textColor: Color,
50
+ animationLabel: String,
51
+ ): Modifier {
52
+ if (!IsShowBaseLineDebug) return Modifier
53
+
54
+ val textMeasurer = rememberTextMeasurer()
55
+ val marquee = rememberInfiniteTransition(label = animationLabel)
56
+ val progress by marquee.animateFloat(
57
+ initialValue = 0f,
58
+ targetValue = 1f,
59
+ animationSpec = infiniteRepeatable(
60
+ animation = tween(durationMillis = 4000, easing = LinearEasing),
61
+ repeatMode = RepeatMode.Restart,
62
+ ),
63
+ label = "${animationLabel}Progress",
64
+ )
65
+
66
+ return Modifier.drawWithContent {
67
+ drawContent()
68
+ drawRect(color = background)
69
+
70
+ if (size.width <= 0f || size.height <= 0f) return@drawWithContent
71
+
72
+ val fontPx = (size.width * 0.1f).coerceIn(12.sp.toPx(), 20.sp.toPx())
73
+ val style = TextStyle(
74
+ color = textColor,
75
+ fontSize = fontPx.toSp(),
76
+ fontWeight = FontWeight.Bold,
77
+ )
78
+
79
+ val intrinsic = textMeasurer.measure(
80
+ text = label,
81
+ style = style,
82
+ maxLines = 1,
83
+ softWrap = false,
84
+ )
85
+ val textW = intrinsic.size.width
86
+ val textH = intrinsic.size.height
87
+ val y = (size.height - textH) / 2f
88
+
89
+ if (textW <= size.width) {
90
+ drawText(
91
+ textLayoutResult = intrinsic,
92
+ topLeft = Offset((size.width - textW) / 2f, y),
93
+ )
94
+ } else {
95
+ clipRect(right = size.width, bottom = size.height) {
96
+ val gap = textW * 0.5f
97
+ val travel = textW + gap
98
+ val x = -progress * travel
99
+ drawText(textLayoutResult = intrinsic, topLeft = Offset(x, y))
100
+ drawText(textLayoutResult = intrinsic, topLeft = Offset(x + travel, y))
101
+ }
102
+ }
13
103
  }
14
104
  }
@@ -9,8 +9,6 @@ import androidx.compose.ui.unit.Dp
9
9
  import androidx.compose.ui.unit.dp
10
10
  import vn.momo.kits.platform.setColor
11
11
  import vn.momo.kits.platform.setMaskFilter
12
-
13
-
14
12
  fun Modifier.shadow(
15
13
  color: Color = Color.Black,
16
14
  borderRadius: Dp = 0.dp,
@@ -41,7 +41,7 @@ import vn.momo.kits.const.AppTheme
41
41
  import vn.momo.kits.const.Colors
42
42
  import vn.momo.kits.const.Radius
43
43
  import vn.momo.kits.const.Spacing
44
- import vn.momo.kits.application.ApplicationContext
44
+ import vn.momo.kits.application.LocalContext
45
45
  import vn.momo.kits.application.IsShowBaseLineDebug
46
46
  import vn.momo.kits.const.Typography
47
47
  import vn.momo.kits.navigation.tracking.ScreenTracker
@@ -73,7 +73,7 @@ internal fun BottomSheet(
73
73
  val coroutineScope = rememberCoroutineScope()
74
74
 
75
75
  val maxApi = LocalMaxApi.current
76
- val context = ApplicationContext.current
76
+ val context = LocalContext.current
77
77
 
78
78
  DisposableEffect(Unit) {
79
79
  ScreenTracker.trackPopupDisplayed(
@@ -10,11 +10,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
10
10
  import androidx.compose.foundation.layout.Box
11
11
  import androidx.compose.foundation.layout.fillMaxSize
12
12
  import androidx.compose.foundation.layout.wrapContentSize
13
- import androidx.compose.runtime.Composable
14
- import androidx.compose.runtime.DisposableEffect
15
- import androidx.compose.runtime.LaunchedEffect
16
- import androidx.compose.runtime.remember
17
- import androidx.compose.runtime.rememberCoroutineScope
13
+ import androidx.compose.runtime.*
18
14
  import androidx.compose.ui.Alignment
19
15
  import androidx.compose.ui.Modifier
20
16
  import androidx.compose.ui.draw.alpha
@@ -22,7 +18,7 @@ import androidx.compose.ui.draw.scale
22
18
  import androidx.compose.ui.graphics.Color
23
19
  import androidx.compose.ui.unit.dp
24
20
  import kotlinx.coroutines.launch
25
- import vn.momo.kits.application.ApplicationContext
21
+ import vn.momo.kits.application.LocalContext
26
22
  import vn.momo.kits.application.IsShowBaseLineDebug
27
23
  import vn.momo.kits.const.Colors
28
24
  import vn.momo.kits.modifier.conditional
@@ -44,7 +40,7 @@ internal fun ModalScreen(
44
40
  val coroutineScope = rememberCoroutineScope()
45
41
 
46
42
  val maxApi = LocalMaxApi.current
47
- val context = ApplicationContext.current
43
+ val context = LocalContext.current
48
44
 
49
45
  DisposableEffect(Unit) {
50
46
  ScreenTracker.trackPopupDisplayed(
@@ -1,29 +1,25 @@
1
1
  package vn.momo.kits.navigation
2
2
 
3
3
  import androidx.compose.foundation.gestures.ScrollableState
4
- import androidx.compose.runtime.Composable
5
- import androidx.compose.runtime.Stable
6
- import androidx.compose.runtime.State
7
- import androidx.compose.runtime.mutableStateOf
8
- import androidx.compose.runtime.staticCompositionLocalOf
4
+ import androidx.compose.runtime.*
9
5
  import androidx.compose.ui.graphics.Color
10
6
  import vn.momo.kits.navigation.bottomtab.setBottomTabOption
11
- import vn.momo.kits.navigation.component.FloatingButtonProps
12
- import vn.momo.kits.navigation.component.HeaderBackProps
13
- import vn.momo.kits.navigation.component.HeaderRight
14
- import vn.momo.kits.navigation.component.HeaderTitle
15
- import vn.momo.kits.navigation.component.HeaderType
16
- import vn.momo.kits.navigation.component.TitlePosition
7
+ import vn.momo.kits.navigation.component.*
17
8
 
18
9
  class Navigation(
19
10
  val id: Int = -1,
20
11
  val bottomTabIndex: Int = -1,
21
- val initOptions: NavigationOptions? = null
12
+ val initOptions: NavigationOptions? = null,
13
+ private val registry: DynamicScreenRegistry? = null
22
14
  ) {
23
15
  private val _options = mutableStateOf(initOptions ?: NavigationOptions())
24
16
  val currentOptions: State<NavigationOptions> get() = _options
25
17
  val options: NavigationOptions get() = _options.value
26
18
 
19
+ private val _isBottomTabRoot = mutableStateOf(false)
20
+ internal val isBottomTabRoot: Boolean get() = _isBottomTabRoot.value
21
+ internal fun markAsBottomTabRoot() { _isBottomTabRoot.value = true }
22
+
27
23
  fun setOptions(
28
24
  onBackHandler: (() -> Unit)? = null,
29
25
  hiddenBack: Boolean? = null,
@@ -65,7 +61,7 @@ class Navigation(
65
61
  private fun updateOptions(updated: NavigationOptions) {
66
62
  _options.value = updated
67
63
  if (bottomTabIndex != -1) setBottomTabOption(bottomTabIndex, updated)
68
- if (id != -1) DynamicScreenRegistry.setOptions(id, updated)
64
+ if (id != -1) registry?.setOptions(id, updated)
69
65
  }
70
66
  }
71
67
 
@@ -89,14 +85,14 @@ data class NavigationOptions(
89
85
  val footerComponent: @Composable (() -> Unit)? = null,
90
86
  val floatingButtonProps: FloatingButtonProps? = null,
91
87
  val keyboardOptions: KeyboardOptions = KeyboardOptions()
92
- )
88
+ ) {
89
+ internal fun hasFooter() : Boolean = footerComponent != null
90
+ }
93
91
 
94
92
  data class KeyboardOptions(
95
93
  val keyboardShouldPersistTaps: Boolean = false,
96
94
  val useAvoidKeyboard: Boolean = true
97
95
  )
98
-
99
-
100
96
  data class ScrollData(
101
97
  val scrollable: Boolean = true,
102
98
  val scrollState: ScrollableState? = null,
@@ -1,17 +1,35 @@
1
1
  package vn.momo.kits.navigation
2
2
 
3
- import androidx.compose.animation.*
4
3
  import androidx.compose.animation.core.tween
5
- import androidx.compose.runtime.*
4
+ import androidx.compose.animation.fadeIn
5
+ import androidx.compose.animation.slideInHorizontally
6
+ import androidx.compose.animation.slideInVertically
7
+ import androidx.compose.animation.slideOutHorizontally
8
+ import androidx.compose.animation.slideOutVertically
9
+ import androidx.compose.runtime.Composable
10
+ import androidx.compose.runtime.CompositionLocalProvider
11
+ import androidx.compose.runtime.DisposableEffect
12
+ import androidx.compose.runtime.LaunchedEffect
13
+ import androidx.compose.runtime.mutableStateOf
14
+ import androidx.compose.runtime.remember
6
15
  import androidx.compose.runtime.saveable.rememberSaveable
16
+ import androidx.compose.runtime.staticCompositionLocalOf
7
17
  import androidx.compose.ui.unit.Dp
8
18
  import androidx.navigation.compose.NavHost
9
19
  import androidx.navigation.compose.composable
10
20
  import androidx.navigation.compose.rememberNavController
11
21
  import androidx.navigation.toRoute
12
- import vn.momo.kits.application.*
13
- import vn.momo.kits.const.*
22
+ import vn.momo.kits.application.LocalContext
23
+ import vn.momo.kits.application.LocalLocalize
24
+ import vn.momo.kits.application.Localize
25
+ import vn.momo.kits.application.MiniAppContext
26
+ import vn.momo.kits.const.AppNavigationBar
27
+ import vn.momo.kits.const.AppStatusBar
28
+ import vn.momo.kits.const.AppTheme
29
+ import vn.momo.kits.const.Theme
30
+ import vn.momo.kits.const.defaultTheme
14
31
  import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
32
+ import vn.momo.kits.platform.ProvideOsFontScale
15
33
  import vn.momo.kits.utils.getAppStatusBarHeight
16
34
  import vn.momo.kits.utils.getNavigationBarHeight
17
35
  import vn.momo.maxapi.IMaxApi
@@ -22,110 +40,114 @@ fun NavigationContainer(
22
40
  initialScreen: @Composable () -> Unit,
23
41
  options: NavigationOptions? = null,
24
42
  initialTheme: Theme = defaultTheme,
25
- applicationContext: MiniAppContext? = null,
43
+ miniAppContext: MiniAppContext? = null,
26
44
  maxApi: IMaxApi? = null,
27
45
  setNavigator: ((Navigator) -> Unit)? = null,
28
46
  statusBarHeight: Dp? = null,
29
- config: KitConfig? = null,
30
- language: String? = null
31
- ){
47
+ localize: Localize? = null,
48
+ ) {
32
49
  val navController = rememberNavController()
33
- val navigator = remember { Navigator(navController = navController, maxApi = maxApi) }
50
+ val registry = remember { DynamicScreenRegistry() }
51
+ val navigator = remember { Navigator(navController = navController, maxApi = maxApi, registry = registry) }
34
52
  val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
35
53
  val navigationBarHeight = getNavigationBarHeight()
36
54
 
37
- val parentContext = ApplicationContext.current
38
- val mergedContext = MiniAppContext.merge(parentContext, applicationContext)
55
+ val parentContext = LocalContext.current
56
+ val mergedContext = MiniAppContext.merge(parentContext, miniAppContext)
39
57
 
40
58
  val theme = remember { mutableStateOf(initialTheme) }
59
+ val fallbackLocalize = remember { Localize() }
41
60
 
42
- LaunchedEffect(Unit) {
43
- val headerBar = config?.headerBar
44
- if (headerBar != null && theme.value.assets.headerBackground == null) {
45
- theme.value = theme.value.copy(
46
- assets = ThemeAssets(
47
- headerBackground = headerBar
48
- )
49
- )
61
+ val resolvedLocalize = localize ?: fallbackLocalize
62
+
63
+ LaunchedEffect(maxApi, resolvedLocalize) {
64
+ val api = maxApi ?: return@LaunchedEffect
65
+ runCatching {
66
+ api.getLanguage(callback = { data ->
67
+ if (parseLanguage(data) == Localize.EN) {
68
+ resolvedLocalize.changeLanguage(Localize.EN)
69
+ }
70
+ })
50
71
  }
51
72
  }
52
73
 
53
- val screenId = rememberSaveable { DynamicScreenRegistry.nextId() }
54
- DynamicScreenRegistry.bind(screenId, initialScreenName, initialScreen, options)
74
+ val screenId = rememberSaveable { registry.nextId() }
75
+ registry.bind(screenId, initialScreenName, initialScreen, options)
55
76
  val startDestination = remember(screenId) { DynamicScreenRoute(screenId) }
56
77
 
57
- ProvideNavigationEventDispatcherOwner {
58
- CompositionLocalProvider(
59
- LocalNavigator provides navigator,
60
- LocalMaxApi provides maxApi,
61
- AppTheme provides theme.value,
62
- AppStatusBar provides statusBarHeight,
63
- AppNavigationBar provides navigationBarHeight,
64
- ApplicationContext provides mergedContext,
65
- AppConfig provides config,
66
- AppLanguage provides language,
67
- ScaleSizeMaxRate provides mergedContext?.scaleSizeMaxRate,
68
- ) {
69
- LaunchedEffect(Unit) {
70
- setNavigator?.invoke(navigator)
71
- }
72
-
73
- NavHost(navController, startDestination = startDestination) {
74
- composable<DynamicScreenRoute>(
75
- enterTransition = {
76
- slideInHorizontally(
77
- animationSpec = tween(300),
78
- initialOffsetX = { it }
79
- )
80
- },
81
- exitTransition = null,
82
- popEnterTransition = { fadeIn(animationSpec = tween(0)) },
83
- popExitTransition = {
84
- slideOutHorizontally(
85
- animationSpec = tween(300),
86
- targetOffsetX = { it }
87
- )
88
- }
89
- ) { backStackEntry ->
90
- val route = backStackEntry.toRoute<DynamicScreenRoute>()
91
- val screen = DynamicScreenRegistry.getScreen(route.id)
92
-
93
- if (screen != null) {
94
- StackScreen(
95
- id = route.id,
96
- name = screen.name,
97
- content = screen.content,
98
- navigationOptions = screen.options
99
- )
100
- }
78
+ ProvideOsFontScale {
79
+ ProvideNavigationEventDispatcherOwner {
80
+ CompositionLocalProvider(
81
+ LocalNavigator provides navigator,
82
+ LocalDynamicScreenRegistry provides registry,
83
+ LocalMaxApi provides maxApi,
84
+ AppTheme provides theme.value,
85
+ AppStatusBar provides statusBarHeight,
86
+ AppNavigationBar provides navigationBarHeight,
87
+ LocalContext provides mergedContext,
88
+ LocalLocalize provides resolvedLocalize,
89
+ ) {
90
+ LaunchedEffect(Unit) {
91
+ setNavigator?.invoke(navigator)
101
92
  }
102
93
 
103
- composable<DynamicDialogRoute>(
104
- enterTransition = {
105
- slideInVertically(
106
- animationSpec = tween(300),
107
- initialOffsetY = { it }
108
- )
109
- },
110
- exitTransition = null,
111
- popEnterTransition = { fadeIn(animationSpec = tween(0)) },
112
- popExitTransition = {
113
- slideOutVertically(
114
- animationSpec = tween(300),
115
- targetOffsetY = { it }
116
- )
94
+ NavHost(navController, startDestination = startDestination) {
95
+ composable<DynamicScreenRoute>(
96
+ enterTransition = {
97
+ slideInHorizontally(
98
+ animationSpec = tween(300),
99
+ initialOffsetX = { it }
100
+ )
101
+ },
102
+ exitTransition = null,
103
+ popEnterTransition = { fadeIn(animationSpec = tween(0)) },
104
+ popExitTransition = {
105
+ slideOutHorizontally(
106
+ animationSpec = tween(300),
107
+ targetOffsetX = { it }
108
+ )
109
+ }
110
+ ) { backStackEntry ->
111
+ val route = backStackEntry.toRoute<DynamicScreenRoute>()
112
+ val screen = registry.getScreen(route.id)
113
+
114
+ if (screen != null) {
115
+ StackScreen(
116
+ id = route.id,
117
+ name = screen.name,
118
+ content = screen.content,
119
+ navigationOptions = screen.options
120
+ )
121
+ }
117
122
  }
118
- ) { backStackEntry ->
119
- val route = backStackEntry.toRoute<DynamicDialogRoute>()
120
- val screen = DynamicScreenRegistry.getScreen(route.id)
121
-
122
- if (screen != null) {
123
- StackScreen(
124
- id = route.id,
125
- name = screen.name,
126
- content = screen.content,
127
- navigationOptions = screen.options
128
- )
123
+
124
+ composable<DynamicDialogRoute>(
125
+ enterTransition = {
126
+ slideInVertically(
127
+ animationSpec = tween(300),
128
+ initialOffsetY = { it }
129
+ )
130
+ },
131
+ exitTransition = null,
132
+ popEnterTransition = { fadeIn(animationSpec = tween(0)) },
133
+ popExitTransition = {
134
+ slideOutVertically(
135
+ animationSpec = tween(300),
136
+ targetOffsetY = { it }
137
+ )
138
+ }
139
+ ) { backStackEntry ->
140
+ val route = backStackEntry.toRoute<DynamicDialogRoute>()
141
+ val screen = registry.getScreen(route.id)
142
+
143
+ if (screen != null) {
144
+ StackScreen(
145
+ id = route.id,
146
+ name = screen.name,
147
+ content = screen.content,
148
+ navigationOptions = screen.options
149
+ )
150
+ }
129
151
  }
130
152
  }
131
153
  }
@@ -135,11 +157,16 @@ fun NavigationContainer(
135
157
  DisposableEffect(Unit) {
136
158
  onDispose {
137
159
  navigator.dispose()
138
- DynamicScreenRegistry.unregisterScreen(screenId)
160
+ registry.unregisterScreen(screenId)
139
161
  }
140
162
  }
141
163
  }
142
164
 
143
- val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> {
144
- error("No MaxApi provided")
165
+ val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> { null }
166
+
167
+ private fun parseLanguage(raw: Map<String, Any?>?): String? {
168
+ val code = (raw?.get("response") as? String)?.trim()?.lowercase()
169
+ if (code.isNullOrEmpty()) return null
170
+ return if (code.startsWith(Localize.EN)) Localize.EN else Localize.VI
145
171
  }
172
+