@momo-kits/native-kits 0.162.1-debug → 0.162.1-sp.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 (148) hide show
  1. package/.claude/settings.local.json +35 -0
  2. package/ios/Information/Information.swift +151 -0
  3. package/package.json +1 -1
  4. package/publish.sh +2 -2
  5. package/build.gradle.kts +0 -11
  6. package/compose/build.gradle.kts +0 -186
  7. package/compose/build.gradle.kts.backup +0 -186
  8. package/compose/compose.podspec +0 -47
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -123
  11. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  12. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  22. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  23. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  24. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -109
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -305
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -921
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -121
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -403
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -85
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -340
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -198
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -123
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -94
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -136
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -224
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -148
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -116
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -452
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -172
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -255
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -233
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -241
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -92
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -352
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -103
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -338
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -70
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -96
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -348
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -256
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -494
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -131
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -215
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -96
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -531
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -92
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -135
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -214
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -590
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -177
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -192
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -205
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -239
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  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 -285
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -57
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  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 -14
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -50
  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 -253
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -133
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -100
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -145
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -345
  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 -556
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -161
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -243
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -187
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -279
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -32
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -370
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -131
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -167
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -72
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -66
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -70
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -33
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -186
  132. package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  133. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  134. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
  135. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
  136. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
  137. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
  138. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
  139. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
  140. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
  141. package/gradle/libs.versions.toml +0 -67
  142. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  143. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  144. package/gradle.properties +0 -26
  145. package/gradlew +0 -252
  146. package/gradlew.bat +0 -94
  147. package/local.properties +0 -8
  148. 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
-