@momo-kits/native-kits 0.165.1-beta.11 → 0.165.2-beta.2

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 (150) hide show
  1. package/CLAUDE.md +1 -0
  2. package/ios/Application/Navigation/NavigatorManager.swift +0 -27
  3. package/ios/Information/Information.swift +5 -2
  4. package/ios/InputMoney/InputMoney.swift +76 -21
  5. package/ios/Typography/Text.swift +41 -1
  6. package/ios/native-kits.podspec +1 -1
  7. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  8. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +9 -1
  9. package/package.json +1 -1
  10. package/publish.sh +25 -0
  11. package/build.gradle.kts +0 -11
  12. package/compose/build.gradle.kts +0 -190
  13. package/compose/build.gradle.kts.backup +0 -190
  14. package/compose/compose.podspec +0 -47
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  17. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -150
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -831
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -134
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -475
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -216
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -264
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -552
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -296
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -52
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -38
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -39
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -299
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -207
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -609
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -175
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -331
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -81
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -75
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -37
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -364
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -69
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -98
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  142. package/gradle/libs.versions.toml +0 -69
  143. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  144. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  145. package/gradle.properties +0 -26
  146. package/gradlew +0 -252
  147. package/gradlew.bat +0 -94
  148. package/ios-demo/README.md +0 -120
  149. package/local.properties +0 -8
  150. package/settings.gradle.kts +0 -64
