@momo-kits/native-kits 0.167.1-duo.13 → 0.167.1-duo.13-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 (149) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +204 -0
  3. package/compose/build.gradle.kts.backup +204 -0
  4. package/compose/compose.podspec +47 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +153 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +52 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +124 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +183 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +207 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +39 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +293 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +831 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +110 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +378 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +361 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +16 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +188 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +297 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +260 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +338 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +137 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +106 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +393 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +708 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +209 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +231 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +98 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +312 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +408 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +103 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +366 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +37 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +185 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +74 -0
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +13 -0
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +40 -0
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +94 -0
  140. package/gradle/libs.versions.toml +69 -0
  141. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  142. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  143. package/gradle.properties +26 -0
  144. package/gradlew +252 -0
  145. package/gradlew.bat +94 -0
  146. package/ios-demo/README.md +120 -0
  147. package/local.properties +8 -0
  148. package/package.json +1 -1
  149. package/settings.gradle.kts +64 -0
@@ -0,0 +1,363 @@
1
+ package vn.momo.kits.navigation.component
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.layout.*
6
+ import androidx.compose.foundation.shape.CircleShape
7
+ import androidx.compose.foundation.shape.RoundedCornerShape
8
+ import androidx.compose.foundation.text.BasicText
9
+ import androidx.compose.foundation.text.TextAutoSize
10
+ import androidx.compose.runtime.Composable
11
+ import androidx.compose.runtime.Immutable
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.draw.clipToBounds
17
+ import androidx.compose.ui.layout.ContentScale
18
+ import androidx.compose.ui.text.TextStyle
19
+ import androidx.compose.ui.text.font.FontWeight
20
+ import androidx.compose.ui.text.style.TextOverflow
21
+ import androidx.compose.ui.unit.Dp
22
+ import androidx.compose.ui.unit.dp
23
+ import androidx.compose.ui.unit.sp
24
+ import vn.momo.kits.components.Image
25
+ import vn.momo.kits.components.Options
26
+ import vn.momo.kits.components.Skeleton
27
+ import vn.momo.kits.components.Text
28
+ import vn.momo.kits.const.AppTheme
29
+ import vn.momo.kits.const.Colors
30
+ import vn.momo.kits.const.Spacing
31
+ import vn.momo.kits.const.Typography
32
+ import vn.momo.kits.const.getFontFamily
33
+ import vn.momo.kits.modifier.activeOpacityClickable
34
+ import vn.momo.kits.navigation.component.HeaderTitle.User
35
+
36
+ @Composable
37
+ internal fun HeaderUser(
38
+ data: HeaderTitle
39
+ ) {
40
+ if (data !is User) return
41
+
42
+ if (data.isLoading) {
43
+ return TitleUserShimmer()
44
+ }
45
+
46
+ val maxWidth = headerTitleMaxWidth()
47
+
48
+ Row(
49
+ modifier = Modifier
50
+ .fillMaxWidth()
51
+ .padding(vertical = Spacing.XS)
52
+ .activeOpacityClickable(enabled = data.onPress != null, onClick = { data.onPress?.invoke() }),
53
+ horizontalArrangement = Arrangement.SpaceBetween,
54
+ verticalAlignment = Alignment.CenterVertically
55
+ ) {
56
+ Row(
57
+ modifier = Modifier.widthIn(max = maxWidth),
58
+ verticalAlignment = Alignment.CenterVertically
59
+ ) {
60
+ Box(modifier = Modifier.size(Spacing.XXL)) {
61
+ AvatarGroup(urls = AvatarUrls(data.image ?: listOf()), title = data.title)
62
+ if (data.dotColor != null) {
63
+ Box(
64
+ modifier = Modifier
65
+ .align(Alignment.BottomEnd)
66
+ .size(10.dp)
67
+ .clip(CircleShape)
68
+ .background(data.dotColor)
69
+ )
70
+ }
71
+ }
72
+
73
+ Spacer(Modifier.width(6.dp))
74
+
75
+ Column(modifier = Modifier.weight(1f, fill = false)) {
76
+ Row(verticalAlignment = Alignment.CenterVertically) {
77
+ Text(
78
+ text = data.title,
79
+ color = data.tintColor,
80
+ style = Typography.actionXsBold,
81
+ fontFamily = HEADER_FONT_FAMILY,
82
+ maxLines = 1,
83
+ overflow = TextOverflow.Ellipsis
84
+ )
85
+ if (data.icons.isNotEmpty()) {
86
+ Spacer(Modifier.width(6.dp))
87
+ Row(verticalAlignment = Alignment.CenterVertically) {
88
+ data.icons.forEach { icon ->
89
+ RemoteIcon16(url = icon)
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ if (!data.subTitle.isNullOrEmpty()) {
96
+ Spacer(Modifier.height(2.dp))
97
+ Text(
98
+ text = data.subTitle,
99
+ color = data.tintColor,
100
+ style = Typography.descriptionXsRegular,
101
+ maxLines = 1,
102
+ overflow = TextOverflow.Ellipsis
103
+ )
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ @Composable
111
+ private fun TitleUserShimmer() {
112
+ val theme = AppTheme.current
113
+ Row(
114
+ modifier = Modifier
115
+ .fillMaxWidth()
116
+ .padding(vertical = Spacing.XS),
117
+ verticalAlignment = Alignment.CenterVertically
118
+ ) {
119
+ Box(
120
+ modifier = Modifier
121
+ .size(Spacing.XXL)
122
+ .clip(CircleShape)
123
+ .background(theme.colors.border.default)
124
+ ) {
125
+ Skeleton()
126
+ }
127
+ Spacer(Modifier.width(Spacing.M / 2))
128
+ Column(modifier = Modifier.fillMaxWidth()) {
129
+ Box(
130
+ modifier = Modifier
131
+ .height(18.dp)
132
+ .width(120.dp)
133
+ .clip(RoundedCornerShape(8.dp))
134
+ ) { Skeleton() }
135
+ Spacer(Modifier.height(Spacing.XXS))
136
+ Box(
137
+ modifier = Modifier
138
+ .height(12.dp)
139
+ .width(120.dp)
140
+ .clip(RoundedCornerShape(8.dp))
141
+ ) { Skeleton() }
142
+ }
143
+ }
144
+ }
145
+
146
+ @Composable
147
+ private fun AvatarGroup(
148
+ urls: AvatarUrls?,
149
+ title: String? = null,
150
+ size: Dp = Spacing.XXL
151
+ ) {
152
+ val theme = AppTheme.current
153
+ val modifierBorder = remember {
154
+ Modifier.clip(CircleShape).border(width = (0.5).dp, color = theme.colors.border.default, shape = CircleShape)
155
+ }
156
+ val options = Options(
157
+ contentScale = ContentScale.Crop,
158
+ alignment = Alignment.Center
159
+ )
160
+
161
+ when (urls?.items?.size) {
162
+ 0 -> InitialsAvatar(
163
+ modifier = modifierBorder,
164
+ name = title ?: "",
165
+ fallbackInitials = null,
166
+ size = size
167
+ )
168
+ 1 -> SingleAvatar(options = options, modifier = modifierBorder, urls.items[0], size)
169
+ 2 -> TwoAvatar(options = options, modifier = modifierBorder, urls, size)
170
+ 3 -> ThreeAvatar(options = options, modifier = modifierBorder, urls, size)
171
+ 4 -> FourAvatar(options = options, modifier = modifierBorder, urls, size)
172
+ else -> ManyAvatar(options = options, modifier = modifierBorder, urls!!, size)
173
+ }
174
+ }
175
+
176
+ @Composable
177
+ private fun SingleAvatar(options: Options, modifier: Modifier = Modifier, url: String, size: Dp) {
178
+ Image(
179
+ source = url,
180
+ options = options,
181
+ modifier = modifier
182
+ .size(size)
183
+ )
184
+ }
185
+
186
+ @Composable
187
+ private fun TwoAvatar(options: Options, modifier: Modifier = Modifier, urls: AvatarUrls, size: Dp) {
188
+ val child = 24.dp
189
+ Box(modifier = Modifier.size(size)) {
190
+ Image(
191
+ source = urls.items[0],
192
+ options = options,
193
+ modifier = modifier
194
+ .size(child)
195
+ .align(Alignment.TopEnd)
196
+ )
197
+ Image(
198
+ source = urls.items[1],
199
+ options = options,
200
+ modifier = modifier
201
+ .size(child)
202
+ .align(Alignment.BottomStart)
203
+ )
204
+ }
205
+ }
206
+
207
+ @Composable
208
+ private fun ThreeAvatar(options: Options, modifier: Modifier = Modifier, urls: AvatarUrls, size: Dp) {
209
+ val child = 16.dp
210
+ Box(modifier = Modifier.size(size).padding(2.dp)) {
211
+ Image(
212
+ source = urls.items[0],
213
+ options = options,
214
+ modifier = modifier
215
+ .size(child)
216
+ .align(Alignment.BottomEnd)
217
+ )
218
+ Image(
219
+ source = urls.items[1],
220
+ options = options,
221
+ modifier = modifier
222
+ .size(child)
223
+ .align(Alignment.TopCenter)
224
+ )
225
+ Image(
226
+ source = urls.items[2],
227
+ options = options,
228
+ modifier = modifier
229
+ .size(child)
230
+ .align(Alignment.BottomStart)
231
+ )
232
+ }
233
+ }
234
+
235
+ @Composable
236
+ private fun FourAvatar(options: Options, modifier: Modifier = Modifier, urls: AvatarUrls, size: Dp) {
237
+ val child = 16.dp
238
+ Box(modifier = Modifier.size(size).padding(1.dp)) {
239
+ Image(
240
+ source = urls.items[0],
241
+ options = options,
242
+ modifier = modifier
243
+ .size(child)
244
+ .align(Alignment.BottomStart)
245
+ )
246
+ Image(
247
+ source = urls.items[1],
248
+ options = options,
249
+ modifier = modifier
250
+ .size(child)
251
+ .align(Alignment.BottomEnd)
252
+ )
253
+ Image(
254
+ source = urls.items[2],
255
+ options = options,
256
+ modifier = modifier
257
+ .size(child)
258
+ .align(Alignment.TopEnd)
259
+ )
260
+ Image(
261
+ source = urls.items[3],
262
+ options = options,
263
+ modifier = modifier
264
+ .size(child)
265
+ .align(Alignment.TopStart)
266
+ )
267
+ }
268
+ }
269
+
270
+ @Composable
271
+ private fun ManyAvatar(options: Options, modifier: Modifier = Modifier, urls: AvatarUrls, size: Dp) {
272
+ val child = 16.dp
273
+ val more = urls.items.size - 3
274
+ Box(modifier = Modifier.size(size).padding(1.dp)) {
275
+ Image(
276
+ source = urls.items[0],
277
+ options = options,
278
+ modifier = modifier
279
+ .size(child)
280
+ .align(Alignment.BottomStart)
281
+ )
282
+ Image(
283
+ source = urls.items[1],
284
+ options = options,
285
+ modifier = modifier
286
+ .size(child)
287
+ .align(Alignment.TopEnd)
288
+ )
289
+ Image(
290
+ source = urls.items[2],
291
+ options = options,
292
+ modifier = modifier
293
+ .size(child)
294
+ .align(Alignment.TopStart)
295
+ )
296
+ Box(
297
+ modifier = modifier
298
+ .size(child)
299
+ .align(Alignment.BottomEnd)
300
+ .background(Colors.pink_09)
301
+ .padding(1.dp)
302
+ .clipToBounds(),
303
+ contentAlignment = Alignment.Center
304
+ ) {
305
+ BasicText(
306
+ text = "+$more",
307
+ style = TextStyle(
308
+ color = Colors.pink_03,
309
+ fontFamily = getFontFamily(AppTheme.current.font, FontWeight.Normal)
310
+ ),
311
+ maxLines = 1,
312
+ autoSize = TextAutoSize.StepBased(
313
+ minFontSize = 1.sp,
314
+ maxFontSize = 10.sp,
315
+ stepSize = 1.sp
316
+ )
317
+ )
318
+ }
319
+ }
320
+ }
321
+
322
+ @Composable
323
+ private fun InitialsAvatar(
324
+ modifier: Modifier = Modifier,
325
+ name: String,
326
+ fallbackInitials: String? = null,
327
+ size: Dp = Spacing.XXL
328
+ ) {
329
+ val initials = remember(name, fallbackInitials) {
330
+ fallbackInitials ?: run {
331
+ val words = name.trim().split(Regex("\\s+")).takeLast(2)
332
+ words.joinToString("") { it.firstOrNull()?.uppercase() ?: "" }
333
+ }
334
+ }
335
+ Box(
336
+ modifier = modifier
337
+ .size(size)
338
+ .background(Colors.pink_09),
339
+ contentAlignment = Alignment.Center
340
+ ) {
341
+ Text(
342
+ text = initials,
343
+ color = Colors.pink_03,
344
+ style = Typography.descriptionXsRegular
345
+ )
346
+ }
347
+ }
348
+
349
+ @Composable
350
+ private fun RemoteIcon16(url: String) {
351
+ Image(
352
+ source = url,
353
+ options = Options(
354
+ contentScale = ContentScale.Crop
355
+ ),
356
+ modifier = Modifier
357
+ .size(16.dp)
358
+ .clip(RoundedCornerShape(4.dp)),
359
+ )
360
+ }
361
+
362
+ @Immutable
363
+ private data class AvatarUrls(val items: List<String>)
@@ -0,0 +1,185 @@
1
+ package vn.momo.kits.navigation.component
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.layout.Arrangement
6
+ import androidx.compose.foundation.layout.Box
7
+ import androidx.compose.foundation.layout.BoxScope
8
+ import androidx.compose.foundation.layout.Column
9
+ import androidx.compose.foundation.layout.ColumnScope
10
+ import androidx.compose.foundation.layout.Spacer
11
+ import androidx.compose.foundation.layout.absolutePadding
12
+ import androidx.compose.foundation.layout.fillMaxWidth
13
+ import androidx.compose.foundation.layout.height
14
+ import androidx.compose.foundation.layout.offset
15
+ import androidx.compose.foundation.layout.size
16
+ import androidx.compose.foundation.layout.width
17
+ import androidx.compose.foundation.shape.CircleShape
18
+ import androidx.compose.foundation.shape.RoundedCornerShape
19
+ import androidx.compose.runtime.Composable
20
+ import androidx.compose.runtime.LaunchedEffect
21
+ import androidx.compose.ui.AbsoluteAlignment
22
+ import androidx.compose.ui.Alignment
23
+ import androidx.compose.ui.Modifier
24
+ import androidx.compose.ui.draw.clip
25
+ import androidx.compose.ui.draw.shadow
26
+ import androidx.compose.ui.graphics.Shape
27
+ import androidx.compose.ui.layout.layout
28
+ import androidx.compose.ui.unit.Dp
29
+ import androidx.compose.ui.unit.constrainHeight
30
+ import androidx.compose.ui.unit.dp
31
+ import vn.momo.kits.components.BadgeDot
32
+ import vn.momo.kits.components.DotSize
33
+ import vn.momo.kits.components.Icon
34
+ import vn.momo.kits.const.Colors
35
+ import vn.momo.kits.const.Radius
36
+ import vn.momo.kits.const.Spacing
37
+ import vn.momo.kits.layout.DuoMetrics
38
+ import vn.momo.kits.layout.SideBarEdge
39
+ import vn.momo.kits.layout.getScreenLayout
40
+ import vn.momo.kits.modifier.activeOpacityClickable
41
+ import vn.momo.kits.modifier.conditional
42
+ import vn.momo.kits.modifier.setAutomationId
43
+ import vn.momo.kits.navigation.LocalNavigator
44
+ import vn.momo.kits.navigation.LocalOptions
45
+ import vn.momo.kits.navigation.bottomtab.LocalDuoBarCompression
46
+
47
+ private val SIDE_BAR_ICON_SIZE = 24.dp
48
+
49
+ // iPhone Duo: back and toolkit leave the bar for a column in the side safe area, as the system bars do.
50
+ // bottomInset is what footer / tab bar / home indicator take from the bottom, gap included; the column stays above it.
51
+ @Composable
52
+ internal fun BoxScope.HeaderSideBar(bottomInset: Dp, modifier: Modifier = Modifier) {
53
+ val options = LocalOptions.current
54
+ val navigator = LocalNavigator.current
55
+ val sideBar = getScreenLayout().sideBar ?: return
56
+ val toolkit = options.headerRight as? HeaderRight.Toolkit
57
+ if (options.headerType == HeaderType.None || (options.hiddenBack && toolkit == null)) return
58
+
59
+ val headerColor = getHeaderColor(options.headerType, headerOpacity(), options.tintColor, Colors.black_17)
60
+ val isRight = sideBar.edge == SideBarEdge.RIGHT
61
+ val compression = LocalDuoBarCompression.current
62
+
63
+ // full height, so the tab bar compression decision matches this screen's toolkit
64
+ val fullHeight = DuoMetrics.controlSize + (toolkit?.let { Spacing.M + toolkitColumnHeight(it) } ?: 0.dp)
65
+ LaunchedEffect(fullHeight, compression.setToolbarHeight) { compression.setToolbarHeight(fullHeight) }
66
+
67
+ Column(
68
+ modifier = modifier
69
+ .align(if (isRight) AbsoluteAlignment.TopRight else AbsoluteAlignment.TopLeft)
70
+ .width(sideBar.width)
71
+ .layout { measurable, constraints ->
72
+ val placeable = measurable.measure(constraints.copy(minHeight = 0))
73
+ val maxY = constraints.maxHeight - bottomInset.roundToPx() - placeable.height
74
+ val y = minOf(sideBar.top.roundToPx(), maxY).coerceAtLeast(0)
75
+ layout(placeable.width, constraints.constrainHeight(y + placeable.height)) {
76
+ placeable.place(0, y)
77
+ }
78
+ }
79
+ .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M),
80
+ horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
81
+ verticalArrangement = Arrangement.spacedBy(Spacing.M),
82
+ ) {
83
+ if (options.hiddenBack) {
84
+ // keep the slot so the toolkit does not jump between root and pushed screens
85
+ Spacer(Modifier.size(DuoMetrics.controlSize))
86
+ } else {
87
+ SideBarButton(
88
+ icon = "arrow-back",
89
+ headerColor = headerColor,
90
+ automationId = "btn_navigation_back",
91
+ onClick = { navigator.onBackSafe { } },
92
+ )
93
+ }
94
+ when {
95
+ toolkit == null || compression.toolbarHidden -> Unit
96
+ // HIG "Toolbar compressed": tools fold into one button, distinct from the useMore icon
97
+ compression.toolbarCompressed -> SideBarButton(
98
+ icon = "navigation_menu",
99
+ headerColor = headerColor,
100
+ showBadge = toolkit.tools.any { group -> group.items.any { it.showBadge } },
101
+ automationId = "btn_navigation_toolbar",
102
+ onClick = compression.expandToolbar,
103
+ )
104
+ else -> Toolkit(headerRight = toolkit, tintColor = options.tintColor, headerColor = headerColor, vertical = true)
105
+ }
106
+ }
107
+ }
108
+
109
+ @Composable
110
+ internal fun SideBarButton(
111
+ icon: String,
112
+ headerColor: HeaderColor,
113
+ onClick: () -> Unit,
114
+ enabled: Boolean = true,
115
+ showBadge: Boolean = false,
116
+ automationId: String? = null,
117
+ ) {
118
+ Box {
119
+ Box(
120
+ modifier = Modifier
121
+ .size(DuoMetrics.controlSize)
122
+ .sideBarGlass(headerColor, CircleShape)
123
+ .activeOpacityClickable(enabled = enabled, onClick = onClick)
124
+ .conditional(automationId != null) { setAutomationId(automationId.orEmpty()) },
125
+ contentAlignment = Alignment.Center,
126
+ ) {
127
+ Icon(source = icon, size = SIDE_BAR_ICON_SIZE, color = headerColor.tintIconColor)
128
+ }
129
+ if (showBadge) {
130
+ BadgeDot(
131
+ size = DotSize.Small,
132
+ modifier = Modifier.align(Alignment.TopEnd).offset(x = -Spacing.XXS, y = Spacing.XXS),
133
+ )
134
+ }
135
+ }
136
+ }
137
+
138
+ // Capsule grouping related controls, one item per 50pt.
139
+ @Composable
140
+ internal fun SideBarGroup(
141
+ headerColor: HeaderColor,
142
+ itemCount: Int,
143
+ content: @Composable ColumnScope.() -> Unit,
144
+ ) {
145
+ val height = if (itemCount > 1) DuoMetrics.itemPitch * itemCount else DuoMetrics.controlSize
146
+ Column(
147
+ modifier = Modifier
148
+ .width(DuoMetrics.controlSize)
149
+ .height(height)
150
+ .sideBarGlass(headerColor, RoundedCornerShape(Radius.XL)),
151
+ content = content,
152
+ )
153
+ }
154
+
155
+ @Composable
156
+ internal fun ColumnScope.SideBarGroupItem(
157
+ icon: String,
158
+ headerColor: HeaderColor,
159
+ automationId: String,
160
+ onClick: () -> Unit,
161
+ ) {
162
+ Box(
163
+ modifier = Modifier
164
+ .weight(1f)
165
+ .fillMaxWidth()
166
+ .activeOpacityClickable(onClick = onClick)
167
+ .setAutomationId(automationId),
168
+ contentAlignment = Alignment.Center,
169
+ ) {
170
+ Icon(source = icon, size = SIDE_BAR_ICON_SIZE, color = headerColor.tintIconColor)
171
+ }
172
+ }
173
+
174
+ // Dark glass under light icons (banner headers), light glass otherwise. The light one is opaque:
175
+ // Compose has no backdrop blur and a translucent fill shows its own shadow through (RN uses 85% white).
176
+ private fun Modifier.sideBarGlass(headerColor: HeaderColor, shape: Shape): Modifier =
177
+ if (headerColor.tintIconColor == Colors.black_01) {
178
+ clip(shape)
179
+ .background(Colors.black_20.copy(alpha = 0.5f))
180
+ .border(0.5.dp, Colors.black_01.copy(alpha = 0.2f), shape)
181
+ } else {
182
+ shadow(3.dp, shape)
183
+ .background(Colors.black_01)
184
+ .border(0.5.dp, Colors.black_20.copy(alpha = 0.08f), shape)
185
+ }
@@ -0,0 +1,133 @@
1
+ package vn.momo.kits.navigation.component
2
+
3
+ import androidx.compose.animation.core.Animatable
4
+ import androidx.compose.animation.core.tween
5
+ import androidx.compose.foundation.border
6
+ import androidx.compose.foundation.layout.Box
7
+ import androidx.compose.foundation.layout.fillMaxWidth
8
+ import androidx.compose.foundation.layout.offset
9
+ import androidx.compose.runtime.Composable
10
+ import androidx.compose.runtime.DisposableEffect
11
+ import androidx.compose.runtime.LaunchedEffect
12
+ import androidx.compose.runtime.getValue
13
+ import androidx.compose.runtime.mutableStateOf
14
+ import androidx.compose.runtime.remember
15
+ import androidx.compose.runtime.rememberCoroutineScope
16
+ import androidx.compose.runtime.setValue
17
+ import androidx.compose.ui.Modifier
18
+ import androidx.compose.ui.layout.onGloballyPositioned
19
+ import androidx.compose.ui.platform.LocalDensity
20
+ import androidx.compose.ui.unit.IntOffset
21
+ import androidx.compose.ui.unit.dp
22
+ import kotlinx.coroutines.delay
23
+ import vn.momo.kits.application.IsShowBaseLineDebug
24
+ import vn.momo.kits.const.Colors
25
+ import vn.momo.kits.modifier.conditional
26
+ import kotlinx.coroutines.launch
27
+ import vn.momo.kits.const.AppNavigationBar
28
+ import vn.momo.kits.navigation.LocalFooterHeightPx
29
+ import vn.momo.kits.navigation.LocalNavigator
30
+ import vn.momo.kits.navigation.LocalOptions
31
+ import vn.momo.kits.navigation.OverplayComponentRegistry
32
+ import kotlin.time.Duration.Companion.milliseconds
33
+
34
+ sealed class SnackBar(open val duration: Long? = null) {
35
+ data class Custom(
36
+ val content: @Composable () -> Unit,
37
+ override val duration: Long? = 3000L
38
+ ) : SnackBar(duration)
39
+
40
+ data class Toast(
41
+ override val duration: Long? = 3000L
42
+ ) : SnackBar(duration)
43
+ }
44
+
45
+ @Composable
46
+ internal fun SnackBar(
47
+ data: SnackBar,
48
+ onDismiss: (() -> Unit)?
49
+ ) {
50
+ val navigator = LocalNavigator.current
51
+ val options = LocalOptions.current
52
+ val density = LocalDensity.current
53
+ val footerHeightPxState = LocalFooterHeightPx.current
54
+ val navigationBar = AppNavigationBar.current
55
+
56
+ val footerHeight = if (options.footerComponent != null) {
57
+ footerHeightPxState.value
58
+ } else {
59
+ with(density){ navigationBar.toPx() }
60
+ }.toInt()
61
+
62
+ var startPosition by remember { mutableStateOf(Float.MAX_VALUE) }
63
+ val targetPosition = 0f
64
+
65
+ var offsetY by remember { mutableStateOf(Animatable(startPosition)) }
66
+ val coroutineScope = rememberCoroutineScope()
67
+
68
+ suspend fun openEvent() {
69
+ offsetY.snapTo(startPosition)
70
+ offsetY.animateTo(
71
+ targetValue = targetPosition,
72
+ animationSpec = tween(
73
+ durationMillis = 350,
74
+ )
75
+ )
76
+ }
77
+
78
+ fun closeEvent() {
79
+ coroutineScope.launch {
80
+ offsetY.animateTo(
81
+ targetValue = startPosition,
82
+ animationSpec = tween(
83
+ durationMillis = 200,
84
+ )
85
+ )
86
+ // hideSnackBar() would call clear() -> this close again while still bound
87
+ OverplayComponentRegistry.hardClearAfterDismiss()
88
+ }
89
+ }
90
+
91
+ LaunchedEffect(startPosition) {
92
+ if (startPosition != Float.MAX_VALUE){
93
+ openEvent()
94
+ }
95
+ }
96
+
97
+ LaunchedEffect(data.duration) {
98
+ val duration = data.duration
99
+ if (duration != null) {
100
+ delay(duration.milliseconds)
101
+ navigator.hideSnackBar()
102
+ }
103
+ }
104
+
105
+ DisposableEffect(Unit) {
106
+ OverplayComponentRegistry.bindClose {
107
+ closeEvent()
108
+ }
109
+ onDispose {
110
+ onDismiss?.invoke()
111
+ }
112
+ }
113
+
114
+ Box(
115
+ modifier = Modifier
116
+ .offset { IntOffset(0, offsetY.value.toInt() - footerHeight) }
117
+ .onGloballyPositioned {
118
+ if (startPosition != it.size.height.toFloat()) {
119
+ startPosition = it.size.height.toFloat()
120
+ offsetY = Animatable(startPosition)
121
+ }
122
+ }
123
+ .fillMaxWidth()
124
+ .conditional(IsShowBaseLineDebug) {
125
+ border(1.dp, Colors.blue_03)
126
+ }
127
+ ) {
128
+ when (data) {
129
+ is SnackBar.Custom -> data.content()
130
+ is SnackBar.Toast -> {}
131
+ }
132
+ }
133
+ }