@momo-kits/native-kits 0.162.3-debug → 0.162.3-fontscale.1

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 (168) hide show
  1. package/.codegraph/.gitignore +5 -0
  2. package/CLAUDE.md +78 -0
  3. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Example.xcscheme +32 -0
  4. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  5. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  6. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/WorkspaceSettings.xcsettings +16 -0
  7. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
  8. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
  9. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
  10. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
  11. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
  12. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
  13. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
  14. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +58 -0
  15. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios.xcscheme +58 -0
  16. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +60 -0
  17. package/ios/Application/Components.swift +1 -0
  18. package/ios/Application/FloatingButton.swift +1 -0
  19. package/ios/Badge/Badge.swift +1 -0
  20. package/ios/Badge/BadgeRibbon.swift +2 -0
  21. package/ios/Button/Button.swift +1 -1
  22. package/ios/Checkbox/Checkbox.swift +1 -0
  23. package/ios/Information/Information.swift +151 -0
  24. package/ios/Input/Input.swift +1 -0
  25. package/ios/Input/InputPhoneNumber.swift +1 -0
  26. package/ios/Input/InputSearch.swift +3 -0
  27. package/ios/Input/InputTextArea.swift +1 -0
  28. package/ios/OTPKeyboard/KeyboardButton.swift +1 -1
  29. package/ios/Popup/PopupDisplay.swift +6 -0
  30. package/ios/Popup/PopupInput.swift +2 -0
  31. package/ios/Template/TrustBanner/TrustBanner.swift +2 -0
  32. package/ios/Typography/Text.swift +1 -0
  33. package/ios/Typography/Typography.swift +14 -5
  34. package/package.json +1 -1
  35. package/build.gradle.kts +0 -11
  36. package/compose/build.gradle.kts +0 -186
  37. package/compose/build.gradle.kts.backup +0 -186
  38. package/compose/compose.podspec +0 -47
  39. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  40. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -123
  41. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  42. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  43. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  44. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  45. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  46. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  47. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  48. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  49. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  50. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  51. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  52. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  53. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  54. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -109
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -305
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -921
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -121
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -403
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -87
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -340
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -198
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -123
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -94
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -136
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -224
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -148
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -116
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -452
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -172
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -255
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -233
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -241
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -92
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -352
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -103
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -338
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -70
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -96
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -348
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -256
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -494
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -131
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -215
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -96
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -531
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -92
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -135
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -214
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -590
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -177
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -192
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -205
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -239
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -285
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -57
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -14
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -50
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -253
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -133
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -104
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -145
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -345
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -556
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -161
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -243
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -187
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -315
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  150. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -34
  151. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -370
  152. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -131
  153. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -167
  154. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -72
  155. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -66
  156. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  157. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -70
  158. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  159. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  160. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -33
  161. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -186
  162. package/gradle/libs.versions.toml +0 -67
  163. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  164. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  165. package/gradle.properties +0 -26
  166. package/gradlew +0 -252
  167. package/gradlew.bat +0 -94
  168. package/settings.gradle.kts +0 -64