@@ -1,129 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.animation.core.Animatable
4
- import androidx.compose.animation.core.CubicBezierEasing
5
- import androidx.compose.animation.core.tween
6
- import androidx.compose.foundation.background
7
- import androidx.compose.foundation.border
8
- import androidx.compose.foundation.clickable
9
- import androidx.compose.foundation.interaction.MutableInteractionSource
10
- import androidx.compose.foundation.layout.Box
11
- import androidx.compose.foundation.layout.fillMaxSize
12
- import androidx.compose.foundation.layout.wrapContentSize
13
- import androidx.compose.runtime.*
14
- import androidx.compose.ui.Alignment
15
- import androidx.compose.ui.Modifier
16
- import androidx.compose.ui.draw.alpha
17
- import androidx.compose.ui.draw.scale
18
- import androidx.compose.ui.graphics.Color
19
- import androidx.compose.ui.unit.dp
20
- import kotlinx.coroutines.launch
21
- import vn.momo.kits.application.LocalContext
22
- import vn.momo.kits.application.IsShowBaseLineDebug
23
- import vn.momo.kits.const.Colors
24
- import vn.momo.kits.modifier.conditional
25
- import vn.momo.kits.modifier.noFeedbackClickable
26
- import vn.momo.kits.navigation.tracking.ScreenTracker
27
- import vn.momo.kits.platform.BackHandler
28
-
29
- @Composable
30
- internal fun ModalScreen(
31
- content: @Composable () -> Unit,
32
- barrierDismissible: Boolean = true,
33
- onDismiss: (() -> Unit)? = null
34
- ) {
35
- val navigator = LocalNavigator.current
36
-
37
- val alpha = remember { Animatable(0f) }
38
- val scale = remember { Animatable(0.8f) }
39
-
40
- val coroutineScope = rememberCoroutineScope()
41
-
42
- val maxApi = LocalMaxApi.current
43
- val context = LocalContext.current
44
-
45
- DisposableEffect(Unit) {
46
- ScreenTracker.trackPopupDisplayed(
47
- maxApi = maxApi,
48
- context = context,
49
- parentScreenName = ScreenTracker.getLastScreenName()
50
- )
51
- onDispose { }
52
- }
53
-
54
- fun openEvent() {
55
- coroutineScope.launch {
56
- launch {
57
- alpha.animateTo(
58
- targetValue = 1f,
59
- animationSpec = tween(durationMillis = 250)
60
- )
61
- }
62
- launch {
63
- scale.animateTo(
64
- targetValue = 1f,
65
- animationSpec = tween(
66
- durationMillis = 250,
67
- easing = CubicBezierEasing(0.2f, 0.0f, 0f, 1f)
68
- )
69
- )
70
- }
71
- }
72
- }
73
-
74
- fun closeEvent() {
75
- coroutineScope.launch {
76
- alpha.animateTo(
77
- targetValue = 0f,
78
- animationSpec = tween(durationMillis = 200)
79
- )
80
- scale.animateTo(
81
- targetValue = 0.8f,
82
- animationSpec = tween(durationMillis = 200)
83
- )
84
- OverplayComponentRegistry.hardClearAfterDismiss()
85
- }
86
- }
87
-
88
- LaunchedEffect(Unit) {
89
- openEvent()
90
- }
91
-
92
- DisposableEffect(Unit) {
93
- OverplayComponentRegistry.bindClose { closeEvent() }
94
- onDispose {
95
- onDismiss?.invoke()
96
- }
97
- }
98
-
99
- BackHandler(enabled = true) {
100
- closeEvent()
101
- }
102
-
103
- Box(
104
- modifier = Modifier
105
- .fillMaxSize()
106
- .background(Color.Black.copy(alpha = 0.6f * alpha.value))
107
- .noFeedbackClickable {
108
- if(barrierDismissible) closeEvent()
109
- },
110
- contentAlignment = Alignment.Center
111
- ) {
112
- Box(
113
- modifier = Modifier
114
- .scale(scale.value)
115
- .alpha(alpha.value)
116
- .wrapContentSize()
117
- .conditional(IsShowBaseLineDebug) {
118
- border(1.dp, Colors.blue_03)
119
- }
120
- .clickable(
121
- indication = null,
122
- interactionSource = remember { MutableInteractionSource() }
123
- ) {},
124
- contentAlignment = Alignment.Center
125
- ) {
126
- content()
127
- }
128
- }
129
- }
@@ -1,106 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.foundation.gestures.ScrollableState
4
- import androidx.compose.runtime.*
5
- import androidx.compose.ui.graphics.Color
6
- import vn.momo.kits.navigation.bottomtab.setBottomTabOption
7
- import vn.momo.kits.navigation.component.*
8
-
9
- class Navigation(
10
- val id: Int = -1,
11
- val bottomTabIndex: Int = -1,
12
- val initOptions: NavigationOptions? = null,
13
- private val registry: DynamicScreenRegistry? = null
14
- ) {
15
- private val _options = mutableStateOf(initOptions ?: NavigationOptions())
16
- val currentOptions: State<NavigationOptions> get() = _options
17
- val options: NavigationOptions get() = _options.value
18
-
19
- private val _isBottomTabRoot = mutableStateOf(false)
20
- internal val isBottomTabRoot: Boolean get() = _isBottomTabRoot.value
21
- internal fun markAsBottomTabRoot() { _isBottomTabRoot.value = true }
22
-
23
- fun setOptions(
24
- onBackHandler: (() -> Unit)? = null,
25
- hiddenBack: Boolean? = null,
26
- headerBackProps: HeaderBackProps? = null,
27
- headerTitle: HeaderTitle? = null,
28
- titlePosition: TitlePosition? = null,
29
- headerRight: HeaderRight? = null,
30
- headerType: HeaderType? = null,
31
- scrollData: ScrollData? = null,
32
- backgroundColor: Color? = null,
33
- tintColor: Color? = null,
34
- footerComponent: (@Composable () -> Unit)? = null,
35
- footerTransparent: Boolean? = null,
36
- footerUseMargin: Boolean? = null,
37
- floatingButtonProps: FloatingButtonProps? = null,
38
- keyboardOptions: KeyboardOptions? = null
39
- ) {
40
- updateOptions(
41
- options.copy(
42
- onBackHandler = onBackHandler ?: options.onBackHandler,
43
- hiddenBack = hiddenBack ?: options.hiddenBack,
44
- headerBackProps = headerBackProps ?: options.headerBackProps,
45
- headerTitle = headerTitle ?: options.headerTitle,
46
- titlePosition = titlePosition ?: options.titlePosition,
47
- headerRight = headerRight ?: options.headerRight,
48
- headerType = headerType ?: options.headerType,
49
- scrollData = scrollData ?: options.scrollData,
50
- backgroundColor = backgroundColor ?: options.backgroundColor,
51
- tintColor = tintColor ?: options.tintColor,
52
- footerComponent = footerComponent ?: options.footerComponent,
53
- footerTransparent = footerTransparent ?: options.footerTransparent,
54
- footerUseMargin = footerUseMargin ?: options.footerUseMargin,
55
- floatingButtonProps = floatingButtonProps ?: options.floatingButtonProps,
56
- keyboardOptions = keyboardOptions ?: options.keyboardOptions,
57
- )
58
- )
59
- }
60
-
61
- fun setOptions(newOptions: NavigationOptions) {
62
- updateOptions(newOptions)
63
- }
64
-
65
- private fun updateOptions(updated: NavigationOptions) {
66
- _options.value = updated
67
- if (bottomTabIndex != -1) setBottomTabOption(bottomTabIndex, updated)
68
- if (id != -1) registry?.setOptions(id, updated)
69
- }
70
- }
71
-
72
- val LocalNavigation = staticCompositionLocalOf<Navigation> {
73
- error("No NavigationStack provided")
74
- }
75
-
76
- @Stable
77
- data class NavigationOptions(
78
- val screenName: String? = null,
79
- val onBackHandler: (() -> Unit)? = null,
80
- val hiddenBack: Boolean = false,
81
- val headerBackProps: HeaderBackProps = HeaderBackProps(),
82
- val headerTitle: HeaderTitle = HeaderTitle.Default("Stack"),
83
- val titlePosition: TitlePosition = TitlePosition.LEFT,
84
- val headerRight: HeaderRight = HeaderRight.Toolkit(),
85
- val headerType: HeaderType = HeaderType.Default(),
86
- val scrollData: ScrollData = ScrollData(),
87
- val backgroundColor: Color? = null,
88
- val tintColor: Color? = null,
89
- val footerComponent: @Composable (() -> Unit)? = null,
90
- val footerTransparent: Boolean = false,
91
- val footerUseMargin: Boolean = true,
92
- val floatingButtonProps: FloatingButtonProps? = null,
93
- val keyboardOptions: KeyboardOptions = KeyboardOptions()
94
- ) {
95
- internal fun hasFooter() : Boolean = footerComponent != null
96
- }
97
-
98
- data class KeyboardOptions(
99
- val keyboardShouldPersistTaps: Boolean = false,
100
- val useAvoidKeyboard: Boolean = true
101
- )
102
- data class ScrollData(
103
- val scrollable: Boolean = true,
104
- val scrollState: ScrollableState? = null,
105
- val scrollToTopCallback: (() -> Unit)? = null,
106
- )
@@ -1,207 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.animation.core.tween
4
- import androidx.compose.animation.fadeIn
5
- import androidx.compose.animation.slideInVertically
6
- import androidx.compose.animation.slideOutVertically
7
- import androidx.compose.runtime.Composable
8
- import androidx.compose.runtime.CompositionLocalProvider
9
- import androidx.compose.runtime.DisposableEffect
10
- import androidx.compose.runtime.LaunchedEffect
11
- import androidx.compose.runtime.mutableStateOf
12
- import androidx.compose.runtime.remember
13
- import androidx.compose.runtime.saveable.rememberSaveable
14
- import androidx.compose.runtime.staticCompositionLocalOf
15
- import androidx.compose.ui.unit.Dp
16
- import androidx.navigation.compose.NavHost
17
- import androidx.navigation.compose.composable
18
- import androidx.navigation.compose.rememberNavController
19
- import androidx.navigation.toRoute
20
- import kotlinx.coroutines.delay
21
- import kotlinx.coroutines.flow.collectLatest
22
- import vn.momo.kits.application.DesignSystemConfig
23
- import vn.momo.kits.application.KitDesignSystemConfig
24
- import vn.momo.kits.application.LocalContext
25
- import vn.momo.kits.application.LocalDesignSystemConfig
26
- import vn.momo.kits.application.LocalLocalize
27
- import vn.momo.kits.application.Localize
28
- import vn.momo.kits.application.MiniAppContext
29
- import vn.momo.kits.const.AppNavigationBar
30
- import vn.momo.kits.const.AppStatusBar
31
- import vn.momo.kits.const.AppTheme
32
- import vn.momo.kits.const.Theme
33
- import vn.momo.kits.const.defaultTheme
34
- import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
35
- import vn.momo.kits.platform.ProvideOsFontScale
36
- import vn.momo.kits.utils.getAppStatusBarHeight
37
- import vn.momo.kits.utils.getNavigationBarHeight
38
- import vn.momo.maxapi.IMaxApi
39
- import kotlin.time.Duration.Companion.milliseconds
40
-
41
- @Composable
42
- fun NavigationContainer(
43
- initialScreenName: String,
44
- initialScreen: @Composable () -> Unit,
45
- options: NavigationOptions? = null,
46
- initialTheme: Theme = defaultTheme,
47
- miniAppContext: MiniAppContext? = null,
48
- maxApi: IMaxApi? = null,
49
- setNavigator: ((Navigator) -> Unit)? = null,
50
- statusBarHeight: Dp? = null,
51
- localize: Localize? = null,
52
- designSystemConfig: DesignSystemConfig? = null,
53
- ) {
54
- val navController = rememberNavController()
55
- val registry = remember { DynamicScreenRegistry() }
56
- val navigator = remember { Navigator(navController = navController, maxApi = maxApi, registry = registry) }
57
- val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
58
- val navigationBarHeight = getNavigationBarHeight()
59
-
60
- val parentContext = LocalContext.current
61
- val mergedContext = MiniAppContext.merge(parentContext, miniAppContext)
62
-
63
- val stackTransition = remember { StackTransitionCoordinator() }
64
- val theme = remember { mutableStateOf(initialTheme) }
65
- val resolvedDesignSystemConfig =
66
- designSystemConfig ?: LocalDesignSystemConfig.current ?: KitDesignSystemConfig.config
67
- val headerBar = resolvedDesignSystemConfig?.headerBar
68
- // RN parity: the theme's own header image wins; config headerBar is only the fallback.
69
- val resolvedTheme = remember(theme.value, headerBar) {
70
- if (theme.value.isHeaderImage() || headerBar.isNullOrEmpty()) {
71
- theme.value
72
- } else {
73
- theme.value.copy(assets = theme.value.assets.copy(headerBackground = headerBar))
74
- }
75
- }
76
- val fallbackLocalize = remember { Localize() }
77
-
78
- val resolvedLocalize = localize ?: fallbackLocalize
79
-
80
- LaunchedEffect(maxApi, resolvedLocalize) {
81
- val api = maxApi ?: return@LaunchedEffect
82
- runCatching {
83
- api.getLanguage(callback = { data ->
84
- if (parseLanguage(data) == Localize.EN) {
85
- resolvedLocalize.changeLanguage(Localize.EN)
86
- }
87
- })
88
- }
89
- }
90
-
91
- val screenId = rememberSaveable { registry.nextId() }
92
- registry.bind(screenId, initialScreenName, initialScreen, options)
93
- val startDestination = remember(screenId) { DynamicScreenRoute(screenId) }
94
-
95
- ProvideOsFontScale {
96
- ProvideNavigationEventDispatcherOwner {
97
- CompositionLocalProvider(
98
- LocalNavigator provides navigator,
99
- LocalDynamicScreenRegistry provides registry,
100
- LocalMaxApi provides maxApi,
101
- AppTheme provides resolvedTheme,
102
- AppStatusBar provides statusBarHeight,
103
- AppNavigationBar provides navigationBarHeight,
104
- LocalContext provides mergedContext,
105
- LocalDesignSystemConfig provides resolvedDesignSystemConfig,
106
- LocalLocalize provides resolvedLocalize,
107
- LocalStackTransition provides stackTransition,
108
- ) {
109
- LaunchedEffect(Unit) {
110
- setNavigator?.invoke(navigator)
111
- }
112
-
113
- SwipeBackHaptic(maxApi)
114
-
115
- // Gesture pops never reach Navigator.dismissScreen(), so prune the registry from
116
- // the back stack itself. collectLatest lets a rapid re-push cancel a pending prune.
117
- LaunchedEffect(navController, registry) {
118
- navController.currentBackStack.collectLatest { entries ->
119
- delay(STACK_TRANSITION_DURATION.milliseconds)
120
- val aliveIds = entries.mapNotNullTo(mutableSetOf()) { entry ->
121
- runCatching { entry.toRoute<DynamicScreenRoute>().id }.getOrNull()
122
- ?: runCatching { entry.toRoute<DynamicDialogRoute>().id }.getOrNull()
123
- }
124
- aliveIds.add(screenId)
125
- registry.retainOnly(aliveIds)
126
- }
127
- }
128
-
129
- // The transitions must live on the NavHost call site, not on the destinations:
130
- // NavHost.uikit computes isDefaultTransition from these arguments alone, and while
131
- // it is true the library paints its own hard-coded black iOS blackout that would
132
- // sit over the pink scrim.
133
- NavHost(
134
- navController,
135
- startDestination = startDestination,
136
- enterTransition = { stackEnter() },
137
- exitTransition = { stackExit() },
138
- popEnterTransition = { stackPopEnter() },
139
- popExitTransition = { stackPopExit() },
140
- ) {
141
- composable<DynamicScreenRoute> { backStackEntry ->
142
- val route = backStackEntry.toRoute<DynamicScreenRoute>()
143
- val screen = registry.getScreen(route.id)
144
-
145
- if (screen != null) {
146
- StackTransitionDecor(id = route.id, isStackRoute = true) {
147
- StackScreen(
148
- id = route.id,
149
- name = screen.name,
150
- content = screen.content,
151
- navigationOptions = screen.options
152
- )
153
- }
154
- }
155
- }
156
-
157
- composable<DynamicDialogRoute>(
158
- enterTransition = {
159
- slideInVertically(
160
- animationSpec = tween(300),
161
- initialOffsetY = { it }
162
- )
163
- },
164
- exitTransition = null,
165
- popEnterTransition = { fadeIn(animationSpec = tween(0)) },
166
- popExitTransition = {
167
- slideOutVertically(
168
- animationSpec = tween(300),
169
- targetOffsetY = { it }
170
- )
171
- }
172
- ) { backStackEntry ->
173
- val route = backStackEntry.toRoute<DynamicDialogRoute>()
174
- val screen = registry.getScreen(route.id)
175
-
176
- if (screen != null) {
177
- StackTransitionDecor(id = route.id, isStackRoute = false) {
178
- StackScreen(
179
- id = route.id,
180
- name = screen.name,
181
- content = screen.content,
182
- navigationOptions = screen.options
183
- )
184
- }
185
- }
186
- }
187
- }
188
- }
189
- }
190
- }
191
-
192
- DisposableEffect(Unit) {
193
- onDispose {
194
- navigator.dispose()
195
- registry.unregisterScreen(screenId)
196
- }
197
- }
198
- }
199
-
200
- val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> { null }
201
-
202
- private fun parseLanguage(raw: Map<String, Any?>?): String? {
203
- val code = (raw?.get("response") as? String)?.trim()?.lowercase()
204
- if (code.isNullOrEmpty()) return null
205
- return if (code.startsWith(Localize.EN)) Localize.EN else Localize.VI
206
- }
207
-