@momo-kits/native-kits 0.163.1-beta.5-debug → 0.163.1-beta.5

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