@momo-kits/native-kits 0.169.8-beta.5-debug → 0.169.8-beta.6

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 (146) hide show
  1. package/ios/Navigation/Component/Header.swift +10 -35
  2. package/ios/Navigation/Component/HeaderRight.swift +5 -7
  3. package/ios/Navigation/Component/SideBar.swift +4 -13
  4. package/ios/Navigation/StackScreen.swift +2 -3
  5. package/ios/native-kits.podspec +1 -1
  6. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  7. package/package.json +1 -1
  8. package/build.gradle.kts +0 -11
  9. package/compose/build.gradle.kts +0 -198
  10. package/compose/compose.podspec +0 -47
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  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/Context.kt +0 -110
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -267
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -195
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -263
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -307
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -306
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -457
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -120
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -210
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -292
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -63
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -748
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -391
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -100
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -207
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -132
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -467
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -406
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -204
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -22
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -144
  139. package/gradle/libs.versions.toml +0 -67
  140. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  141. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  142. package/gradle.properties +0 -24
  143. package/gradlew +0 -252
  144. package/gradlew.bat +0 -94
  145. package/ios-demo/README.md +0 -120
  146. 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,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.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.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.const.Typography
16
- import vn.momo.kits.modifier.conditional
17
-
18
- @Composable
19
- fun PaginationNumber(
20
- activeIndex: Int = 0,
21
- dataLength: Int = 2
22
- ) {
23
- BoxWithConstraints(
24
- modifier = Modifier.background(
25
- color = Colors.opacity_black_20,
26
- shape = RoundedCornerShape(Spacing.L)
27
- )
28
- .conditional(IsShowBaseLineDebug) {
29
- border(1.dp, Colors.blue_03)
30
- },
31
- contentAlignment = Alignment.Center
32
- ) {
33
- Text(
34
- modifier = Modifier.padding(horizontal = Spacing.S),
35
- text = "${1 + activeIndex}/$dataLength",
36
- color = Colors.black_01,
37
- style = Typography.labelDefaultMedium
38
- )
39
- }
40
- }
@@ -1,82 +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
- val indicatorOffset by remember {
42
- derivedStateOf {
43
- calculateOffset(scrollState.value, scrollState.maxValue)
44
- }
45
- }
46
-
47
- val (progressBackground, indicatorColor) = remember(theme) {
48
- theme.colors.background.pressed to theme.colors.primary
49
- }
50
-
51
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
52
- Row(
53
- modifier = modifier
54
- .fillMaxWidth()
55
- .conditional(IsShowBaseLineDebug) {
56
- border(1.dp, Colors.blue_03)
57
- }
58
- .padding(bottom = Spacing.L)
59
- .horizontalScroll(scrollState)
60
- ) {
61
- content()
62
- }
63
-
64
- // Progress indicator
65
- Box(
66
- modifier = Modifier
67
- .clip(RoundedCornerShape(Spacing.XS))
68
- .width(PROGRESS_WIDTH)
69
- .height(4.dp)
70
- .background(color = progressBackground)
71
- ) {
72
- Box(
73
- modifier = Modifier
74
- .offset(x = indicatorOffset)
75
- .clip(RoundedCornerShape(Spacing.XS))
76
- .width(INDICATOR_WIDTH)
77
- .height(4.dp)
78
- .background(color = indicatorColor)
79
- )
80
- }
81
- }
82
- }
@@ -1,39 +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.unit.dp
11
- import vn.momo.kits.application.IsShowBaseLineDebug
12
- import vn.momo.kits.const.Colors
13
- import vn.momo.kits.const.Spacing
14
- import vn.momo.kits.modifier.conditional
15
-
16
- @Composable
17
- fun PaginationWhiteDot(
18
- activeIndex: Int = 0,
19
- dataLength: Int = 3
20
- ) {
21
- Row(
22
- modifier = Modifier.background(
23
- color = Colors.opacity_black_20,
24
- shape = RoundedCornerShape(Spacing.S)
25
- )
26
- .conditional(IsShowBaseLineDebug) {
27
- border(1.dp, Colors.blue_03)
28
- }
29
- .padding(Spacing.XS)
30
- ) {
31
- for (i in 0 until dataLength) {
32
- Dot(
33
- i == activeIndex,
34
- Colors.black_01,
35
- modifier = Modifier.padding(end = if (i != dataLength - 1) Spacing.XS else 0.dp)
36
- )
37
- }
38
- }
39
- }