@momo-kits/native-kits 0.169.4-debug → 0.169.5-beta.1

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 (148) hide show
  1. package/CLAUDE.md +1 -1
  2. package/PUBLISH_GUIDE.md +3 -10
  3. package/ios/Navigation/BottomTab/BottomTabBar.swift +21 -6
  4. package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -0
  5. package/ios/Typography/FontScale.swift +28 -5
  6. package/ios/native-kits.podspec +1 -1
  7. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  8. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +21 -9
  9. package/package.json +1 -4
  10. package/publish.sh +10 -36
  11. package/build.gradle.kts +0 -11
  12. package/compose/build.gradle.kts +0 -198
  13. package/compose/compose.podspec +0 -47
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  17. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  20. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -195
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -393
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -113
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -739
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -239
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -389
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -94
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -203
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -104
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -92
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -22
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -219
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -144
  141. package/gradle/libs.versions.toml +0 -69
  142. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  143. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  144. package/gradle.properties +0 -24
  145. package/gradlew +0 -252
  146. package/gradlew.bat +0 -94
  147. package/ios-demo/README.md +0 -120
  148. 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,399 +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
- // Colors follow the enclosing header, so it fits a `HeaderRight.Custom` next to the toolkit.
260
- @Composable
261
- fun NavigationButton(
262
- icon: String,
263
- onClick: () -> Unit,
264
- showBadge: Boolean = false,
265
- disabled: Boolean = false,
266
- modifier: Modifier = Modifier,
267
- ) {
268
- NavigationButton(
269
- disabled = disabled,
270
- icon = icon,
271
- showBadge = showBadge,
272
- onClick = onClick,
273
- headerColor = LocalHeaderColor.current ?: getHeaderColor(HeaderType.Default(), 1f, null, Colors.black_17),
274
- modifier = modifier,
275
- )
276
- }
277
-
278
- @Composable
279
- internal fun NavigationButton(
280
- disabled: Boolean,
281
- icon: String,
282
- showBadge: Boolean? = false,
283
- onClick: () -> Unit,
284
- headerColor: HeaderColor,
285
- modifier: Modifier = Modifier,
286
- ) {
287
- Box(
288
- modifier = modifier
289
- .size(28.dp)
290
- .activeOpacityClickable(enabled = !disabled, onClick = onClick)
291
- ) {
292
- Box(
293
- modifier = Modifier
294
- .matchParentSize()
295
- .clip(CircleShape)
296
- .background(headerColor.backgroundButton)
297
- .border(0.2.dp, headerColor.borderColor, CircleShape)
298
- )
299
- Box(
300
- modifier = Modifier.matchParentSize(),
301
- contentAlignment = Alignment.Center
302
- ) {
303
- Icon(
304
- source = icon,
305
- size = 20.dp,
306
- color = headerColor.tintIconColor
307
- )
308
- }
309
-
310
- if (showBadge == true) {
311
- BadgeDot(
312
- size = DotSize.Small,
313
- modifier = Modifier
314
- .align(Alignment.TopEnd)
315
- .offset(x = -Spacing.XXS, y = -Spacing.XXS)
316
- )
317
- }
318
- }
319
- }
320
-
321
- private fun getNavigationButtonConfig(
322
- headerRight: HeaderRight.Toolkit,
323
- onPressShortcut: () -> Unit,
324
- onPressMore: () -> Unit
325
- ): NavigationButtonConfig {
326
- val totalTools = headerRight.tools.sumOf { it.items.size }
327
- val config = NavigationButtonConfig(icon = "star", onPress = onPressShortcut)
328
- return if (totalTools > 1 || headerRight.useMore == true) {
329
- NavigationButtonConfig(
330
- icon = "navigation_more_icon",
331
- onPress = onPressMore
332
- )
333
- } else if (totalTools == 1 && headerRight.tools.isNotEmpty()) {
334
- val singleTool = headerRight.tools.first().items.firstOrNull()
335
- return if (singleTool != null){
336
- NavigationButtonConfig(
337
- icon = singleTool.icon,
338
- onPress = {
339
- headerRight.toolCallback?.invoke(singleTool.key)
340
- }
341
- )
342
- } else {
343
- config
344
- }
345
- } else {
346
- config
347
- }
348
- }
349
-
350
- sealed interface HeaderRight {
351
- data object None : HeaderRight
352
- data class Custom(
353
- val content: @Composable () -> Unit
354
- ) : HeaderRight
355
- data object OnBoarding : HeaderRight
356
- data class Toolkit(
357
- val useShortcut: Boolean = false,
358
- val useMore: Boolean = false,
359
- val useSystemTools: Boolean = true,
360
- val tools: List<ToolGroup> = emptyList(),
361
- val toolCallback: ((String) -> Unit)? = { _ -> },
362
- // Close dismisses only this mini app instead of returning home.
363
- val useCloseIcon: Boolean = false,
364
- ) : HeaderRight
365
- }
366
-
367
- data class ToolGroup(
368
- val title: Map<String, String> = emptyMap(),
369
- val items: List<Tool>
370
- ) {
371
- fun toMap(): Map<String, Any> {
372
- return mapOf(
373
- "title" to title,
374
- "items" to items.map { it.toMap() }
375
- )
376
- }
377
- }
378
- data class Tool(
379
- val key: String,
380
- val icon: String,
381
- val showBadge: Boolean = false,
382
- val name: Map<String, String> = emptyMap(),
383
- val showRightIcon: Boolean = true,
384
- ) {
385
- fun toMap(): Map<String, Any> {
386
- return mapOf(
387
- "key" to key,
388
- "icon" to icon,
389
- "showBadge" to showBadge,
390
- "name" to name,
391
- "showRightIcon" to showRightIcon
392
- )
393
- }
394
- }
395
-
396
- private data class NavigationButtonConfig(
397
- val icon: String,
398
- val onPress: () -> Unit
399
- )
@@ -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.application.DesignSystemKits
12
- import vn.momo.kits.components.Text
13
- import vn.momo.kits.const.Typography
14
- import vn.momo.kits.modifier.setAutomationId
15
-
16
- internal val headerFontFamily: String?
17
- get() = if (DesignSystemKits.getConfigs().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
- }