@momo-kits/native-kits 0.162.2-test.9-debug → 0.162.2-test.9

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 (135) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -186
  4. package/compose/build.gradle.kts.backup +0 -186
  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/Platform.android.kt +0 -123
  8. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -116
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -305
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -921
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -121
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -403
  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 -85
  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 -340
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -198
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -123
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -94
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -136
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -224
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  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 -148
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -116
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -452
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -172
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -255
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -233
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -241
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  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 -92
  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 -352
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -103
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -338
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -70
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -96
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -348
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -256
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -494
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -131
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -215
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -96
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -531
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -92
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -138
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -214
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -590
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -177
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -192
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -205
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -239
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -290
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -57
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -14
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -50
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -253
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -133
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -104
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -184
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -345
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -556
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -161
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -243
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -187
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -315
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -34
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -370
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -131
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -167
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -72
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -66
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -70
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -33
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -186
  128. package/gradle/libs.versions.toml +0 -67
  129. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  130. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  131. package/gradle.properties +0 -26
  132. package/gradlew +0 -252
  133. package/gradlew.bat +0 -94
  134. package/local.properties +0 -8
  135. package/settings.gradle.kts +0 -64
@@ -1,253 +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.gestures.detectDragGestures
9
- import androidx.compose.foundation.layout.Box
10
- import androidx.compose.foundation.layout.BoxWithConstraints
11
- import androidx.compose.foundation.layout.Column
12
- import androidx.compose.foundation.layout.Row
13
- import androidx.compose.foundation.layout.Spacer
14
- import androidx.compose.foundation.layout.fillMaxHeight
15
- import androidx.compose.foundation.layout.fillMaxSize
16
- import androidx.compose.foundation.layout.fillMaxWidth
17
- import androidx.compose.foundation.layout.height
18
- import androidx.compose.foundation.layout.heightIn
19
- import androidx.compose.foundation.layout.offset
20
- import androidx.compose.foundation.layout.padding
21
- import androidx.compose.foundation.layout.size
22
- import androidx.compose.foundation.layout.width
23
- import androidx.compose.foundation.shape.RoundedCornerShape
24
- import androidx.compose.runtime.Composable
25
- import androidx.compose.runtime.DisposableEffect
26
- import androidx.compose.runtime.LaunchedEffect
27
- import androidx.compose.runtime.remember
28
- import androidx.compose.runtime.rememberCoroutineScope
29
- import androidx.compose.ui.Alignment
30
- import androidx.compose.ui.Modifier
31
- import androidx.compose.ui.graphics.Color
32
- import androidx.compose.ui.input.pointer.pointerInput
33
- import androidx.compose.ui.platform.LocalDensity
34
- import androidx.compose.ui.unit.IntOffset
35
- import androidx.compose.ui.unit.dp
36
- import kotlinx.coroutines.launch
37
- import vn.momo.kits.components.Divider
38
- import vn.momo.kits.components.Icon
39
- import vn.momo.kits.components.Text
40
- import vn.momo.kits.const.AppTheme
41
- import vn.momo.kits.const.Colors
42
- import vn.momo.kits.const.Radius
43
- import vn.momo.kits.const.Spacing
44
- import vn.momo.kits.application.ApplicationContext
45
- import vn.momo.kits.application.IsShowBaseLineDebug
46
- import vn.momo.kits.const.Typography
47
- import vn.momo.kits.navigation.tracking.ScreenTracker
48
- import vn.momo.kits.modifier.conditional
49
- import vn.momo.kits.modifier.noFeedbackClickable
50
- import vn.momo.kits.platform.BackHandler
51
- import vn.momo.kits.platform.getScreenHeight
52
-
53
- @Composable
54
- internal fun BottomSheet(
55
- content: @Composable () -> Unit,
56
- header: BottomHeader,
57
- isSurface: Boolean = false,
58
- barrierDismissible: Boolean = true,
59
- onDismiss: (() -> Unit)?
60
- ) {
61
- val navigator = LocalNavigator.current
62
-
63
- val screenHeightDp = getScreenHeight()
64
- val screenHeightPx = with(LocalDensity.current) { screenHeightDp.toPx() }
65
- val sheetOffset = remember { Animatable(screenHeightPx) }
66
-
67
- val backgroundAlpha = remember { Animatable(0f) }
68
- val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.3f
69
- val alpha = backgroundAlpha.value + dynamicAlpha
70
-
71
- val sheetCloseOffset = with(LocalDensity.current) { 100.dp.toPx() }
72
-
73
- val coroutineScope = rememberCoroutineScope()
74
-
75
- val maxApi = LocalMaxApi.current
76
- val context = ApplicationContext.current
77
-
78
- DisposableEffect(Unit) {
79
- ScreenTracker.trackPopupDisplayed(
80
- maxApi = maxApi,
81
- context = context,
82
- parentScreenName = ScreenTracker.getLastScreenName()
83
- )
84
- onDispose { }
85
- }
86
-
87
- suspend fun openEvent(){
88
- backgroundAlpha.animateTo(
89
- targetValue = 0.3f,
90
- animationSpec = tween(
91
- durationMillis = 100,
92
- easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
93
- )
94
- )
95
- sheetOffset.animateTo(
96
- targetValue = 0f,
97
- animationSpec = tween(
98
- durationMillis = 350,
99
- easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
100
- )
101
- )
102
- }
103
-
104
- fun closeEvent(){
105
- coroutineScope.launch {
106
- sheetOffset.animateTo(
107
- targetValue = screenHeightPx,
108
- animationSpec = tween(
109
- durationMillis = 200,
110
- easing = CubicBezierEasing(0.3f, 0.0f, 0.8f, 0.15f)
111
- )
112
- )
113
- backgroundAlpha.animateTo(
114
- targetValue = 0f,
115
- animationSpec = tween(
116
- durationMillis = 100,
117
- easing = CubicBezierEasing(0.3f, 0.0f, 0.8f, 0.15f)
118
- )
119
- )
120
- navigator.pop()
121
- }
122
- }
123
-
124
- LaunchedEffect(Unit) {
125
- openEvent()
126
- }
127
-
128
- DisposableEffect(Unit) {
129
- OverplayComponentRegistry.bindClose { closeEvent() }
130
- onDispose {
131
- onDismiss?.invoke()
132
- }
133
- }
134
-
135
- BackHandler(true){
136
- closeEvent()
137
- }
138
-
139
- BoxWithConstraints(
140
- modifier = Modifier
141
- .fillMaxSize()
142
- .background(Color.Black.copy(alpha = alpha))
143
- .noFeedbackClickable {
144
- if(barrierDismissible) closeEvent()
145
- }
146
- ) {
147
- val parentHeight = with(LocalDensity.current) { constraints.maxHeight.toDp() }
148
-
149
- Box(
150
- modifier = Modifier
151
- .align(Alignment.BottomCenter)
152
- .offset { IntOffset(x = 0, y = sheetOffset.value.toInt()) }
153
- .fillMaxWidth()
154
- .heightIn(max = parentHeight - 90.dp)
155
- .background(
156
- color = if (isSurface) AppTheme.current.colors.background.surface else AppTheme.current.colors.background.default,
157
- shape = RoundedCornerShape(topStart = Radius.M, topEnd = Radius.M)
158
- )
159
- .conditional(IsShowBaseLineDebug) {
160
- border(1.dp, Colors.blue_03)
161
- }
162
- .noFeedbackClickable { },
163
- contentAlignment = Alignment.BottomCenter
164
- ) {
165
- Column {
166
- Box(
167
- modifier = Modifier
168
- .height(72.dp)
169
- .fillMaxWidth()
170
- .pointerInput(Unit) {
171
- detectDragGestures(
172
- onDrag = { change, dragAmount ->
173
- change.consume()
174
- coroutineScope.launch {
175
- val newOffset = (sheetOffset.value + dragAmount.y).coerceAtLeast(0f)
176
- sheetOffset.snapTo(newOffset)
177
- }
178
- },
179
- onDragEnd = {
180
- coroutineScope.launch {
181
- if (sheetOffset.value > sheetCloseOffset) {
182
- closeEvent()
183
- } else {
184
- sheetOffset.animateTo(0f)
185
- }
186
- }
187
- }
188
- )
189
- }
190
- ) {
191
- Column(
192
- modifier = Modifier
193
- .fillMaxSize()
194
- .padding(horizontal = Spacing.M),
195
- horizontalAlignment = Alignment.CenterHorizontally
196
- ) {
197
- Spacer(Modifier.height(8.dp))
198
- Box(
199
- modifier = Modifier
200
- .height(4.dp)
201
- .width(40.dp)
202
- .background(
203
- color = Colors.black_06,
204
- shape = RoundedCornerShape(Radius.S)
205
- )
206
- )
207
- Spacer(Modifier.height(4.dp))
208
- Box(Modifier.fillMaxWidth().height(56.dp), contentAlignment = Alignment.Center){
209
- when (header) {
210
- is BottomHeader.Title -> {
211
- Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
212
- Box(Modifier.size(24.dp))
213
- Box(Modifier.fillMaxHeight().weight(1f), contentAlignment = Alignment.Center){
214
- Text(
215
- text = header.data,
216
- color = Colors.black_17,
217
- style = Typography.headerDefaultBold
218
- )
219
- }
220
- Box(Modifier
221
- .size(24.dp)
222
- .noFeedbackClickable {
223
- closeEvent()
224
- },
225
- contentAlignment = Alignment.Center
226
- ){
227
- Icon(source = "navigation_close")
228
- }
229
- }
230
- }
231
- is BottomHeader.Custom -> {
232
- header.content()
233
- }
234
- }
235
- }
236
- }
237
- }
238
- Divider()
239
- content()
240
- }
241
- }
242
- }
243
- }
244
-
245
- sealed class BottomHeader {
246
- data class Title(
247
- val data: String = "Bottom Sheet Title",
248
- ) : BottomHeader()
249
-
250
- data class Custom(
251
- val content: @Composable () -> Unit
252
- ) : BottomHeader()
253
- }
@@ -1,133 +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.Composable
14
- import androidx.compose.runtime.DisposableEffect
15
- import androidx.compose.runtime.LaunchedEffect
16
- import androidx.compose.runtime.remember
17
- import androidx.compose.runtime.rememberCoroutineScope
18
- import androidx.compose.ui.Alignment
19
- import androidx.compose.ui.Modifier
20
- import androidx.compose.ui.draw.alpha
21
- import androidx.compose.ui.draw.scale
22
- import androidx.compose.ui.graphics.Color
23
- import androidx.compose.ui.unit.dp
24
- import kotlinx.coroutines.launch
25
- import vn.momo.kits.application.ApplicationContext
26
- import vn.momo.kits.application.IsShowBaseLineDebug
27
- import vn.momo.kits.const.Colors
28
- import vn.momo.kits.modifier.conditional
29
- import vn.momo.kits.modifier.noFeedbackClickable
30
- import vn.momo.kits.navigation.tracking.ScreenTracker
31
- import vn.momo.kits.platform.BackHandler
32
-
33
- @Composable
34
- internal fun ModalScreen(
35
- content: @Composable () -> Unit,
36
- barrierDismissible: Boolean = true,
37
- onDismiss: (() -> Unit)? = null
38
- ) {
39
- val navigator = LocalNavigator.current
40
-
41
- val alpha = remember { Animatable(0f) }
42
- val scale = remember { Animatable(0.8f) }
43
-
44
- val coroutineScope = rememberCoroutineScope()
45
-
46
- val maxApi = LocalMaxApi.current
47
- val context = ApplicationContext.current
48
-
49
- DisposableEffect(Unit) {
50
- ScreenTracker.trackPopupDisplayed(
51
- maxApi = maxApi,
52
- context = context,
53
- parentScreenName = ScreenTracker.getLastScreenName()
54
- )
55
- onDispose { }
56
- }
57
-
58
- fun openEvent() {
59
- coroutineScope.launch {
60
- launch {
61
- alpha.animateTo(
62
- targetValue = 1f,
63
- animationSpec = tween(durationMillis = 250)
64
- )
65
- }
66
- launch {
67
- scale.animateTo(
68
- targetValue = 1f,
69
- animationSpec = tween(
70
- durationMillis = 250,
71
- easing = CubicBezierEasing(0.2f, 0.0f, 0f, 1f)
72
- )
73
- )
74
- }
75
- }
76
- }
77
-
78
- fun closeEvent() {
79
- coroutineScope.launch {
80
- alpha.animateTo(
81
- targetValue = 0f,
82
- animationSpec = tween(durationMillis = 200)
83
- )
84
- scale.animateTo(
85
- targetValue = 0.8f,
86
- animationSpec = tween(durationMillis = 200)
87
- )
88
- navigator.pop()
89
- }
90
- }
91
-
92
- LaunchedEffect(Unit) {
93
- openEvent()
94
- }
95
-
96
- DisposableEffect(Unit) {
97
- OverplayComponentRegistry.bindClose { closeEvent() }
98
- onDispose {
99
- onDismiss?.invoke()
100
- }
101
- }
102
-
103
- BackHandler(enabled = true) {
104
- closeEvent()
105
- }
106
-
107
- Box(
108
- modifier = Modifier
109
- .fillMaxSize()
110
- .background(Color.Black.copy(alpha = 0.6f * alpha.value))
111
- .noFeedbackClickable {
112
- if(barrierDismissible) closeEvent()
113
- },
114
- contentAlignment = Alignment.Center
115
- ) {
116
- Box(
117
- modifier = Modifier
118
- .scale(scale.value)
119
- .alpha(alpha.value)
120
- .wrapContentSize()
121
- .conditional(IsShowBaseLineDebug) {
122
- border(1.dp, Colors.blue_03)
123
- }
124
- .clickable(
125
- indication = null,
126
- interactionSource = remember { MutableInteractionSource() }
127
- ) {},
128
- contentAlignment = Alignment.Center
129
- ) {
130
- content()
131
- }
132
- }
133
- }
@@ -1,104 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.foundation.gestures.ScrollableState
4
- import androidx.compose.runtime.Composable
5
- import androidx.compose.runtime.Stable
6
- import androidx.compose.runtime.State
7
- import androidx.compose.runtime.mutableStateOf
8
- import androidx.compose.runtime.staticCompositionLocalOf
9
- import androidx.compose.ui.graphics.Color
10
- import vn.momo.kits.navigation.bottomtab.setBottomTabOption
11
- import vn.momo.kits.navigation.component.FloatingButtonProps
12
- import vn.momo.kits.navigation.component.HeaderBackProps
13
- import vn.momo.kits.navigation.component.HeaderRight
14
- import vn.momo.kits.navigation.component.HeaderTitle
15
- import vn.momo.kits.navigation.component.HeaderType
16
- import vn.momo.kits.navigation.component.TitlePosition
17
-
18
- class Navigation(
19
- val id: Int = -1,
20
- val bottomTabIndex: Int = -1,
21
- val initOptions: NavigationOptions? = null
22
- ) {
23
- private val _options = mutableStateOf(initOptions ?: NavigationOptions())
24
- val currentOptions: State<NavigationOptions> get() = _options
25
- val options: NavigationOptions get() = _options.value
26
-
27
- fun setOptions(
28
- onBackHandler: (() -> Unit)? = null,
29
- hiddenBack: Boolean? = null,
30
- headerBackProps: HeaderBackProps? = null,
31
- headerTitle: HeaderTitle? = null,
32
- titlePosition: TitlePosition? = null,
33
- headerRight: HeaderRight? = null,
34
- headerType: HeaderType? = null,
35
- scrollData: ScrollData? = null,
36
- backgroundColor: Color? = null,
37
- tintColor: Color? = null,
38
- footerComponent: (@Composable () -> Unit)? = null,
39
- floatingButtonProps: FloatingButtonProps? = null,
40
- keyboardOptions: KeyboardOptions? = null
41
- ) {
42
- updateOptions(
43
- options.copy(
44
- onBackHandler = onBackHandler ?: options.onBackHandler,
45
- hiddenBack = hiddenBack ?: options.hiddenBack,
46
- headerBackProps = headerBackProps ?: options.headerBackProps,
47
- headerTitle = headerTitle ?: options.headerTitle,
48
- titlePosition = titlePosition ?: options.titlePosition,
49
- headerRight = headerRight ?: options.headerRight,
50
- headerType = headerType ?: options.headerType,
51
- scrollData = scrollData ?: options.scrollData,
52
- backgroundColor = backgroundColor ?: options.backgroundColor,
53
- tintColor = tintColor ?: options.tintColor,
54
- footerComponent = footerComponent ?: options.footerComponent,
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) DynamicScreenRegistry.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 floatingButtonProps: FloatingButtonProps? = null,
91
- val keyboardOptions: KeyboardOptions = KeyboardOptions()
92
- )
93
-
94
- data class KeyboardOptions(
95
- val keyboardShouldPersistTaps: Boolean = false,
96
- val useAvoidKeyboard: Boolean = true
97
- )
98
-
99
-
100
- data class ScrollData(
101
- val scrollable: Boolean = true,
102
- val scrollState: ScrollableState? = null,
103
- val scrollToTopCallback: (() -> Unit)? = null,
104
- )
@@ -1,184 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.animation.*
4
- import androidx.compose.animation.core.tween
5
- import androidx.compose.runtime.*
6
- import androidx.compose.runtime.saveable.rememberSaveable
7
- import androidx.compose.ui.unit.Dp
8
- import androidx.navigation.compose.NavHost
9
- import androidx.navigation.compose.composable
10
- import androidx.navigation.compose.rememberNavController
11
- import androidx.navigation.toRoute
12
- import kotlinx.coroutines.flow.collect
13
- import vn.momo.kits.application.*
14
- import vn.momo.kits.const.*
15
- import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
16
- import vn.momo.kits.utils.getAppStatusBarHeight
17
- import vn.momo.kits.utils.getNavigationBarHeight
18
- import vn.momo.maxapi.IMaxApi
19
-
20
- @Composable
21
- fun NavigationContainer(
22
- initialScreenName: String,
23
- initialScreen: @Composable () -> Unit,
24
- options: NavigationOptions? = null,
25
- initialTheme: Theme = defaultTheme,
26
- applicationContext: MiniAppContext? = null,
27
- maxApi: IMaxApi? = null,
28
- setNavigator: ((Navigator) -> Unit)? = null,
29
- statusBarHeight: Dp? = null,
30
- config: KitConfig? = null,
31
- language: String? = null
32
- ){
33
- val navController = rememberNavController()
34
- val navigator = remember { Navigator(navController = navController, maxApi = maxApi) }
35
- val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
36
- val navigationBarHeight = getNavigationBarHeight()
37
-
38
- val parentContext = ApplicationContext.current
39
- val mergedContext = MiniAppContext.merge(parentContext, applicationContext)
40
-
41
- // Default = the host-seeded fontScaleConfig from the merged context, so the first frame is
42
- // already scaled (no flash). The observer below overwrites it on later host writes (live rate
43
- // changes); a null emit (host cleared) falls back to the ambient LocalFontScaleConfig default.
44
- var observerFontScaleConfig by remember { mutableStateOf(mergedContext?.fontScaleConfig) }
45
- LaunchedEffect(maxApi) {
46
- val api = maxApi ?: return@LaunchedEffect
47
- runCatching {
48
- api.observer(FONT_SCALE_OBSERVER_KEY).collect { data ->
49
- observerFontScaleConfig = parseFontScaleConfig(data)
50
- }
51
- }
52
- }
53
-
54
- val theme = remember { mutableStateOf(initialTheme) }
55
-
56
- LaunchedEffect(Unit) {
57
- val headerBar = config?.headerBar
58
- if (headerBar != null && theme.value.assets.headerBackground == null) {
59
- theme.value = theme.value.copy(
60
- assets = ThemeAssets(
61
- headerBackground = headerBar
62
- )
63
- )
64
- }
65
- }
66
-
67
- val screenId = rememberSaveable { DynamicScreenRegistry.nextId() }
68
- DynamicScreenRegistry.bind(screenId, initialScreenName, initialScreen, options)
69
- val startDestination = remember(screenId) { DynamicScreenRoute(screenId) }
70
-
71
- ProvideNavigationEventDispatcherOwner {
72
- CompositionLocalProvider(
73
- LocalNavigator provides navigator,
74
- LocalMaxApi provides maxApi,
75
- AppTheme provides theme.value,
76
- AppStatusBar provides statusBarHeight,
77
- AppNavigationBar provides navigationBarHeight,
78
- ApplicationContext provides mergedContext,
79
- AppConfig provides config,
80
- AppLanguage provides language,
81
- LocalFontScaleConfig provides (observerFontScaleConfig ?: LocalFontScaleConfig.current),
82
- ) {
83
- LaunchedEffect(Unit) {
84
- setNavigator?.invoke(navigator)
85
- }
86
-
87
- NavHost(navController, startDestination = startDestination) {
88
- composable<DynamicScreenRoute>(
89
- enterTransition = {
90
- slideInHorizontally(
91
- animationSpec = tween(300),
92
- initialOffsetX = { it }
93
- )
94
- },
95
- exitTransition = null,
96
- popEnterTransition = { fadeIn(animationSpec = tween(0)) },
97
- popExitTransition = {
98
- slideOutHorizontally(
99
- animationSpec = tween(300),
100
- targetOffsetX = { it }
101
- )
102
- }
103
- ) { backStackEntry ->
104
- val route = backStackEntry.toRoute<DynamicScreenRoute>()
105
- val screen = DynamicScreenRegistry.getScreen(route.id)
106
-
107
- if (screen != null) {
108
- StackScreen(
109
- id = route.id,
110
- name = screen.name,
111
- content = screen.content,
112
- navigationOptions = screen.options
113
- )
114
- }
115
- }
116
-
117
- composable<DynamicDialogRoute>(
118
- enterTransition = {
119
- slideInVertically(
120
- animationSpec = tween(300),
121
- initialOffsetY = { it }
122
- )
123
- },
124
- exitTransition = null,
125
- popEnterTransition = { fadeIn(animationSpec = tween(0)) },
126
- popExitTransition = {
127
- slideOutVertically(
128
- animationSpec = tween(300),
129
- targetOffsetY = { it }
130
- )
131
- }
132
- ) { backStackEntry ->
133
- val route = backStackEntry.toRoute<DynamicDialogRoute>()
134
- val screen = DynamicScreenRegistry.getScreen(route.id)
135
-
136
- if (screen != null) {
137
- StackScreen(
138
- id = route.id,
139
- name = screen.name,
140
- content = screen.content,
141
- navigationOptions = screen.options
142
- )
143
- }
144
- }
145
- }
146
- }
147
- }
148
-
149
- DisposableEffect(Unit) {
150
- onDispose {
151
- navigator.dispose()
152
- DynamicScreenRegistry.unregisterScreen(screenId)
153
- }
154
- }
155
- }
156
-
157
- val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> {
158
- error("No MaxApi provided")
159
- }
160
-
161
- // Observer storage key the host app writes FontScaleConfig to. Lowercased natively.
162
- private const val FONT_SCALE_OBSERVER_KEY = "font_scale_config"
163
-
164
- // Host returns object {useOSFontScale, userScaleRate}; guard against envelope wrapping / type mismatch from marshaling.
165
- private fun parseFontScaleConfig(raw: Map<String, Any?>?): FontScaleConfig? {
166
- if (raw.isNullOrEmpty()) return null
167
- @Suppress("UNCHECKED_CAST")
168
- val data = (raw["response"] as? Map<String, Any?>)
169
- ?: (raw["data"] as? Map<String, Any?>)
170
- ?: raw
171
- if (!data.containsKey("useOSFontScale") && !data.containsKey("userScaleRate")) return null
172
- val useOS = when (val v = data["useOSFontScale"]) {
173
- is Boolean -> v
174
- is String -> v.equals("true", ignoreCase = true)
175
- is Number -> v.toInt() != 0
176
- else -> false
177
- }
178
- val rate = when (val v = data["userScaleRate"]) {
179
- is Number -> v.toFloat()
180
- is String -> v.toFloatOrNull()
181
- else -> null
182
- }
183
- return FontScaleConfig(useOSFontScale = useOS, userScaleRate = rate)
184
- }