@momo-kits/native-kits 0.167.1-duo.17-debug → 0.167.1-duo.18

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 (154) hide show
  1. package/CLAUDE.md +1 -0
  2. package/ios/Layout/ScreenLayout.swift +49 -3
  3. package/ios/Navigation/Component/Header.swift +48 -11
  4. package/ios/Navigation/Component/HeaderRight.swift +34 -28
  5. package/ios/Navigation/Component/SideBar.swift +15 -8
  6. package/ios/Navigation/StackScreen.swift +13 -12
  7. package/package.json +1 -1
  8. package/build.gradle.kts +0 -11
  9. package/compose/build.gradle.kts +0 -204
  10. package/compose/build.gradle.kts.backup +0 -204
  11. package/compose/compose.podspec +0 -47
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  17. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -916
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -20
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -283
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -260
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -708
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -218
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -231
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -98
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -312
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -408
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -366
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -185
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -13
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -78
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  142. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  143. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  144. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  145. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  146. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -94
  147. package/gradle/libs.versions.toml +0 -69
  148. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  149. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  150. package/gradle.properties +0 -26
  151. package/gradlew +0 -252
  152. package/gradlew.bat +0 -94
  153. package/ios-demo/README.md +0 -120
  154. 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
- }