@momo-kits/native-kits 0.169.10-beta.1-debug → 0.169.10

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