@@ -1,345 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.foundation.layout.Box
4
- import androidx.compose.foundation.layout.fillMaxSize
5
- import androidx.compose.runtime.Composable
6
- import androidx.compose.runtime.MutableState
7
- import androidx.compose.runtime.mutableStateOf
8
- import androidx.compose.runtime.staticCompositionLocalOf
9
- import androidx.compose.ui.Alignment
10
- import androidx.compose.ui.Modifier
11
- import androidx.navigation.NavController
12
- import kotlinx.coroutines.CoroutineScope
13
- import kotlinx.coroutines.Dispatchers
14
- import kotlinx.coroutines.SupervisorJob
15
- import kotlinx.coroutines.cancel
16
- import kotlinx.coroutines.delay
17
- import kotlinx.coroutines.launch
18
- import kotlinx.serialization.Serializable
19
- import vn.momo.kits.components.PopupAction
20
- import vn.momo.kits.components.PopupNotify
21
- import vn.momo.kits.navigation.BottomHeader.*
22
- import vn.momo.kits.navigation.component.SnackBar
23
- import vn.momo.maxapi.IMaxApi
24
-
25
- class Navigator(
26
- private val navController: NavController,
27
- private val maxApi: IMaxApi?
28
- ) {
29
- private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
30
-
31
- fun push(screenName: String, content: @Composable () -> Unit, options: NavigationOptions? = null) {
32
- val route = DynamicScreenRegistry.register(screenName, content, options)
33
- navController.navigate(DynamicScreenRoute(route.id))
34
- }
35
-
36
- fun replace(screenName: String, content: @Composable () -> Unit, options: NavigationOptions? = null) {
37
- if (navController.previousBackStackEntry != null){
38
- val latestScreen = DynamicScreenRegistry.getLatestScreen()
39
- latestScreen?.let { DynamicScreenRegistry.unregisterScreen(it.id) }
40
- navController.popBackStack()
41
- push(screenName, content, options)
42
- }
43
- }
44
-
45
- fun onBackSafe(callBack: (() -> Unit)? = null) {
46
- val latestScreen = DynamicScreenRegistry.getLatestScreen()
47
- val options = latestScreen?.options
48
- if (options?.onBackHandler != null) {
49
- options.onBackHandler.invoke()
50
- return
51
- }
52
- val preventBack = options?.headerBackProps?.preventBack
53
- if (preventBack != null) {
54
- showModal(
55
- content = {
56
- PopupNotify(preventBack.copy(
57
- primary = PopupAction(
58
- title = preventBack.primary?.title ?: "",
59
- onPress = {
60
- preventBack.primary?.onPress?.invoke()
61
- pop(2, callBack) // close popup notify, then close the screen
62
- }
63
- )
64
- ))
65
- }
66
- )
67
- } else {
68
- pop(1, callBack)
69
- }
70
- }
71
-
72
- fun pop(count: Int = 1, callBack: (() -> Unit)? = null) {
73
- scope.launch {
74
- repeat(count) {
75
- if (OverplayComponentRegistry.getOverplayType() == OverplayComponentType.SNACK_BAR){
76
- dismissScreen()
77
- OverplayComponentRegistry.hardClearAfterDismiss()
78
- }
79
- else if (OverplayComponentRegistry.isOverplayShowing()){
80
- dismissOverplay()
81
- } else {
82
- dismissScreen()
83
- }
84
- }
85
- callBack?.invoke()
86
- }
87
- }
88
- private suspend fun dismissOverplay(isDelay: Boolean = true) {
89
- OverplayComponentRegistry.clear()
90
- if (isDelay) delay(300L)
91
- OverplayComponentRegistry.hardClearAfterDismiss()
92
- }
93
-
94
- private suspend fun dismissScreen() {
95
- if (navController.previousBackStackEntry != null){
96
- navController.popBackStack()
97
- delay(300L)
98
- DynamicScreenRegistry.getLatestScreen()?.let { it1 ->
99
- DynamicScreenRegistry.unregisterScreen(it1.id)
100
- }
101
- } else {
102
- maxApi?.dismiss { }
103
- }
104
- }
105
-
106
- fun present(screenName: String, content: @Composable () -> Unit, options: NavigationOptions? = null) {
107
- val route = DynamicScreenRegistry.register(screenName, content, options)
108
- navController.navigate(DynamicDialogRoute(route.id))
109
- }
110
-
111
- fun reset(screenName: String, content: @Composable () -> Unit, options: NavigationOptions? = null) {
112
- DynamicScreenRegistry.unregisterAll()
113
-
114
- val route = DynamicScreenRegistry.register(screenName, content, options)
115
- navController.navigate(DynamicScreenRoute(route.id)) {
116
- popUpTo(0) { inclusive = true }
117
- }
118
- }
119
-
120
- fun showModal(
121
- content: @Composable () -> Unit,
122
- barrierDismissible: Boolean = true,
123
- onDismiss: (() -> Unit)? = null
124
- ){
125
- val id = DynamicScreenRegistry.getLatestScreen()?.id ?: -1
126
- OverplayComponentRegistry.registerOverplay(id, content, OverplayComponentType.MODAL, false, barrierDismissible, onDismiss)
127
- }
128
-
129
- fun showBottomSheet(
130
- content: @Composable () -> Unit,
131
- isSurface: Boolean = false,
132
- barrierDismissible: Boolean = true,
133
- onDismiss: (() -> Unit)? = null,
134
- bottomSheetHeader: BottomHeader? = null
135
- ){
136
- val id = DynamicScreenRegistry.getLatestScreen()?.id ?: -1
137
- OverplayComponentRegistry.registerOverplay(id, content, OverplayComponentType.BOTTOM_SHEET, isSurface, barrierDismissible, onDismiss, bottomSheetHeader)
138
- }
139
-
140
- fun showSnackBar(snackBar: SnackBar, onDismiss: (() -> Unit)? = null) {
141
- val id = DynamicScreenRegistry.getLatestScreen()?.id ?: -1
142
- scope.launch {
143
- OverplayComponentRegistry.registerOverplay(
144
- id = id,
145
- content = {
146
- SnackBar(snackBar, onDismiss)
147
- },
148
- type = OverplayComponentType.SNACK_BAR,
149
- onDismiss = onDismiss
150
- )
151
- }
152
- }
153
-
154
- fun hideSnackBar() {
155
- scope.launch {
156
- OverplayComponentRegistry.clear()
157
- delay(250L)
158
- OverplayComponentRegistry.hardClearAfterDismiss()
159
- }
160
- }
161
-
162
- fun dispose(){
163
- scope.cancel()
164
- }
165
- }
166
-
167
- val LocalNavigator = staticCompositionLocalOf<Navigator> {
168
- error("No NavigationStack provided")
169
- }
170
-
171
- @Serializable
172
- data class DynamicScreenRoute(val id: Int)
173
-
174
- @Serializable
175
- data class DynamicDialogRoute(val id: Int)
176
-
177
- data class DynamicScreen(
178
- val id: Int,
179
- val name: String,
180
- val content: @Composable () -> Unit,
181
- var options: NavigationOptions? = null
182
- )
183
-
184
- object DynamicScreenRegistry {
185
- private val screens = mutableMapOf<Int, DynamicScreen>()
186
- private var idCounter = 1
187
-
188
- fun register(screenName: String, content: @Composable () -> Unit, options: NavigationOptions?): DynamicScreenRoute {
189
- val id = idCounter++
190
- screens[id] = DynamicScreen(
191
- id = id,
192
- name = screenName,
193
- content = content,
194
- options = options
195
- )
196
- return DynamicScreenRoute(id)
197
- }
198
-
199
- fun nextId(): Int = idCounter++
200
-
201
- fun bind(id: Int, screenName: String, content: @Composable () -> Unit, options: NavigationOptions?) {
202
- screens[id] = DynamicScreen(
203
- id = id,
204
- name = screenName,
205
- content = content,
206
- options = options
207
- )
208
- if (id >= idCounter) idCounter = id + 1 // keep counter ahead after process-death restore
209
- }
210
-
211
- fun unregisterScreen(id: Int) {
212
- screens.remove(id)
213
- }
214
-
215
- fun getLatestScreen(): DynamicScreen?{
216
- return screens.entries.lastOrNull()?.value
217
- }
218
-
219
- fun unregisterAll(){
220
- val ids = screens.keys.toList()
221
- for (id in ids) {
222
- unregisterScreen(id)
223
- }
224
- }
225
-
226
- fun getScreen(id: Int): DynamicScreen? = screens[id]
227
-
228
- fun setOptions(id: Int, options: NavigationOptions){
229
- screens[id]?.options = options
230
- }
231
- }
232
-
233
-
234
- sealed class OverplayComponentParams {
235
- class Modal(
236
- val onDismiss: (() -> Unit)? = null,
237
- val barrierDismissible: Boolean = true
238
- ) : OverplayComponentParams()
239
-
240
- class BottomSheet(
241
- val isSurface: Boolean = false,
242
- val onDismiss: (() -> Unit)? = null,
243
- val barrierDismissible: Boolean = true,
244
- val bottomSheetHeader: BottomHeader? = null,
245
- ) : OverplayComponentParams()
246
-
247
- class SnackBar() : OverplayComponentParams()
248
- }
249
-
250
- data class OverplayComponent(
251
- val id: Int,
252
- val type: OverplayComponentType? = null,
253
- val content: @Composable () -> Unit,
254
- val params: OverplayComponentParams? = null
255
- )
256
-
257
- enum class OverplayComponentType {
258
- MODAL, BOTTOM_SHEET, SNACK_BAR
259
- }
260
-
261
- object OverplayComponentRegistry {
262
- private var currentOverlayComponent : MutableState<OverplayComponent?> = mutableStateOf(null)
263
- private var requestClose: (() -> Unit)? = null
264
- internal fun bindClose(handler: (() -> Unit)?) {
265
- requestClose = handler
266
- }
267
-
268
- fun registerOverplay(
269
- id: Int,
270
- content: @Composable () -> Unit,
271
- type: OverplayComponentType,
272
- isSurface: Boolean = false,
273
- barrierDismissible: Boolean = true,
274
- onDismiss: (() -> Unit)?,
275
- bottomSheetHeader: BottomHeader? = null,
276
- ){
277
- val params = when(type){
278
- OverplayComponentType.MODAL -> OverplayComponentParams.Modal(onDismiss, barrierDismissible)
279
- OverplayComponentType.BOTTOM_SHEET -> OverplayComponentParams.BottomSheet(isSurface, onDismiss, barrierDismissible, bottomSheetHeader)
280
- OverplayComponentType.SNACK_BAR -> OverplayComponentParams.SnackBar()
281
- }
282
-
283
- currentOverlayComponent.value = OverplayComponent(
284
- id = id,
285
- type = type,
286
- content = content,
287
- params = params
288
- )
289
- }
290
-
291
- fun isOverplayShowing(): Boolean = currentOverlayComponent.value != null
292
-
293
- fun getOverplayType(): OverplayComponentType? = currentOverlayComponent.value?.type
294
-
295
- fun currentRootId(): Int? = currentOverlayComponent.value?.id
296
-
297
- fun clear(){
298
- if (requestClose != null) {
299
- requestClose?.invoke()
300
- } else {
301
- currentOverlayComponent.value = null
302
- }
303
- }
304
-
305
- internal fun hardClearAfterDismiss() {
306
- currentOverlayComponent.value = null
307
- requestClose = null
308
- }
309
-
310
- @Composable
311
- fun OverlayComponent(){
312
- val overplay = currentOverlayComponent.value ?: return
313
-
314
- when (val params = overplay.params) {
315
- is OverplayComponentParams.BottomSheet -> {
316
- BottomSheet(
317
- content = overplay.content,
318
- header = params.bottomSheetHeader ?: Title(),
319
- isSurface = params.isSurface,
320
- barrierDismissible = params.barrierDismissible,
321
- onDismiss = params.onDismiss
322
- )
323
- }
324
-
325
- is OverplayComponentParams.Modal -> {
326
- ModalScreen(
327
- content = overplay.content,
328
- barrierDismissible = params.barrierDismissible,
329
- onDismiss = params.onDismiss
330
- )
331
- }
332
-
333
- is OverplayComponentParams.SnackBar -> {
334
- Box(
335
- modifier = Modifier.fillMaxSize(),
336
- contentAlignment = Alignment.BottomCenter
337
- ) {
338
- overplay.content()
339
- }
340
- }
341
-
342
- null -> {}
343
- }
344
- }
345
- }
@@ -1,8 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.runtime.Composable
4
-
5
- @Composable
6
- internal expect fun RegisterScrollToTop(callback: (() -> Unit)?)
7
-
8
-