@momo-kits/native-kits 0.167.1-duo.20-debug → 0.167.1-duo.21

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 (137) hide show
  1. package/ios/Navigation/Component/HeaderRight.swift +25 -6
  2. package/package.json +1 -1
  3. package/build.gradle.kts +0 -11
  4. package/compose/build.gradle.kts +0 -204
  5. package/compose/build.gradle.kts.backup +0 -204
  6. package/compose/compose.podspec +0 -47
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -947
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -20
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -283
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -309
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -727
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -218
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -231
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -98
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -312
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -447
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -379
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -13
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -78
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -94
  130. package/gradle/libs.versions.toml +0 -69
  131. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  132. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  133. package/gradle.properties +0 -26
  134. package/gradlew +0 -252
  135. package/gradlew.bat +0 -94
  136. package/ios-demo/README.md +0 -120
  137. package/settings.gradle.kts +0 -64
@@ -1,74 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.foundation.layout.Box
4
- import androidx.compose.foundation.layout.Column
5
- import androidx.compose.foundation.layout.Row
6
- import androidx.compose.foundation.layout.Spacer
7
- import androidx.compose.foundation.layout.fillMaxWidth
8
- import androidx.compose.foundation.layout.height
9
- import androidx.compose.foundation.layout.width
10
- import androidx.compose.foundation.layout.widthIn
11
- import androidx.compose.foundation.shape.RoundedCornerShape
12
- import androidx.compose.runtime.Composable
13
- import androidx.compose.ui.Alignment
14
- import androidx.compose.ui.Modifier
15
- import androidx.compose.ui.draw.clip
16
- import androidx.compose.ui.graphics.Color
17
- import androidx.compose.ui.text.style.TextOverflow
18
- import androidx.compose.ui.unit.dp
19
- import vn.momo.kits.components.Icon
20
- import vn.momo.kits.components.Skeleton
21
- import vn.momo.kits.components.Text
22
- import vn.momo.kits.const.Spacing
23
- import vn.momo.kits.const.Typography
24
- import vn.momo.kits.modifier.activeOpacityClickable
25
-
26
- @Composable
27
- internal fun HeaderLocation(
28
- data: HeaderTitle,
29
- tintIconColor: Color,
30
- ) {
31
- if (data !is HeaderTitle.Location) return
32
- if (data.isLoading) return TitleLocationShimmer()
33
-
34
- val maxWidth = headerTitleMaxWidth()
35
- val tint = parseHeaderTint(data.tintColor) ?: tintIconColor
36
-
37
- Column(
38
- modifier = Modifier
39
- .widthIn(max = maxWidth)
40
- .activeOpacityClickable(enabled = data.onPress != null, onClick = { data.onPress?.invoke() }),
41
- horizontalAlignment = Alignment.Start,
42
- ) {
43
- if (!data.description.isNullOrEmpty()) {
44
- Text(
45
- text = data.description,
46
- color = tint,
47
- style = Typography.descriptionXsRegular,
48
- maxLines = 1,
49
- overflow = TextOverflow.Ellipsis,
50
- )
51
- }
52
- Row(verticalAlignment = Alignment.CenterVertically) {
53
- Text(
54
- text = data.location,
55
- color = tint,
56
- style = Typography.actionXsBold,
57
- maxLines = 1,
58
- overflow = TextOverflow.Ellipsis,
59
- modifier = Modifier.weight(1f, fill = false),
60
- )
61
- Spacer(Modifier.width(Spacing.XS))
62
- Icon(source = "16_arrow_chevron_down_small", size = 16.dp, color = tint)
63
- }
64
- }
65
- }
66
-
67
- @Composable
68
- private fun TitleLocationShimmer() {
69
- Column(modifier = Modifier.fillMaxWidth()) {
70
- Box(modifier = Modifier.height(12.dp).width(120.dp).clip(RoundedCornerShape(8.dp))) { Skeleton() }
71
- Spacer(Modifier.height(Spacing.XXS))
72
- Box(modifier = Modifier.height(18.dp).width(120.dp).clip(RoundedCornerShape(8.dp))) { Skeleton() }
73
- }
74
- }
@@ -1,379 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import vn.momo.kits.modifier.InternalApi
4
-
5
- import androidx.compose.foundation.background
6
- import androidx.compose.foundation.border
7
- import androidx.compose.foundation.layout.Arrangement
8
- import androidx.compose.foundation.layout.Box
9
- import androidx.compose.foundation.layout.Column
10
- import androidx.compose.foundation.layout.Row
11
- import androidx.compose.foundation.layout.height
12
- import androidx.compose.foundation.layout.offset
13
- import androidx.compose.foundation.layout.padding
14
- import androidx.compose.foundation.layout.size
15
- import androidx.compose.foundation.layout.width
16
- import androidx.compose.foundation.shape.CircleShape
17
- import androidx.compose.foundation.shape.RoundedCornerShape
18
- import androidx.compose.runtime.Composable
19
- import androidx.compose.runtime.LaunchedEffect
20
- import androidx.compose.runtime.derivedStateOf
21
- import androidx.compose.runtime.getValue
22
- import androidx.compose.runtime.mutableStateOf
23
- import androidx.compose.runtime.remember
24
- import androidx.compose.runtime.setValue
25
- import androidx.compose.ui.Alignment
26
- import androidx.compose.ui.Modifier
27
- import androidx.compose.ui.draw.clip
28
- import androidx.compose.ui.graphics.Color
29
- import androidx.compose.ui.unit.Dp
30
- import androidx.compose.ui.unit.dp
31
- import vn.momo.kits.layout.DuoMetrics
32
- import vn.momo.kits.application.LocalContext
33
- import vn.momo.kits.application.MiniAppContext
34
- import vn.momo.kits.components.BadgeDot
35
- import vn.momo.kits.components.DotSize
36
- import vn.momo.kits.components.Icon
37
- import vn.momo.kits.const.Colors
38
- import vn.momo.kits.const.Spacing
39
- import vn.momo.kits.modifier.activeOpacityClickable
40
- import vn.momo.kits.navigation.LocalMaxApi
41
-
42
- @Composable
43
- @InternalApi
44
- fun HeaderRight(
45
- headerRight: HeaderRight,
46
- tintColor: Color? = null,
47
- headerColor: HeaderColor
48
- ) {
49
- when (headerRight) {
50
- is HeaderRight.None -> {}
51
- is HeaderRight.Custom -> {
52
- headerRight.content()
53
- }
54
- is HeaderRight.OnBoarding -> {}
55
- is HeaderRight.Toolkit -> {
56
- Toolkit(
57
- headerRight = headerRight,
58
- tintColor = tintColor,
59
- headerColor = headerColor
60
- )
61
- }
62
- }
63
- }
64
-
65
- private const val HELP_CENTER_APP_ID = "vn.momo.helpcenter"
66
-
67
- private fun usesHelpCenter(context: MiniAppContext?): Boolean =
68
- context != null && context.appId != HELP_CENTER_APP_ID
69
-
70
- private fun showsShortcut(headerRight: HeaderRight.Toolkit, context: MiniAppContext?): Boolean =
71
- headerRight.useShortcut && !(headerRight.useMore && context == null)
72
-
73
- // Height of the vertical toolkit: the optional shortcut, then the help/home capsule.
74
- @Composable
75
- internal fun toolkitColumnHeight(headerRight: HeaderRight.Toolkit): Dp {
76
- val context = LocalContext.current
77
- val shortcut = if (showsShortcut(headerRight, context)) DuoMetrics.controlSize + Spacing.M else 0.dp
78
- val groupCount = if (usesHelpCenter(context)) 2 else 1
79
- return shortcut + if (groupCount > 1) DuoMetrics.itemPitch * groupCount else DuoMetrics.controlSize
80
- }
81
-
82
- // SideBarColumn: the iPhone Duo side bar; SideBarRow: the Duo header row on the status bar, same 48pt controls.
83
- internal enum class ToolkitLayout { Bar, SideBarColumn, SideBarRow }
84
-
85
- @Composable
86
- internal fun Toolkit(
87
- headerRight: HeaderRight.Toolkit,
88
- tintColor: Color? = null,
89
- headerColor: HeaderColor,
90
- layout: ToolkitLayout = ToolkitLayout.Bar,
91
- ) {
92
- val api = LocalMaxApi.current
93
- val context = LocalContext.current
94
-
95
- var isFavorite by remember { mutableStateOf(false) }
96
- val isLoading by remember { mutableStateOf(false) }
97
-
98
- LaunchedEffect(context?.appCode) {
99
- api?.isFavoriteApp(mapOf("code" to context?.appCode)) { callback ->
100
- val response = callback?.get("response") as? Boolean
101
- isFavorite = response == true
102
- }
103
- }
104
-
105
- fun onPressShortcut() {
106
- api?.onToolAction(mapOf("item" to mapOf("key" to "onFavorite"), "context" to MiniAppContext.toMap(context))) { callback ->
107
- val response = callback?.get("response") as? Map<*, *>?
108
- val success = response?.get("success") as? Boolean
109
- if (success == true){
110
- isFavorite = !isFavorite
111
- }
112
- }
113
- }
114
-
115
- fun onPressMore() {
116
- api?.showTools(
117
- mapOf(
118
- "useSystemTools" to headerRight.useSystemTools,
119
- "tools" to headerRight.tools.map { it.toMap() },
120
- "context" to MiniAppContext.toMap(context)
121
- )
122
- ) { callback ->
123
- val response = callback?.get("response") as? String
124
- if (response != null) {
125
- headerRight.toolCallback?.invoke(response)
126
- }
127
- }
128
- }
129
-
130
- fun onPressHelpCenter() {
131
- if (context == null) return
132
- api?.showHelpCenter(
133
- mapOf(
134
- "appId" to context.appId,
135
- "code" to context.appCode,
136
- "name" to context.appName,
137
- "icon" to context.appIcon,
138
- "description" to context.description
139
- )
140
- ) {}
141
- }
142
-
143
- fun onPressClose() {
144
- if (headerRight.useCloseIcon) api?.dismiss { } else api?.dismissAll { }
145
- }
146
-
147
- val useHelpCenter = usesHelpCenter(context)
148
- val closeIcon = if (headerRight.useCloseIcon) "16_navigation_close_circle" else "16_basic_home"
149
-
150
- val navButtonConfig = getNavigationButtonConfig(
151
- headerRight,
152
- ::onPressShortcut,
153
- ::onPressMore
154
- )
155
-
156
- val showBadge = headerRight.tools.any { group ->
157
- group.items.any { it.showBadge }
158
- }
159
-
160
- val isShowShortcut = showsShortcut(headerRight, context)
161
-
162
- val icon by remember(navButtonConfig.icon, isFavorite) {
163
- derivedStateOf {
164
- navButtonConfig.icon.takeUnless { it == "star" }
165
- ?: if (isFavorite) "pin_star_checked" else "pin_star"
166
- }
167
- }
168
-
169
- if (layout != ToolkitLayout.Bar) {
170
- val horizontal = layout == ToolkitLayout.SideBarRow
171
- val controls = @Composable {
172
- if (isShowShortcut) {
173
- SideBarButton(
174
- icon = icon,
175
- headerColor = headerColor,
176
- enabled = !isLoading,
177
- showBadge = showBadge,
178
- onClick = navButtonConfig.onPress,
179
- )
180
- }
181
- SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1, horizontal = horizontal) { item ->
182
- if (useHelpCenter) {
183
- SideBarGroupItem(
184
- icon = "help_center",
185
- headerColor = headerColor,
186
- automationId = "btn_navigation_help_center",
187
- onClick = ::onPressHelpCenter,
188
- modifier = item,
189
- )
190
- }
191
- SideBarGroupItem(
192
- icon = closeIcon,
193
- headerColor = headerColor,
194
- automationId = "btn_navigation_close",
195
- onClick = ::onPressClose,
196
- modifier = item,
197
- )
198
- }
199
- }
200
- if (horizontal) {
201
- Row(horizontalArrangement = Arrangement.spacedBy(Spacing.M), verticalAlignment = Alignment.CenterVertically) {
202
- controls()
203
- }
204
- } else {
205
- Column(verticalArrangement = Arrangement.spacedBy(Spacing.M)) { controls() }
206
- }
207
- return
208
- }
209
-
210
- Row(
211
- verticalAlignment = Alignment.CenterVertically
212
- ) {
213
- if (isShowShortcut) {
214
- NavigationButton(
215
- disabled = isLoading,
216
- icon = icon,
217
- showBadge = showBadge,
218
- onClick = navButtonConfig.onPress,
219
- headerColor = headerColor
220
- )
221
- }
222
-
223
- Row(
224
- verticalAlignment = Alignment.CenterVertically,
225
- horizontalArrangement = Arrangement.Center,
226
- modifier = Modifier
227
- .padding(start = Spacing.S)
228
- .border(0.2.dp, headerColor.borderColor, shape = RoundedCornerShape(14.dp))
229
- .height(28.dp)
230
- .clip(shape = RoundedCornerShape(14.dp))
231
- .background(headerColor.backgroundButton)
232
- ) {
233
- if (useHelpCenter) {
234
- Icon(
235
- source = "help_center",
236
- size = 20.dp,
237
- color = headerColor.tintIconColor,
238
- modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressHelpCenter)
239
- )
240
- Box(
241
- modifier = Modifier
242
- .width(0.5.dp)
243
- .height(12.dp)
244
- .background(tintColor ?: Colors.black_20)
245
- )
246
- }
247
- Icon(
248
- source = closeIcon,
249
- size = 20.dp,
250
- color = headerColor.tintIconColor,
251
- modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressClose)
252
- )
253
- }
254
- }
255
- }
256
-
257
-
258
-
259
- @Composable
260
- internal fun NavigationButton(
261
- disabled: Boolean,
262
- icon: String,
263
- showBadge: Boolean? = false,
264
- onClick: () -> Unit,
265
- headerColor: HeaderColor
266
- ) {
267
- Box(
268
- modifier = Modifier
269
- .size(28.dp)
270
- .activeOpacityClickable(enabled = !disabled, onClick = onClick)
271
- ) {
272
- Box(
273
- modifier = Modifier
274
- .matchParentSize()
275
- .clip(CircleShape)
276
- .background(headerColor.backgroundButton)
277
- .border(0.2.dp, headerColor.borderColor, CircleShape)
278
- )
279
- Box(
280
- modifier = Modifier.matchParentSize(),
281
- contentAlignment = Alignment.Center
282
- ) {
283
- Icon(
284
- source = icon,
285
- size = 20.dp,
286
- color = headerColor.tintIconColor
287
- )
288
- }
289
-
290
- if (showBadge == true) {
291
- BadgeDot(
292
- size = DotSize.Small,
293
- modifier = Modifier
294
- .align(Alignment.TopEnd)
295
- .offset(x = -Spacing.XXS, y = -Spacing.XXS)
296
- )
297
- }
298
- }
299
- }
300
-
301
- private fun getNavigationButtonConfig(
302
- headerRight: HeaderRight.Toolkit,
303
- onPressShortcut: () -> Unit,
304
- onPressMore: () -> Unit
305
- ): NavigationButtonConfig {
306
- val totalTools = headerRight.tools.sumOf { it.items.size }
307
- val config = NavigationButtonConfig(icon = "star", onPress = onPressShortcut)
308
- return if (totalTools > 1 || headerRight.useMore == true) {
309
- NavigationButtonConfig(
310
- icon = "navigation_more_icon",
311
- onPress = onPressMore
312
- )
313
- } else if (totalTools == 1 && headerRight.tools.isNotEmpty()) {
314
- val singleTool = headerRight.tools.first().items.firstOrNull()
315
- return if (singleTool != null){
316
- NavigationButtonConfig(
317
- icon = singleTool.icon,
318
- onPress = {
319
- headerRight.toolCallback?.invoke(singleTool.key)
320
- }
321
- )
322
- } else {
323
- config
324
- }
325
- } else {
326
- config
327
- }
328
- }
329
-
330
- sealed interface HeaderRight {
331
- data object None : HeaderRight
332
- data class Custom(
333
- val content: @Composable () -> Unit
334
- ) : HeaderRight
335
- data object OnBoarding : HeaderRight
336
- data class Toolkit(
337
- val useShortcut: Boolean = false,
338
- val useMore: Boolean = false,
339
- val useSystemTools: Boolean = true,
340
- val tools: List<ToolGroup> = emptyList(),
341
- val toolCallback: ((String) -> Unit)? = { _ -> },
342
- // Close dismisses only this mini app instead of returning home.
343
- val useCloseIcon: Boolean = false,
344
- ) : HeaderRight
345
- }
346
-
347
- data class ToolGroup(
348
- val title: Map<String, String> = emptyMap(),
349
- val items: List<Tool>
350
- ) {
351
- fun toMap(): Map<String, Any> {
352
- return mapOf(
353
- "title" to title,
354
- "items" to items.map { it.toMap() }
355
- )
356
- }
357
- }
358
- data class Tool(
359
- val key: String,
360
- val icon: String,
361
- val showBadge: Boolean = false,
362
- val name: Map<String, String> = emptyMap(),
363
- val showRightIcon: Boolean = true,
364
- ) {
365
- fun toMap(): Map<String, Any> {
366
- return mapOf(
367
- "key" to key,
368
- "icon" to icon,
369
- "showBadge" to showBadge,
370
- "name" to name,
371
- "showRightIcon" to showRightIcon
372
- )
373
- }
374
- }
375
-
376
- private data class NavigationButtonConfig(
377
- val icon: String,
378
- val onPress: () -> Unit
379
- )
@@ -1,39 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.foundation.layout.fillMaxWidth
4
- import androidx.compose.runtime.Composable
5
- import androidx.compose.ui.Modifier
6
- import androidx.compose.ui.graphics.Color
7
- import androidx.compose.ui.text.style.TextAlign
8
- import androidx.compose.ui.text.style.TextOverflow
9
- import androidx.compose.ui.unit.sp
10
- import androidx.compose.ui.zIndex
11
- import vn.momo.kits.components.Text
12
- import vn.momo.kits.const.KitDesignSystem
13
- import vn.momo.kits.const.Typography
14
- import vn.momo.kits.modifier.setAutomationId
15
-
16
- internal val headerFontFamily: String?
17
- get() = if (KitDesignSystem.isWhiteList) "MoMoTrustDisplay" else null
18
-
19
- @Composable
20
- internal fun HeaderTitle(
21
- title: String = "",
22
- color: Color? = null,
23
- modifier: Modifier = Modifier.fillMaxWidth(),
24
- textAlign: TextAlign = TextAlign.Start,
25
- ) {
26
- Text(
27
- modifier = modifier.zIndex(1f).setAutomationId("title_navigation_header"),
28
- text = title,
29
- textAlign = textAlign,
30
- style = Typography.actionSBold.copy(
31
- fontSize = 15.sp,
32
- lineHeight = 22.sp,
33
- ),
34
- fontFamily = headerFontFamily,
35
- color = color,
36
- maxLines = 1,
37
- overflow = TextOverflow.Ellipsis
38
- )
39
- }