@momo-kits/native-kits 0.162.47-debug → 0.162.48

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 (138) hide show
  1. package/CLAUDE.md +1 -1
  2. package/ios/Layout/ScreenLayout.swift +41 -11
  3. package/ios/Popup/PopupLayout.swift +0 -2
  4. package/package.json +1 -1
  5. package/build.gradle.kts +0 -11
  6. package/compose/build.gradle.kts +0 -198
  7. package/compose/build.gradle.kts.backup +0 -198
  8. package/compose/compose.podspec +0 -47
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -314
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -399
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -228
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -377
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -13
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -94
  131. package/gradle/libs.versions.toml +0 -69
  132. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  133. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  134. package/gradle.properties +0 -26
  135. package/gradlew +0 -252
  136. package/gradlew.bat +0 -94
  137. package/ios-demo/README.md +0 -120
  138. package/settings.gradle.kts +0 -64
@@ -1,343 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.animation.core.*
4
- import androidx.compose.foundation.Canvas
5
- import androidx.compose.foundation.OverscrollEffect
6
- import androidx.compose.foundation.background
7
- import androidx.compose.foundation.gestures.FlingBehavior
8
- import androidx.compose.foundation.gestures.ScrollableDefaults
9
- import androidx.compose.foundation.layout.*
10
- import androidx.compose.foundation.lazy.*
11
- import androidx.compose.material.ExperimentalMaterialApi
12
- import androidx.compose.material.pullrefresh.PullRefreshIndicator
13
- import androidx.compose.material.pullrefresh.pullRefresh
14
- import androidx.compose.material.pullrefresh.rememberPullRefreshState
15
- import androidx.compose.runtime.*
16
- import androidx.compose.ui.Alignment
17
- import androidx.compose.ui.Modifier
18
- import androidx.compose.ui.composed
19
- import androidx.compose.ui.geometry.CornerRadius
20
- import androidx.compose.ui.geometry.Offset
21
- import androidx.compose.ui.geometry.Size
22
- import androidx.compose.ui.graphics.Color
23
- import androidx.compose.ui.graphics.drawscope.rotate
24
- import androidx.compose.ui.hapticfeedback.HapticFeedbackType
25
- import androidx.compose.ui.layout.Measurable
26
- import androidx.compose.ui.layout.MeasureResult
27
- import androidx.compose.ui.layout.MeasureScope
28
- import androidx.compose.ui.layout.layout
29
- import androidx.compose.ui.platform.LocalDensity
30
- import androidx.compose.ui.platform.LocalHapticFeedback
31
- import androidx.compose.ui.unit.Constraints
32
- import androidx.compose.ui.unit.IntOffset
33
- import androidx.compose.ui.unit.dp
34
- import kotlinx.coroutines.flow.collect
35
- import kotlinx.coroutines.flow.combine
36
- import kotlinx.coroutines.flow.distinctUntilChanged
37
- import vn.momo.kits.const.Spacing
38
- import vn.momo.kits.modifier.conditional
39
- import vn.momo.kits.platform.getPlatformName
40
-
41
- private const val BOX_KEY = "LazyColumnWithBouncing_BOX_KEY"
42
-
43
-
44
- @OptIn(ExperimentalMaterialApi::class)
45
- @Composable
46
- internal fun overScrollWithPullToRefresh(
47
- pullRefreshState: PullToRefreshCustomState?,
48
- ): OverscrollEffect {
49
- val density = LocalDensity.current
50
- val hapticFeedback = LocalHapticFeedback.current
51
-
52
- return remember(density) {
53
- CupertinoOverscrollEffect(
54
- pullRefreshState = if (pullRefreshState != null && pullRefreshState.sendHaptic != null) pullRefreshState
55
- else pullRefreshState?.copy(
56
- sendHaptic = {
57
- hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
58
- }),
59
- density = density.density,
60
- applyClip = false,
61
- )
62
- }
63
- }
64
-
65
- @OptIn(ExperimentalMaterialApi::class)
66
- @Composable
67
- fun LazyColumnWithBouncing(
68
- modifier: Modifier = Modifier,
69
- modifierIndicator: Modifier = Modifier,
70
- state: LazyListState = rememberLazyListState(),
71
- contentPadding: PaddingValues = PaddingValues(0.dp),
72
- reverseLayout: Boolean = false,
73
- verticalArrangement: Arrangement.Vertical = if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
74
- horizontalAlignment: Alignment.Horizontal = Alignment.Start,
75
- flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
76
- userScrollEnabled: Boolean = true,
77
- pullRefreshState: PullToRefreshCustomState? = null,
78
- content: LazyListScope.() -> Unit,
79
- ) {
80
- val height = remember { mutableIntStateOf(0) }
81
- val maxConstraint = remember { mutableIntStateOf(0) }
82
-
83
- LaunchedEffect(Unit) {
84
- val addOn = 1
85
- combine(
86
- snapshotFlow { maxConstraint.value }.distinctUntilChanged(),
87
- snapshotFlow { state.layoutInfo }
88
- ) { cHeight, layoutInfo ->
89
- height.value = when {
90
- height.value == 0 && (state.canScrollForward || state.canScrollBackward) -> 0
91
- layoutInfo.viewportSize.height >= cHeight && height.value == 0 -> 0
92
- layoutInfo.visibleItemsInfo.lastOrNull()?.key != BOX_KEY -> 0
93
- else -> {
94
- val vH = layoutInfo.totalHeight
95
- (cHeight - (vH - height.value) + addOn).coerceIn(0, cHeight)
96
- }
97
- }
98
- }.collect()
99
- }
100
-
101
- val measureLayout =
102
- remember<MeasureScope.(Measurable, Constraints) -> MeasureResult>(maxConstraint) {
103
- { m, c ->
104
- val p = m.measure(c.copy(minHeight = 0))
105
- maxConstraint.value = c.maxHeight
106
- layout(p.width, p.height) {
107
- p.place(IntOffset.Zero)
108
- }
109
- }
110
- }
111
-
112
- if (getPlatformName() == "iOS") {
113
-
114
- val overscroll = overScrollWithPullToRefresh(
115
- pullRefreshState = remember {
116
- pullRefreshState
117
- })
118
-
119
- Box {
120
- IosIndicator(
121
- effect = overscroll,
122
- modifier = modifierIndicator.align(Alignment.TopCenter).padding(top = Spacing.L).size(24.dp),
123
- )
124
- LazyColumn(
125
- modifier = modifier
126
- .layout(measure = measureLayout),
127
- state = state,
128
- contentPadding = contentPadding,
129
- flingBehavior = flingBehavior,
130
- horizontalAlignment = horizontalAlignment,
131
- verticalArrangement = verticalArrangement,
132
- reverseLayout = reverseLayout,
133
- userScrollEnabled = userScrollEnabled,
134
- overscrollEffect = overscroll,
135
- ) {
136
- content()
137
- item(key = BOX_KEY) {
138
- FakeBox(height)
139
- }
140
- }
141
- }
142
- } else {
143
- val pullState = rememberPullRefreshState(
144
- refreshing = pullRefreshState?.refreshingState?.value ?: false,
145
- onRefresh = {
146
- pullRefreshState?.onRefresh()
147
- },
148
- )
149
-
150
- Box(
151
- contentAlignment = Alignment.TopCenter,
152
- modifier = Modifier.conditional(pullRefreshState != null) {
153
- pullRefresh(pullState)
154
- }) {
155
- LazyColumn(
156
- modifier = modifier.calculateHeight(height),
157
- state = state,
158
- contentPadding = contentPadding,
159
- flingBehavior = flingBehavior,
160
- horizontalAlignment = horizontalAlignment,
161
- verticalArrangement = verticalArrangement,
162
- reverseLayout = reverseLayout,
163
- userScrollEnabled = userScrollEnabled,
164
- ) {
165
- content()
166
- }
167
- if (pullRefreshState != null) {
168
- PullRefreshIndicator(
169
- pullRefreshState.refreshingState.value,
170
- pullState,
171
- modifierIndicator.align(Alignment.TopCenter)
172
- )
173
- }
174
-
175
- }
176
- }
177
- }
178
-
179
- @Composable
180
- private fun IosIndicator(
181
- effect: OverscrollEffect?,
182
- modifier: Modifier = Modifier,
183
- ) {
184
- if (effect !is CupertinoOverscrollEffect) return
185
- if (effect.pullRefreshState == null) return
186
- val state = effect.pullRefreshState
187
-
188
-
189
- SpinningProgressBarLoading(
190
- progress = state.position, modifier = modifier
191
- )
192
- }
193
-
194
- @Composable
195
- private fun SpinningProgressBarLoading(
196
- progress: State<Float>, modifier: Modifier = Modifier
197
- ) {
198
- if (progress.value <= 0) {
199
- return
200
- }
201
-
202
- val hapticFeedback = LocalHapticFeedback.current
203
- val isSendHaptic = remember { mutableStateOf(false) }
204
-
205
- val totalStep = 8
206
- val stepAngle = 360f / totalStep
207
- val baseOpacity = 1.0f / (totalStep + 2)
208
- val minAlpha = 0.2f
209
-
210
- val infiniteTransition = rememberInfiniteTransition()
211
- val angle = infiniteTransition.animateFloat(
212
- initialValue = 0f, targetValue = totalStep.toFloat(), animationSpec = infiniteRepeatable(
213
- animation = tween(totalStep * 100, easing = LinearEasing),
214
- repeatMode = RepeatMode.Restart
215
- )
216
- )
217
-
218
- LaunchedEffect(Unit) {
219
- snapshotFlow { progress.value }.collect {
220
- if (it >= 1.0f && !isSendHaptic.value) {
221
- hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
222
- isSendHaptic.value = true
223
- } else if (progress.value < 1.0f && isSendHaptic.value) {
224
- isSendHaptic.value = false
225
- }
226
- }
227
-
228
- }
229
-
230
- Canvas(modifier = modifier) {
231
- val percentage = progress.value
232
- val clampedProgress = percentage.coerceIn(0f, 1f)
233
- val value = (totalStep * clampedProgress).coerceIn(0f, totalStep.toFloat())
234
- val integerPart = value.toInt()
235
- val decimalPart = value - integerPart
236
-
237
- if (integerPart <= 0) return@Canvas
238
-
239
- val canvasWidth = size.width
240
- val canvasHeight = size.height
241
- val width = size.width * 0.3f
242
- val height = size.height / 8
243
- val cornerRadius = (width.coerceAtMost(height) / 2)
244
-
245
- if (percentage >= 1f) {
246
- for (i in 0..360 step 360 / totalStep) {
247
- rotate(i.toFloat()) {
248
- drawRoundRect(
249
- color = Color.LightGray.copy(alpha = .7f),
250
- topLeft = Offset(canvasWidth - width, (canvasHeight - height) / 2),
251
- size = Size(width, height),
252
- cornerRadius = CornerRadius(cornerRadius, cornerRadius)
253
- )
254
- }
255
- }
256
-
257
- val coefficient = 360f / totalStep
258
-
259
- for (i in 1..4) {
260
- rotate((angle.value.toInt() + i) * coefficient) {
261
- drawRoundRect(
262
- color = Color.Gray.copy(alpha = (0.2f + 0.2f * i).coerceIn(0f, 1f)),
263
- topLeft = Offset(canvasWidth - width, (canvasHeight - height) / 2),
264
- size = Size(width, height),
265
- cornerRadius = CornerRadius(cornerRadius, cornerRadius)
266
- )
267
- }
268
- }
269
- return@Canvas
270
- }
271
-
272
- val topLeft = Offset(canvasWidth - width, (canvasHeight - height) / 2)
273
- val rectSize = Size(width, height)
274
- val cornerRadiusValue = CornerRadius(cornerRadius, cornerRadius)
275
- repeat(integerPart) { i ->
276
- val angle = i * stepAngle - 90f
277
- val stepOpacity = 1f - (baseOpacity * i)
278
-
279
- val alpha = if (i == integerPart - 1) {
280
- (decimalPart * stepOpacity).coerceIn(minAlpha, 1f)
281
- } else {
282
- stepOpacity.coerceIn(minAlpha, 1f)
283
- }
284
-
285
- rotate(angle) {
286
- drawRoundRect(
287
- color = Color.Gray.copy(alpha = alpha),
288
- topLeft = topLeft,
289
- size = rectSize,
290
- cornerRadius = cornerRadiusValue
291
- )
292
- }
293
- }
294
- }
295
- }
296
-
297
- @Composable
298
- private fun FakeBox(height: MutableState<Int>) {
299
- Box(
300
- modifier = Modifier
301
- .dynamicHeight(height).fillMaxWidth().background(Color.Red),
302
- )
303
- }
304
-
305
- private fun Modifier.calculateHeight(
306
- height: MutableState<Int>,
307
- ) = this.layout { m, c ->
308
- val p = m.measure(
309
- constraints = c.copy(
310
- minHeight = 0
311
- )
312
- )
313
- val vH = p.height
314
- val cMaxHeight = c.maxHeight
315
- val addOn = 0.5.dp.roundToPx()
316
- var extraSpace = addOn + height.value
317
- if (height.value == 0) {
318
- extraSpace = 0
319
- }
320
- if (vH - extraSpace >= cMaxHeight && height.value != 0) {
321
- height.value = 0
322
- } else if (vH - extraSpace < cMaxHeight) {
323
- height.value = cMaxHeight - (vH - extraSpace) + addOn
324
- }
325
-
326
- layout(c.maxWidth, cMaxHeight) {
327
- p.place(IntOffset.Zero)
328
- }
329
- }
330
-
331
-
332
- private fun Modifier.dynamicHeight(height: MutableState<Int>) = composed {
333
- val measure = remember<MeasureScope.(Measurable, Constraints) -> MeasureResult>(this, height) {
334
- { m, c ->
335
- val p = m.measure(c)
336
- layout(c.maxWidth, height.value) { p.place(IntOffset.Zero) }
337
- }
338
- }
339
- this.layout(measure = measure)
340
- }
341
-
342
- private val LazyListLayoutInfo.totalHeight: Int
343
- get() = visibleItemsInfo.sumOf { it.size }
@@ -1,108 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.animation.core.FastOutSlowInEasing
4
- import androidx.compose.animation.core.animateFloatAsState
5
- import androidx.compose.animation.core.tween
6
- import androidx.compose.foundation.background
7
- import androidx.compose.foundation.border
8
- import androidx.compose.foundation.layout.Box
9
- import androidx.compose.foundation.layout.fillMaxWidth
10
- import androidx.compose.foundation.layout.height
11
- import androidx.compose.foundation.layout.size
12
- import androidx.compose.foundation.shape.RoundedCornerShape
13
- import androidx.compose.runtime.Composable
14
- import androidx.compose.runtime.getValue
15
- import androidx.compose.ui.Modifier
16
- import androidx.compose.ui.draw.clip
17
- import androidx.compose.ui.graphics.Color
18
- import androidx.compose.ui.unit.dp
19
- import vn.momo.kits.application.IsShowBaseLineDebug
20
- import vn.momo.kits.const.AppTheme
21
- import vn.momo.kits.const.Colors
22
- import vn.momo.kits.const.Radius
23
- import vn.momo.kits.modifier.conditional
24
- import vn.momo.kits.platform.LottieAnimation
25
-
26
- enum class LoaderType {
27
- DOT, SPINNER
28
- }
29
-
30
- @Composable
31
- fun Loader(
32
- type: LoaderType = LoaderType.DOT,
33
- tintColor: Color? = null,
34
- modifier: Modifier = Modifier
35
- ) {
36
- when (type) {
37
- LoaderType.DOT -> DotLoader(tintColor = tintColor, modifier = modifier)
38
- LoaderType.SPINNER -> SpinnerLoader(tintColor = tintColor, modifier = modifier)
39
- }
40
- }
41
-
42
- @Composable
43
- fun DotLoader(
44
- tintColor: Color? = null,
45
- modifier: Modifier = Modifier
46
- ) {
47
- LottieAnimation(
48
- path = "files/dot_loading",
49
- tintColor = tintColor,
50
- modifier = modifier
51
- .size(width = 52.dp, height = 18.dp)
52
- .conditional(IsShowBaseLineDebug) {
53
- border(1.dp, Colors.blue_03)
54
- }
55
- )
56
- }
57
-
58
- @Composable
59
- fun SpinnerLoader(
60
- tintColor: Color? = null,
61
- modifier: Modifier = Modifier
62
- ) {
63
- LottieAnimation(
64
- path = "files/lottie_circle_loader",
65
- tintColor = tintColor,
66
- modifier = modifier
67
- .size(24.dp)
68
- .conditional(IsShowBaseLineDebug) {
69
- border(1.dp, Colors.blue_03)
70
- }
71
- )
72
- }
73
-
74
- @Composable
75
- fun ProgressBar(
76
- percent: Float = 0f,
77
- color: Color? = null,
78
- modifier: Modifier = Modifier
79
- ) {
80
- val clampedPercent = percent.coerceIn(0f, 100f)
81
- val animatedProgress by animateFloatAsState(
82
- targetValue = clampedPercent / 100f,
83
- animationSpec = tween(durationMillis = 200, easing = FastOutSlowInEasing),
84
- label = "progressAnimation"
85
- )
86
-
87
- val trackColor = AppTheme.current.colors.background.default
88
- val fillColor = color ?: AppTheme.current.colors.primary
89
-
90
- Box(
91
- modifier = modifier
92
- .fillMaxWidth()
93
- .height(4.dp)
94
- .clip(RoundedCornerShape(Radius.XXS))
95
- .background(trackColor)
96
- .conditional(IsShowBaseLineDebug) {
97
- border(1.dp, Colors.blue_03)
98
- }
99
- ) {
100
- Box(
101
- modifier = Modifier
102
- .fillMaxWidth(animatedProgress)
103
- .height(4.dp)
104
- .clip(RoundedCornerShape(Radius.XXS))
105
- .background(fillColor)
106
- )
107
- }
108
- }
@@ -1,56 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.layout.Box
6
- import androidx.compose.foundation.layout.Row
7
- import androidx.compose.foundation.layout.padding
8
- import androidx.compose.foundation.layout.size
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.ui.Modifier
12
- import androidx.compose.ui.graphics.Color
13
- import androidx.compose.ui.unit.dp
14
- import vn.momo.kits.application.IsShowBaseLineDebug
15
- import vn.momo.kits.const.AppTheme
16
- import vn.momo.kits.const.Colors
17
- import vn.momo.kits.const.Spacing
18
- import vn.momo.kits.modifier.conditional
19
-
20
- @Composable
21
- internal fun Dot(active: Boolean = false, activeColor: Color, modifier: Modifier = Modifier) {
22
- return if (active) {
23
- Box(
24
- modifier = modifier.size(width = 12.dp, height = 4.dp).background(
25
- color = activeColor,
26
- shape = RoundedCornerShape(4.dp)
27
- )
28
- )
29
- } else {
30
- Box(
31
- modifier = modifier.size(4.dp)
32
- .background(
33
- color = AppTheme.current.colors.background.pressed,
34
- shape = RoundedCornerShape(4.dp)
35
- )
36
- )
37
- }
38
- }
39
-
40
- @Composable
41
- fun PaginationDot(
42
- activeIndex: Int = 0,
43
- dataLength: Int = 3
44
- ) {
45
- Row(modifier = Modifier.conditional(IsShowBaseLineDebug) {
46
- border(1.dp, Colors.blue_03)
47
- }) {
48
- for (i in 0 until dataLength) {
49
- Dot(
50
- i == activeIndex,
51
- AppTheme.current.colors.primary,
52
- modifier = Modifier.padding(end = if (i != dataLength - 1) Spacing.XS else 0.dp)
53
- )
54
- }
55
- }
56
- }
@@ -1,41 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.layout.BoxWithConstraints
6
- import androidx.compose.foundation.layout.padding
7
- import androidx.compose.foundation.shape.RoundedCornerShape
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Alignment
10
- import androidx.compose.ui.Modifier
11
- import androidx.compose.ui.graphics.Color
12
- import androidx.compose.ui.unit.dp
13
- import vn.momo.kits.application.IsShowBaseLineDebug
14
- import vn.momo.kits.const.Colors
15
- import vn.momo.kits.const.Spacing
16
- import vn.momo.kits.const.Typography
17
- import vn.momo.kits.modifier.conditional
18
-
19
- @Composable
20
- fun PaginationNumber(
21
- activeIndex: Int = 0,
22
- dataLength: Int = 2
23
- ) {
24
- BoxWithConstraints(
25
- modifier = Modifier.background(
26
- color = Color(0x33000000),
27
- shape = RoundedCornerShape(Spacing.L)
28
- )
29
- .conditional(IsShowBaseLineDebug) {
30
- border(1.dp, Colors.blue_03)
31
- },
32
- contentAlignment = Alignment.Center
33
- ) {
34
- Text(
35
- modifier = Modifier.padding(horizontal = Spacing.S),
36
- text = "${1 + activeIndex}/$dataLength",
37
- color = Colors.black_01,
38
- style = Typography.labelDefaultMedium
39
- )
40
- }
41
- }
@@ -1,84 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.horizontalScroll
6
- import androidx.compose.foundation.layout.*
7
- import androidx.compose.foundation.rememberScrollState
8
- import androidx.compose.foundation.shape.RoundedCornerShape
9
- import androidx.compose.runtime.Composable
10
- import androidx.compose.runtime.derivedStateOf
11
- import androidx.compose.runtime.getValue
12
- import androidx.compose.runtime.remember
13
- import androidx.compose.ui.Alignment
14
- import androidx.compose.ui.Modifier
15
- import androidx.compose.ui.draw.clip
16
- import androidx.compose.ui.unit.Dp
17
- import androidx.compose.ui.unit.dp
18
- import vn.momo.kits.application.IsShowBaseLineDebug
19
- import vn.momo.kits.const.AppTheme
20
- import vn.momo.kits.const.Colors
21
- import vn.momo.kits.const.Spacing
22
- import vn.momo.kits.modifier.conditional
23
-
24
- private val INDICATOR_WIDTH = 24.dp
25
- private val PROGRESS_WIDTH = 72.dp
26
-
27
- private fun calculateOffset(currentPosition: Int, maxBound: Int): Dp {
28
- return if (maxBound == 0) 0.dp else {
29
- (PROGRESS_WIDTH - INDICATOR_WIDTH) * (currentPosition / maxBound.toFloat())
30
- }
31
- }
32
-
33
- @Composable
34
- fun PaginationScroll(
35
- modifier: Modifier = Modifier,
36
- content: @Composable () -> Unit
37
- ) {
38
- val scrollState = rememberScrollState()
39
- val theme = AppTheme.current
40
-
41
- // Use derivedStateOf to optimize scroll position calculations
42
- val indicatorOffset by remember {
43
- derivedStateOf {
44
- calculateOffset(scrollState.value, scrollState.maxValue)
45
- }
46
- }
47
-
48
- // Cache theme colors to avoid repeated access
49
- val (progressBackground, indicatorColor) = remember(theme) {
50
- theme.colors.background.pressed to theme.colors.primary
51
- }
52
-
53
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
54
- Row(
55
- modifier = modifier
56
- .fillMaxWidth()
57
- .conditional(IsShowBaseLineDebug) {
58
- border(1.dp, Colors.blue_03)
59
- }
60
- .padding(bottom = Spacing.L)
61
- .horizontalScroll(scrollState)
62
- ) {
63
- content()
64
- }
65
-
66
- // Progress indicator
67
- Box(
68
- modifier = Modifier
69
- .clip(RoundedCornerShape(Spacing.XS))
70
- .width(PROGRESS_WIDTH)
71
- .height(4.dp)
72
- .background(color = progressBackground)
73
- ) {
74
- Box(
75
- modifier = Modifier
76
- .offset(x = indicatorOffset)
77
- .clip(RoundedCornerShape(Spacing.XS))
78
- .width(INDICATOR_WIDTH)
79
- .height(4.dp)
80
- .background(color = indicatorColor)
81
- )
82
- }
83
- }
84
- }
@@ -1,40 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.layout.Row
6
- import androidx.compose.foundation.layout.padding
7
- import androidx.compose.foundation.shape.RoundedCornerShape
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Modifier
10
- import androidx.compose.ui.graphics.Color
11
- import androidx.compose.ui.unit.dp
12
- import vn.momo.kits.application.IsShowBaseLineDebug
13
- import vn.momo.kits.const.Colors
14
- import vn.momo.kits.const.Spacing
15
- import vn.momo.kits.modifier.conditional
16
-
17
- @Composable
18
- fun PaginationWhiteDot(
19
- activeIndex: Int = 0,
20
- dataLength: Int = 3
21
- ) {
22
- Row(
23
- modifier = Modifier.background(
24
- color = Color(0x33000000),
25
- shape = RoundedCornerShape(Spacing.S)
26
- )
27
- .conditional(IsShowBaseLineDebug) {
28
- border(1.dp, Colors.blue_03)
29
- }
30
- .padding(Spacing.XS)
31
- ) {
32
- for (i in 0 until dataLength) {
33
- Dot(
34
- i == activeIndex,
35
- Colors.black_01,
36
- modifier = Modifier.padding(end = if (i != dataLength - 1) Spacing.XS else 0.dp)
37
- )
38
- }
39
- }
40
- }