@momo-kits/native-kits 0.160.7 → 0.160.8-debug

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