@momo-kits/native-kits 0.164.1-beta.17-debug → 0.164.1-beta.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 (140) hide show
  1. package/ios/native-kits.podspec +1 -1
  2. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  3. package/package.json +2 -2
  4. package/build.gradle.kts +0 -11
  5. package/compose/build.gradle.kts +0 -190
  6. package/compose/build.gradle.kts.backup +0 -190
  7. package/compose/compose.podspec +0 -47
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -150
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -106
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -826
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -134
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -475
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -214
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -216
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -182
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -217
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -470
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -131
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -203
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -175
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -263
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -52
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -38
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -39
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -299
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -103
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -191
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -386
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -595
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -157
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -39
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -156
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -320
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -81
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -34
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -360
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -15
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -69
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -119
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -35
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -220
  132. package/gradle/libs.versions.toml +0 -69
  133. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  134. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  135. package/gradle.properties +0 -26
  136. package/gradlew +0 -252
  137. package/gradlew.bat +0 -94
  138. package/ios-demo/README.md +0 -120
  139. package/local.properties +0 -8
  140. package/settings.gradle.kts +0 -64
@@ -1,826 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import androidx.annotation.FloatRange
4
- import androidx.compose.animation.animateContentSize
5
- import androidx.compose.foundation.*
6
- import androidx.compose.foundation.gestures.detectTapGestures
7
- import androidx.compose.foundation.interaction.FocusInteraction
8
- import androidx.compose.foundation.interaction.MutableInteractionSource
9
- import androidx.compose.foundation.layout.*
10
- import androidx.compose.foundation.shape.CircleShape
11
- import androidx.compose.foundation.text.BasicTextField
12
- import androidx.compose.foundation.text.KeyboardActions
13
- import androidx.compose.foundation.text.KeyboardOptions
14
- import androidx.compose.runtime.*
15
- import androidx.compose.ui.Alignment
16
- import androidx.compose.ui.Modifier
17
- import androidx.compose.ui.composed
18
- import androidx.compose.ui.draw.clip
19
- import androidx.compose.ui.draw.drawBehind
20
- import androidx.compose.ui.draw.drawWithContent
21
- import androidx.compose.ui.geometry.Offset
22
- import androidx.compose.ui.geometry.Rect
23
- import androidx.compose.ui.graphics.Brush
24
- import androidx.compose.ui.graphics.Color
25
- import androidx.compose.ui.graphics.SolidColor
26
- import androidx.compose.ui.graphics.graphicsLayer
27
- import androidx.compose.ui.input.pointer.pointerInput
28
- import androidx.compose.ui.layout.*
29
- import androidx.compose.ui.platform.LocalDensity
30
- import androidx.compose.ui.platform.LocalFocusManager
31
- import androidx.compose.ui.platform.LocalSoftwareKeyboardController
32
- import androidx.compose.ui.text.TextStyle
33
- import androidx.compose.ui.text.style.TextOverflow
34
- import androidx.compose.ui.unit.*
35
- import kotlinx.coroutines.flow.collectLatest
36
- import kotlinx.coroutines.flow.mapNotNull
37
- import vn.momo.kits.components.Icon
38
- import vn.momo.kits.components.Text
39
- import vn.momo.kits.const.AppTheme
40
- import vn.momo.kits.const.Colors
41
- import vn.momo.kits.const.Spacing
42
- import vn.momo.kits.const.Typography
43
- import vn.momo.kits.modifier.kitsAutomationId
44
- import vn.momo.kits.modifier.noFeedbackClickable
45
- import vn.momo.kits.modifier.setAutomationId
46
- import vn.momo.kits.navigation.component.HEADER_HEIGHT
47
- import vn.momo.kits.utils.getAppStatusBarHeight
48
- import kotlin.math.max
49
- import kotlin.math.roundToInt
50
-
51
-
52
- data class AnimationOption(
53
- val targetBounds: Rect,
54
- val progress: State<Float>,
55
- @param:FloatRange(from = 0.0, to = 1.0)
56
- val opacityLimitFraction: Float = 0f,
57
- ) {
58
- val opacityCap: Float
59
- get() = 1f - opacityLimitFraction
60
-
61
- val animateOpacity: Float
62
- get() {
63
- if (progress.value < opacityLimitFraction) return 0f
64
- return androidx.compose.ui.util.lerp(
65
- 0f,
66
- 1f,
67
- (progress.value - opacityLimitFraction) / (opacityCap),
68
- )
69
- }
70
- }
71
-
72
- val LocalAnimationOption = staticCompositionLocalOf<AnimationOption?> { null }
73
-
74
- @Composable
75
- fun LiteScreen(
76
- scrollable: Boolean = true,
77
- scrollState: ScrollState? = null,
78
- headerType: HeaderType = HeaderType.DEFAULT,
79
- verticalArrangement: Arrangement.Vertical = Arrangement.Top,
80
- horizontalAlignment: Alignment.Horizontal = Alignment.Start,
81
- backgroundColor: Color = AppTheme.current.colors.background.default,
82
- /* Begin of header props */
83
- title: String? = null,
84
- inputSearchProps: LiteInputSearchProps? = null,
85
- goBack: (() -> Unit)? = null,
86
- headerRight: @Composable (() -> Unit)? = null,
87
- useAnimationSearch: Boolean = true,
88
- titlePosition: TitlePosition = TitlePosition.LEFT,
89
- headerRightData: HeaderRightData? = null,
90
- headerTintColor: Color? = null,
91
- headerBackgroundColor: Color? = null,
92
- headerSpaceBetween: Dp? = null,
93
- /* End of header props */
94
-
95
- screenContent: @Composable () -> Unit,
96
- ) {
97
- val content by rememberUpdatedState(screenContent)
98
-
99
- val finalScrollState = scrollState ?: rememberScrollState()
100
-
101
- val contentModifier = remember(
102
- key1 = scrollable,
103
- key2 = finalScrollState,
104
- ) {
105
- var res: Modifier = Modifier
106
- .background(color = backgroundColor)
107
- if (scrollable) {
108
- res = res.verticalScroll(finalScrollState)
109
- }
110
- res
111
- }
112
-
113
- LiteScreenLayout(
114
- scrollState = finalScrollState,
115
- modifier = Modifier
116
- .fillMaxSize()
117
- .hideKeyboardOnTap(),
118
- contentModifier = contentModifier,
119
- verticalArrangement = verticalArrangement,
120
- horizontalAlignment = horizontalAlignment,
121
- title = title,
122
- headerRight = headerRight,
123
- headerType = headerType,
124
- onGoBack = goBack,
125
- inputSearchProps = inputSearchProps,
126
- titlePosition = titlePosition,
127
- useAnimationSearch = useAnimationSearch,
128
- headerRightData = headerRightData,
129
- tintColor = headerTintColor,
130
- headerBackgroundColor = headerBackgroundColor,
131
- headerSpaceBetween = headerSpaceBetween,
132
- ) {
133
- content()
134
- }
135
- }
136
-
137
- private object HeaderId {
138
- private const val PACKAGE_NAME = "vn.momo.compose.kits"
139
- const val CONTENT_ID = "${PACKAGE_NAME}.content"
140
- const val BACKGROUND_ID = "${PACKAGE_NAME}.background"
141
- const val BACK_ID = "${PACKAGE_NAME}.back"
142
- const val HEADER_RIGHT_ID = "${PACKAGE_NAME}.headerRight"
143
- const val INPUT_SEARCH_ID = "${PACKAGE_NAME}.inputSearch"
144
- const val TITLE_ID = "${PACKAGE_NAME}.title"
145
-
146
- val EXTENDED_HEADER_HEIGHT = 154.dp
147
- }
148
-
149
- @Composable
150
- private fun LiteScreenLayout(
151
- scrollState: ScrollState?,
152
- modifier: Modifier = Modifier,
153
- contentModifier: Modifier = Modifier,
154
- verticalArrangement: Arrangement.Vertical = Arrangement.Top,
155
- horizontalAlignment: Alignment.Horizontal = Alignment.Start,
156
- title: String? = null,
157
- tintColor: Color? = null,
158
- headerRightData: HeaderRightData? = null,
159
- headerType: HeaderType = HeaderType.DEFAULT,
160
- titlePosition: TitlePosition = TitlePosition.LEFT,
161
- useAnimationSearch: Boolean = true,
162
- onGoBack: (() -> Unit)? = null,
163
- headerBackgroundColor: Color? = null,
164
- headerSpaceBetween: Dp? = null,
165
- inputSearchProps: LiteInputSearchProps? = null,
166
- headerRight: @Composable (() -> Unit)? = null,
167
- content: @Composable () -> Unit,
168
- ) {
169
- val statusBarHeight = getAppStatusBarHeight()
170
- val isHeaderNone = remember(headerType) {
171
- headerType == HeaderType.NONE
172
- }
173
- val theme = AppTheme.current
174
- val density = LocalDensity.current
175
-
176
- val isHeaderExtend = remember(headerType) {
177
- headerType == HeaderType.EXTENDED
178
- }
179
- val backgroundHeight = remember(isHeaderNone, isHeaderExtend, statusBarHeight) {
180
- when {
181
- isHeaderNone -> statusBarHeight
182
- !isHeaderExtend -> statusBarHeight + HEADER_HEIGHT.dp
183
- else -> HeaderId.EXTENDED_HEADER_HEIGHT
184
- }
185
- }
186
- val listGradientColors = remember {
187
- listOf(
188
- Color(0xFFFDCADE),
189
- Color(0x00FDCADE),
190
- )
191
- }
192
-
193
- val headerColor = remember(tintColor, theme) {
194
- if (tintColor == Colors.black_01) HeaderColor(
195
- tintIconColor = tintColor,
196
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
197
- borderColor = Colors.black_01.copy(alpha = 0.2f)
198
- )
199
- else HeaderColor(
200
- tintIconColor = tintColor ?: theme.colors.text.default,
201
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
202
- borderColor = Colors.black_20.copy(alpha = 0.2f)
203
- )
204
- }
205
-
206
- val scrollPercentage = produceState(
207
- initialValue = 0f,
208
- key1 = useAnimationSearch,
209
- key2 = scrollState,
210
- key3 = backgroundHeight,
211
- ) {
212
- if (!useAnimationSearch) return@produceState
213
- scrollState ?: return@produceState
214
- val rangePx = with(density) { backgroundHeight.toPx() }
215
- snapshotFlow { scrollState.value }.collectLatest {
216
- value = (it / rangePx).coerceIn(0f, 1f)
217
- }
218
- }
219
-
220
- val titleStyle = remember {
221
- Typography.actionSBold.copy(
222
- fontSize = 15.sp,
223
- lineHeight = 22.sp,
224
- )
225
- }
226
-
227
- val animationOption = LocalAnimationOption.current
228
- val animationOpacityModifier = Modifier.graphicsLayer {
229
- alpha = animationOption?.animateOpacity ?: 1f
230
- }
231
- val titleModifier = Modifier
232
- .kitsAutomationId("title_navigation_header")
233
- .layoutId(HeaderId.TITLE_ID)
234
- .graphicsLayer {
235
- val titleAlpha = if (isHeaderExtend && inputSearchProps != null && useAnimationSearch)
236
- (1 - scrollPercentage.value * 2).coerceIn(0f, 1f)
237
- else 1f
238
- alpha = titleAlpha * (animationOption?.progress?.value ?: 1f)
239
- }
240
-
241
- val policy = remember(
242
- useAnimationSearch,
243
- isHeaderNone,
244
- isHeaderExtend,
245
- statusBarHeight,
246
- titlePosition,
247
- scrollPercentage,
248
- headerSpaceBetween,
249
- animationOption,
250
- verticalArrangement,
251
- horizontalAlignment,
252
- ) {
253
- LiteScreenLayoutPolicy(
254
- useAnimationSearch = useAnimationSearch,
255
- isHeaderNone = isHeaderNone,
256
- isHeaderExtend = isHeaderExtend,
257
- statusBarHeight = statusBarHeight,
258
- titlePosition = titlePosition,
259
- scrollPercentage = scrollPercentage,
260
- headerSpaceBetween = headerSpaceBetween,
261
- animationOption = animationOption,
262
- verticalArrangement = verticalArrangement,
263
- horizontalAlignment = horizontalAlignment,
264
- )
265
- }
266
-
267
- Layout(
268
- modifier = modifier
269
- .animateContentSize(),
270
- content = {
271
- Box(
272
- modifier = animationOpacityModifier
273
- .layoutId(HeaderId.CONTENT_ID)
274
- .then(contentModifier),
275
- contentAlignment = Alignment.TopCenter,
276
- ) {
277
- content()
278
- }
279
-
280
- if (!isHeaderNone) {
281
- Box(
282
- modifier = Modifier
283
- .layoutId(HeaderId.BACKGROUND_ID)
284
- .then(animationOpacityModifier)
285
- .drawBehind {
286
- val headerHeight = max(
287
- HeaderId.EXTENDED_HEADER_HEIGHT.toPx(),
288
- size.height,
289
- )
290
- headerBackgroundColor?.let {
291
- drawRect(color = it)
292
- } ?: run {
293
- drawRect(color = Colors.black_01)
294
- drawRect(
295
- brush = Brush.linearGradient(
296
- colors = listGradientColors,
297
- start = Offset.Zero,
298
- end = Offset(
299
- x = 0f,
300
- y = headerHeight * (1 - scrollPercentage.value),
301
- ),
302
- )
303
- )
304
- }
305
- },
306
- )
307
- }
308
-
309
- if (!isHeaderNone && onGoBack != null) {
310
- val coreModifier = Modifier
311
- .layoutId(HeaderId.BACK_ID)
312
- .then(animationOpacityModifier)
313
- .clip(CircleShape)
314
- .noFeedbackClickable(onClick = onGoBack)
315
- .setAutomationId("btn_navigation_back")
316
- inputSearchProps?.customBackIcon?.invoke(coreModifier) ?: Box(
317
- modifier = coreModifier
318
- .size(28.dp)
319
- .border(
320
- width = 0.2.dp,
321
- color = headerColor.borderColor,
322
- shape = CircleShape,
323
- )
324
- .background(color = headerColor.backgroundButton)
325
- .padding(Spacing.XS),
326
- ) {
327
- Icon(
328
- source = "arrow-back",
329
- color = headerColor.tintIconColor,
330
- size = 20.dp,
331
- )
332
- }
333
- }
334
-
335
- if (!isHeaderNone) {
336
- Box(
337
- modifier = Modifier
338
- .layoutId(HeaderId.HEADER_RIGHT_ID)
339
- .then(animationOpacityModifier)
340
- ) {
341
- if (headerRight != null) {
342
- headerRight()
343
- } else {
344
- HeaderRight(
345
- headerRight = headerRightData,
346
- tintColor = tintColor,
347
- )
348
- }
349
- }
350
- }
351
-
352
- if (!isHeaderNone && inputSearchProps != null) {
353
- LiteInputSearch(
354
- modifier = Modifier.layoutId(HeaderId.INPUT_SEARCH_ID),
355
- inputSearchProps = inputSearchProps,
356
- )
357
- }
358
- if (!isHeaderNone && title != null && (inputSearchProps == null || isHeaderExtend)) {
359
- Text(
360
- text = title,
361
- color = headerColor.tintIconColor,
362
- style = titleStyle,
363
- modifier = titleModifier,
364
- maxLines = 1,
365
- overflow = TextOverflow.Ellipsis
366
- )
367
- }
368
- },
369
- measurePolicy = policy,
370
- )
371
- }
372
-
373
- private class LiteScreenLayoutPolicy(
374
- private val useAnimationSearch: Boolean,
375
- private val isHeaderNone: Boolean,
376
- private val isHeaderExtend: Boolean,
377
- private val statusBarHeight: Dp,
378
- private val scrollPercentage: State<Float>,
379
- private val titlePosition: TitlePosition,
380
- private val headerSpaceBetween: Dp? = null,
381
- private val animationOption: AnimationOption?,
382
- private val verticalArrangement: Arrangement.Vertical,
383
- private val horizontalAlignment: Alignment.Horizontal,
384
- ) : MeasurePolicy {
385
-
386
- val searchStartPosition: IntOffset by lazy {
387
- if (animationOption == null) return@lazy IntOffset.Zero
388
- val offset = animationOption.targetBounds.topLeft
389
- IntOffset(
390
- x = offset.x.roundToInt(),
391
- y = offset.y.roundToInt(),
392
- )
393
- }
394
-
395
- override fun MeasureScope.measure(
396
- measurables: List<Measurable>,
397
- constraints: Constraints
398
- ): MeasureResult {
399
- val spacing12 = Spacing.M.roundToPx()
400
- val spaceBetween = headerSpaceBetween?.roundToPx() ?: spacing12
401
- val statusBarPx = statusBarHeight.roundToPx()
402
- val headerRowDefault = HEADER_HEIGHT.dp.roundToPx()
403
- val scrollPercent = scrollPercentage.value
404
-
405
- val contentMeasurable = measurables.find { it.layoutId == HeaderId.CONTENT_ID }
406
-
407
- val realConstraints = constraints.copy(
408
- minWidth = 0,
409
- minHeight = 0,
410
- maxWidth = (constraints.maxWidth - spacing12 * 2)
411
- .coerceAtLeast(0),
412
- )
413
- val backIconPlaceable =
414
- measurables.find { it.layoutId == HeaderId.BACK_ID }?.measure(realConstraints)
415
- val headerRightPlaceable =
416
- measurables.find { it.layoutId == HeaderId.HEADER_RIGHT_ID }?.measure(
417
- realConstraints.copy(
418
- maxWidth = realConstraints.maxWidth / 2,
419
- )
420
- )
421
- val baseInputSearchConstraints = if (isHeaderExtend) {
422
- val minWidth =
423
- if (useAnimationSearch) realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
424
- else realConstraints.maxWidth
425
- realConstraints.copy(
426
- maxWidth = (realConstraints.maxWidth * (1 - scrollPercent)).toInt()
427
- .coerceAtLeast(minWidth)
428
- )
429
- } else {
430
- var spaceConsumed = 0
431
- if (backIconPlaceable.safeWidth != 0) spaceConsumed += backIconPlaceable.safeWidth + spaceBetween
432
- if (headerRightPlaceable.safeWidth != 0) spaceConsumed += headerRightPlaceable.safeWidth + spaceBetween
433
- realConstraints.copy(
434
- maxWidth = realConstraints.maxWidth - spaceConsumed
435
- )
436
- }
437
- val inputSearchConstraints = baseInputSearchConstraints.withAnimationTargetBounds()
438
- val inputSearchPlaceable = measurables.find { it.layoutId == HeaderId.INPUT_SEARCH_ID }
439
- ?.measure(inputSearchConstraints)
440
- val titlePlaceable = measurables.find { it.layoutId == HeaderId.TITLE_ID }?.measure(
441
- constraints = realConstraints.copy(
442
- maxWidth = realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
443
- )
444
- )
445
-
446
- /**
447
- * replicate logic from [vn.momo.kits.navigation.component.HeaderBackground]
448
- * */
449
- var defaultHeight = statusBarPx + headerRowDefault
450
- if (isHeaderExtend) {
451
- defaultHeight = 154.dp.roundToPx()
452
- }
453
- val headerHeight = when {
454
- isHeaderNone -> statusBarPx
455
- !useAnimationSearch && !isHeaderExtend -> defaultHeight
456
- else -> {
457
- val collapsableSpace = defaultHeight - statusBarPx - headerRowDefault
458
- (defaultHeight - scrollPercent * collapsableSpace).toInt()
459
- }
460
- }
461
-
462
- val layoutWidth = constraints.maxWidth
463
- val layoutHeight = constraints.maxHeight
464
- val contentHeight = (layoutHeight - headerHeight).coerceAtLeast(0)
465
- val contentPlaceable = contentMeasurable?.measure(
466
- constraints.copy(
467
- minWidth = 0,
468
- minHeight = contentHeight,
469
- maxHeight = contentHeight,
470
- )
471
- )
472
- val backgroundPlaceable = measurables.find { it.layoutId == HeaderId.BACKGROUND_ID }
473
- ?.measure(
474
- Constraints.fixed(
475
- width = layoutWidth,
476
- height = headerHeight,
477
- )
478
- )
479
- val childrenHeights = intArrayOf(
480
- headerHeight,
481
- contentPlaceable.safeHeight,
482
- )
483
- val childrenY = IntArray(childrenHeights.size)
484
- with(verticalArrangement) {
485
- arrange(
486
- totalSize = layoutHeight,
487
- sizes = childrenHeights,
488
- outPositions = childrenY,
489
- )
490
- }
491
- val headerY = childrenY[0]
492
- val contentY = childrenY[1]
493
-
494
- return layout(
495
- width = layoutWidth,
496
- height = layoutHeight,
497
- ) {
498
- val progress = animationOption?.progress?.value ?: 1f
499
-
500
- val startX = spacing12
501
- val startY = headerY + statusBarPx
502
- var curX = startX
503
- var curY = startY
504
-
505
- contentPlaceable?.place(
506
- x = horizontalAlignment.align(
507
- size = contentPlaceable.width,
508
- space = layoutWidth,
509
- layoutDirection = layoutDirection,
510
- ),
511
- y = contentY,
512
- )
513
-
514
- backgroundPlaceable?.place(
515
- x = 0,
516
- y = headerY,
517
- )
518
-
519
- if (backIconPlaceable != null) {
520
- backIconPlaceable.place(
521
- x = startX,
522
- y = startY + backIconPlaceable.verticalCenterOffset(headerRowDefault),
523
- )
524
- curX += backIconPlaceable.safeWidth + spaceBetween
525
- }
526
-
527
- headerRightPlaceable?.place(
528
- x = layoutWidth - spacing12 - headerRightPlaceable.safeWidth,
529
- y = startY + headerRightPlaceable.verticalCenterOffset(headerRowDefault),
530
- )
531
-
532
- val titleOffset = IntOffset(
533
- x = if (titlePosition == TitlePosition.LEFT) curX
534
- else titlePlaceable.horizontalCenterOffset(
535
- space = layoutWidth,
536
- layoutDirection = layoutDirection,
537
- ),
538
- y = startY + titlePlaceable.verticalCenterOffset(headerRowDefault),
539
- )
540
-
541
- titlePlaceable?.place(titleOffset)
542
-
543
- if (backIconPlaceable != null || headerRightPlaceable != null || titlePlaceable != null) {
544
- curY += headerRowDefault
545
- }
546
-
547
- val inputSearchOffset = if (isHeaderExtend) {
548
- val baseY = curY + inputSearchPlaceable.verticalCenterOffset(headerRowDefault)
549
- val y = (baseY * (1 - scrollPercent)).toInt().coerceAtLeast(
550
- startY + inputSearchPlaceable.verticalCenterOffset(headerRowDefault)
551
- )
552
- IntOffset(
553
- x = startX + ((backIconPlaceable.safeWidth + spaceBetween) * (scrollPercent * 2f).coerceIn(
554
- 0f, 1f
555
- )).toInt(),
556
- y = y,
557
- )
558
- } else {
559
- IntOffset(
560
- x = curX,
561
- y = startY + inputSearchPlaceable.verticalCenterOffset(headerRowDefault),
562
- )
563
- }
564
- val finalPosition = lerp(
565
- searchStartPosition,
566
- inputSearchOffset,
567
- progress,
568
- )
569
-
570
- inputSearchPlaceable?.place(
571
- finalPosition
572
- )
573
- }
574
- }
575
-
576
- private val Placeable?.safeHeight
577
- get() = this?.height ?: 0
578
- private val Placeable?.safeWidth
579
- get() = this?.width ?: 0
580
-
581
- private fun Constraints.withAnimationTargetBounds(): Constraints {
582
- val option = animationOption ?: return this
583
- val progress = option.progress.value
584
- if (progress >= 1f) return this
585
-
586
- val targetWidth = option.targetBounds.width.roundToInt().coerceAtLeast(0)
587
- val targetHeight = option.targetBounds.height.roundToInt().coerceAtLeast(0)
588
- val animatedMinWidth = lerpPx(targetWidth, minWidth, progress)
589
- .coerceInBounds(maxWidth)
590
- val animatedMaxWidth = lerpMaxPx(targetWidth, maxWidth, progress)
591
- .coerceAtLeast(animatedMinWidth)
592
- val animatedMinHeight = lerpPx(targetHeight, minHeight, progress)
593
- .coerceInBounds(maxHeight)
594
- val animatedMaxHeight = lerpMaxPx(targetHeight, maxHeight, progress)
595
- .coerceAtLeast(animatedMinHeight)
596
-
597
- return copy(
598
- minWidth = animatedMinWidth,
599
- maxWidth = animatedMaxWidth,
600
- minHeight = animatedMinHeight,
601
- maxHeight = animatedMaxHeight,
602
- )
603
- }
604
-
605
- private fun lerpPx(
606
- start: Int,
607
- stop: Int,
608
- fraction: Float,
609
- ): Int = androidx.compose.ui.util.lerp(
610
- start.toFloat(),
611
- stop.toFloat(),
612
- fraction,
613
- ).roundToInt()
614
-
615
- private fun lerpMaxPx(
616
- start: Int,
617
- stop: Int,
618
- fraction: Float,
619
- ): Int {
620
- if (stop == Constraints.Infinity) return Constraints.Infinity
621
- return lerpPx(start, stop, fraction)
622
- }
623
-
624
- private fun Int.coerceInBounds(max: Int): Int {
625
- if (max == Constraints.Infinity) return coerceAtLeast(0)
626
- return coerceIn(0, max)
627
- }
628
-
629
- private fun Placeable?.verticalCenterOffset(space: Int): Int {
630
- if (this == null) return 0
631
- return Alignment.CenterVertically.align(safeHeight, space)
632
- }
633
-
634
- private fun Placeable?.horizontalCenterOffset(
635
- space: Int,
636
- layoutDirection: LayoutDirection
637
- ): Int {
638
- if (this == null) return 0
639
- return Alignment.CenterHorizontally.align(safeWidth, space, layoutDirection)
640
- }
641
- }
642
-
643
- private val EMPTY_FUNC = {}
644
-
645
- @Stable
646
- data class LiteInputSearchProps(
647
- val textFieldState: MutableState<String>,
648
- val onValueChange: (String) -> Unit,
649
- val onClear: () -> Unit = EMPTY_FUNC,
650
- val clearCondition: (() -> Boolean)? = null,
651
- val modifier: Modifier = Modifier,
652
- val onFocused: (() -> Unit) = EMPTY_FUNC,
653
- val keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
654
- val keyboardActions: KeyboardActions = KeyboardActions.Default,
655
- val onKeyboardAction: (() -> Unit) = EMPTY_FUNC,
656
-
657
- val btnText: String? = null,
658
- val isShowBtnText: Boolean = !btnText.isNullOrEmpty(),
659
- val onPressBtnText: (() -> Unit) = EMPTY_FUNC,
660
-
661
- val disabled: Boolean = false,
662
-
663
- val placeHolder: String? = null,
664
-
665
- val cursorBrush: Brush? = null,
666
- val customBackIcon: @Composable ((Modifier) -> Unit)? = null,
667
- val customSearchIcon: @Composable (() -> Unit)? = null,
668
- val customPlaceHolder: @Composable (() -> Unit)? = null,
669
- val customTextStyle: TextStyle? = null,
670
- val customIconClear: @Composable (() -> Unit)? = null,
671
- val iconRightTextField: @Composable ((Modifier) -> Unit)? = null,
672
- )
673
-
674
- @Composable
675
- private fun LiteInputSearch(
676
- modifier: Modifier = Modifier,
677
- inputSearchProps: LiteInputSearchProps? = null,
678
- ) {
679
- inputSearchProps ?: return
680
- val theme = AppTheme.current
681
-
682
- val isFocused = remember { mutableStateOf(false) }
683
- val interactionSource = remember { MutableInteractionSource() }
684
- val textState by remember { inputSearchProps.textFieldState }
685
-
686
- val isShowBtnText by remember(inputSearchProps.isShowBtnText, inputSearchProps.btnText) {
687
- derivedStateOf {
688
- inputSearchProps.isShowBtnText && !inputSearchProps.btnText.isNullOrEmpty()
689
- }
690
- }
691
- val inputFieldStyle = remember(theme) {
692
- Typography.bodyDefaultRegular.copy(
693
- color = theme.colors.text.default,
694
- )
695
- }
696
-
697
- LaunchedEffect(inputSearchProps.onFocused) {
698
- interactionSource.interactions.mapNotNull { it as? FocusInteraction }.collectLatest {
699
- val isFocus = it is FocusInteraction.Focus
700
- isFocused.value = isFocus
701
- if (isFocus) inputSearchProps.onFocused()
702
- }
703
- }
704
-
705
- Row(
706
- modifier = modifier,
707
- verticalAlignment = Alignment.CenterVertically,
708
- ) {
709
- val textFieldModifier = remember(inputSearchProps.modifier) {
710
- inputSearchProps.modifier
711
- .weight(1f)
712
- }
713
- BasicTextField(
714
- value = textState,
715
- onValueChange = inputSearchProps.onValueChange,
716
- enabled = !inputSearchProps.disabled,
717
- keyboardOptions = inputSearchProps.keyboardOptions,
718
- keyboardActions = inputSearchProps.keyboardActions,
719
- modifier = textFieldModifier,
720
- textStyle = inputSearchProps.customTextStyle ?: inputFieldStyle,
721
- singleLine = true,
722
- cursorBrush = inputSearchProps.cursorBrush ?: SolidColor(Color.Black),
723
- interactionSource = interactionSource,
724
- decorationBox = { innerTextField ->
725
- val isShowClear by remember(inputSearchProps.clearCondition, isFocused.value) {
726
- derivedStateOf {
727
- inputSearchProps.clearCondition?.invoke() == true || (isFocused.value && textState.isNotEmpty())
728
- }
729
- }
730
- val placeHolder by produceState<String?>(null, inputSearchProps.placeHolder) {
731
- if (inputSearchProps.placeHolder.isNullOrEmpty()) return@produceState
732
- snapshotFlow { textState }.collectLatest {
733
- value = if (it.isEmpty()) inputSearchProps.placeHolder else null
734
- }
735
- }
736
- val iconRightModifier = remember {
737
- Modifier
738
- .padding(start = Spacing.L)
739
- .drawWithContent {
740
- val offsetX = -Spacing.S.toPx()
741
- drawLine(
742
- start = Offset(
743
- x = offsetX,
744
- y = 0f,
745
- ),
746
- end = Offset(
747
- x = offsetX,
748
- y = size.height,
749
- ),
750
- color = theme.colors.primary,
751
- strokeWidth = 1.dp.toPx(),
752
- )
753
- drawContent()
754
- }
755
- }
756
-
757
- Row(
758
- modifier = Modifier
759
- .padding(
760
- horizontal = Spacing.M,
761
- vertical = Spacing.S,
762
- ),
763
- horizontalArrangement = Arrangement.Start,
764
- verticalAlignment = Alignment.CenterVertically,
765
- ) {
766
- inputSearchProps.customSearchIcon?.invoke() ?: Icon(
767
- source = "navigation_search",
768
- modifier = Modifier.padding(end = Spacing.XS),
769
- size = 24.dp,
770
- color = theme.colors.text.hint
771
- )
772
- Box(
773
- modifier = Modifier.weight(1f),
774
- contentAlignment = Alignment.CenterStart,
775
- ) {
776
- if (!placeHolder.isNullOrEmpty()) {
777
- inputSearchProps.customPlaceHolder?.invoke() ?: Text(
778
- text = placeHolder ?: "",
779
- style = inputSearchProps.customTextStyle
780
- ?: Typography.bodyDefaultRegular,
781
- maxLines = 1,
782
- color = theme.colors.text.hint,
783
- overflow = TextOverflow.Ellipsis
784
- )
785
- }
786
- innerTextField()
787
- }
788
-
789
- if (isShowClear) {
790
- inputSearchProps.customIconClear?.invoke() ?: Icon(
791
- source = "24_navigation_close_circle_full",
792
- size = 16.dp,
793
- color = theme.colors.text.hint,
794
- modifier = Modifier.padding(start = Spacing.XS)
795
- .noFeedbackClickable(onClick = inputSearchProps.onClear),
796
- )
797
- }
798
-
799
- inputSearchProps.iconRightTextField?.invoke(iconRightModifier)
800
- }
801
- }
802
- )
803
-
804
- if (isShowBtnText) {
805
- Text(
806
- text = inputSearchProps.btnText ?: "",
807
- style = Typography.actionDefaultBold,
808
- color = theme.colors.text.default,
809
- modifier = Modifier.padding(start = Spacing.L)
810
- .noFeedbackClickable(onClick = inputSearchProps.onPressBtnText)
811
- )
812
- }
813
- }
814
- }
815
-
816
- fun Modifier.hideKeyboardOnTap() = composed {
817
- val focusManager = LocalFocusManager.current
818
- val keyboardManager = LocalSoftwareKeyboardController.current
819
-
820
- pointerInput(Unit) {
821
- detectTapGestures {
822
- keyboardManager?.hide()
823
- focusManager.clearFocus()
824
- }
825
- }
826
- }