@momo-kits/native-kits 0.162.3-debug → 0.162.3-fontscale.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 (168) hide show
  1. package/.codegraph/.gitignore +5 -0
  2. package/CLAUDE.md +78 -0
  3. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Example.xcscheme +32 -0
  4. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  5. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  6. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/WorkspaceSettings.xcsettings +16 -0
  7. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
  8. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
  9. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
  10. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
  11. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
  12. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
  13. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
  14. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +58 -0
  15. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios.xcscheme +58 -0
  16. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +60 -0
  17. package/ios/Application/Components.swift +1 -0
  18. package/ios/Application/FloatingButton.swift +1 -0
  19. package/ios/Badge/Badge.swift +1 -0
  20. package/ios/Badge/BadgeRibbon.swift +2 -0
  21. package/ios/Button/Button.swift +1 -1
  22. package/ios/Checkbox/Checkbox.swift +1 -0
  23. package/ios/Information/Information.swift +151 -0
  24. package/ios/Input/Input.swift +1 -0
  25. package/ios/Input/InputPhoneNumber.swift +1 -0
  26. package/ios/Input/InputSearch.swift +3 -0
  27. package/ios/Input/InputTextArea.swift +1 -0
  28. package/ios/OTPKeyboard/KeyboardButton.swift +1 -1
  29. package/ios/Popup/PopupDisplay.swift +6 -0
  30. package/ios/Popup/PopupInput.swift +2 -0
  31. package/ios/Template/TrustBanner/TrustBanner.swift +2 -0
  32. package/ios/Typography/Text.swift +1 -0
  33. package/ios/Typography/Typography.swift +14 -5
  34. package/package.json +1 -1
  35. package/build.gradle.kts +0 -11
  36. package/compose/build.gradle.kts +0 -186
  37. package/compose/build.gradle.kts.backup +0 -186
  38. package/compose/compose.podspec +0 -47
  39. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  40. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -123
  41. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  42. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  43. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  44. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  45. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  46. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  47. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  48. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  49. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  50. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  51. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  52. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  53. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  54. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -109
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -305
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -921
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -121
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -403
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -87
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -340
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -198
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -123
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -94
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -136
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -224
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -148
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -116
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -452
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -172
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -255
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -233
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -241
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -92
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -352
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -103
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -338
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -70
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -96
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -348
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -256
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -494
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -131
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -215
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -96
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -531
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -92
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -135
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -214
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -590
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -177
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -192
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -205
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -239
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -285
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -57
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  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 -14
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -50
  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 -253
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -133
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -104
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -145
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -345
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -556
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -161
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -243
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -187
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -315
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  150. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -34
  151. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -370
  152. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -131
  153. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -167
  154. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -72
  155. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -66
  156. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  157. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -70
  158. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  159. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  160. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -33
  161. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -186
  162. package/gradle/libs.versions.toml +0 -67
  163. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  164. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  165. package/gradle.properties +0 -26
  166. package/gradlew +0 -252
  167. package/gradlew.bat +0 -94
  168. package/settings.gradle.kts +0 -64
@@ -1,315 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.animation.core.animateFloatAsState
4
- import androidx.compose.foundation.background
5
- import androidx.compose.foundation.border
6
- import androidx.compose.foundation.layout.Arrangement
7
- import androidx.compose.foundation.layout.Box
8
- import androidx.compose.foundation.layout.Row
9
- import androidx.compose.foundation.layout.Spacer
10
- import androidx.compose.foundation.layout.fillMaxWidth
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.RoundedCornerShape
17
- import androidx.compose.runtime.Composable
18
- import androidx.compose.runtime.getValue
19
- import androidx.compose.ui.Alignment
20
- import androidx.compose.ui.Modifier
21
- import androidx.compose.ui.graphics.Brush
22
- import androidx.compose.ui.graphics.Color
23
- import androidx.compose.ui.layout.onGloballyPositioned
24
- import androidx.compose.ui.platform.LocalDensity
25
- import androidx.compose.ui.text.style.TextAlign
26
- import androidx.compose.ui.unit.Dp
27
- import androidx.compose.ui.unit.dp
28
- import vn.momo.kits.components.Icon
29
- import vn.momo.kits.components.InputSearchProps
30
- import vn.momo.kits.const.AppStatusBar
31
- import vn.momo.kits.const.AppTheme
32
- import vn.momo.kits.const.Colors
33
- import vn.momo.kits.components.PopupNotifyProps
34
- import vn.momo.kits.application.IsShowBaseLineDebug
35
- import vn.momo.kits.const.Spacing
36
- import vn.momo.kits.modifier.activeOpacityClickable
37
- import vn.momo.kits.modifier.conditional
38
- import vn.momo.kits.modifier.setAutomationId
39
- import vn.momo.kits.navigation.LocalHeaderRightWidthPx
40
- import vn.momo.kits.navigation.LocalNavigator
41
- import vn.momo.kits.navigation.LocalOptions
42
- import vn.momo.kits.navigation.LocalScrollState
43
- import vn.momo.kits.navigation.getInputSearchType
44
-
45
- const val HEADER_HEIGHT = 52
46
- enum class InputSearchType { None, Header, Animated }
47
- enum class TitlePosition { LEFT, CENTER }
48
-
49
- @Composable
50
- fun Header(onBackHandler: (() -> Unit)? = null) {
51
- val options = LocalOptions.current
52
- val navigator = LocalNavigator.current
53
- val scrollState = LocalScrollState.current
54
- val headerRightWidthPx = LocalHeaderRightWidthPx.current
55
- val inputSearchType = getInputSearchType(options)
56
-
57
- val opacityHeight = when (val header = options.headerType) {
58
- is HeaderType.Animated -> with(LocalDensity.current) { header.layoutOffSet.roundToPx() }
59
- else -> HEADER_HEIGHT
60
- }
61
- val opacity by animateFloatAsState(
62
- targetValue = if (options.headerType is HeaderType.Transparent) {
63
- 0f
64
- } else {
65
- (scrollState.value / opacityHeight.toFloat())
66
- .coerceIn(0f, 1f)
67
- }
68
- )
69
-
70
- val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
71
-
72
- val animatedAlpha by animateFloatAsState(targetValue = opacity, label = "BackgroundAlpha")
73
-
74
- val background = if (options.headerType is HeaderType.Transparent)
75
- options.backgroundColor ?: AppTheme.current.colors.background.surface
76
- else
77
- AppTheme.current.colors.background.surface
78
-
79
- if (options.headerType == HeaderType.None) return
80
-
81
- val titlePosition = options.titlePosition
82
- val titleColor = headerColor.tintIconColor
83
- .copy(alpha = if (inputSearchType == InputSearchType.Animated) 1f - animatedAlpha else 1f)
84
- // Centered title needs a full-width overlay to stay screen-centered, not boxed between back button and header right.
85
- val centerTitle = titlePosition == TitlePosition.CENTER && options.headerTitle is HeaderTitle.Default
86
-
87
- Box(
88
- Modifier.height(AppStatusBar.current + HEADER_HEIGHT.dp)
89
- .fillMaxWidth()
90
- .background(background.copy(alpha = animatedAlpha))
91
- .conditional(IsShowBaseLineDebug) {
92
- border(1.dp, Colors.blue_03)
93
- },
94
- contentAlignment = Alignment.BottomCenter
95
- ) {
96
- Row(
97
- modifier = Modifier.height(HEADER_HEIGHT.dp)
98
- .fillMaxWidth()
99
- .padding(horizontal = Spacing.M),
100
- verticalAlignment = Alignment.CenterVertically,
101
- horizontalArrangement = Arrangement.SpaceBetween
102
- ) {
103
- if(!options.hiddenBack) {
104
- BackButton(
105
- borderColor = headerColor.borderColor,
106
- backgroundButton = headerColor.backgroundButton,
107
- tintIconColor = headerColor.tintIconColor,
108
- onBackHandler = {
109
- onBackHandler?.invoke() ?: navigator.onBackSafe { }
110
- }
111
- )
112
- Spacer(Modifier.width(Spacing.S))
113
- }
114
-
115
- if (centerTitle) {
116
- Spacer(Modifier.weight(1f))
117
- } else {
118
- HeaderContent(
119
- headerTitle = options.headerTitle,
120
- tintIconColor = titleColor,
121
- titlePosition = titlePosition,
122
- modifier = Modifier.weight(1f)
123
- )
124
- }
125
- Box(Modifier.onGloballyPositioned {
126
- if(headerRightWidthPx.intValue != it.size.width) headerRightWidthPx.intValue = it.size.width
127
- }){
128
- HeaderRight(options.headerRight, options.tintColor, headerColor)
129
- }
130
- }
131
- if (centerTitle) {
132
- Box(
133
- modifier = Modifier.height(HEADER_HEIGHT.dp)
134
- .fillMaxWidth()
135
- .padding(horizontal = Spacing.M),
136
- contentAlignment = Alignment.Center
137
- ) {
138
- HeaderContent(
139
- headerTitle = options.headerTitle,
140
- tintIconColor = titleColor,
141
- titlePosition = titlePosition,
142
- modifier = Modifier.fillMaxWidth()
143
- )
144
- }
145
- }
146
- VerticalShadow(opacity)
147
- }
148
- }
149
-
150
- @Composable
151
- private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
152
- Box(
153
- modifier = Modifier
154
- .size(28.dp)
155
- .background(backgroundButton, RoundedCornerShape(100))
156
- .border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
157
- .activeOpacityClickable(onClick = onBackHandler)
158
- .padding(Spacing.XS)
159
- .setAutomationId("btn_navigation_back"),
160
- contentAlignment = Alignment.Center
161
- ) {
162
- Icon(
163
- source = "arrow-back",
164
- color = tintIconColor,
165
- size = 20.dp,
166
- )
167
- }
168
- }
169
-
170
- @Composable
171
- fun HeaderContent(
172
- headerTitle: HeaderTitle,
173
- tintIconColor: Color,
174
- titlePosition: TitlePosition = TitlePosition.LEFT,
175
- modifier: Modifier = Modifier,
176
- ){
177
- Box(
178
- modifier = modifier,
179
- contentAlignment = if (titlePosition == TitlePosition.CENTER) Alignment.Center else Alignment.CenterStart
180
- ) {
181
- when (headerTitle){
182
- is HeaderTitle.Default -> {
183
- HeaderTitle(
184
- title = headerTitle.title,
185
- color = tintIconColor,
186
- modifier = Modifier.fillMaxWidth(fraction = if (titlePosition == TitlePosition.CENTER) 0.5f else 1f),
187
- textAlign = if (titlePosition == TitlePosition.CENTER) TextAlign.Center else TextAlign.Start
188
- )
189
- }
190
- is HeaderTitle.Journey -> {}
191
- is HeaderTitle.Location -> {}
192
- is HeaderTitle.User -> {
193
- HeaderUser(
194
- data = headerTitle
195
- )
196
- }
197
- }
198
- }
199
- }
200
-
201
- @Composable
202
- fun VerticalShadow(opacity: Float){
203
- if(opacity == 1f){
204
- Box(modifier = Modifier
205
- .fillMaxWidth()
206
- .height(6.dp)
207
- .offset(x = 0.dp, y = 6.dp)
208
- .background(
209
- brush = Brush.verticalGradient(
210
- colors = listOf(Color.Black.copy(alpha = 0.05f), Color.Transparent)
211
- )
212
- )
213
- )
214
- }
215
- }
216
-
217
- sealed class HeaderTitle {
218
- class Default(val title: String) : HeaderTitle()
219
-
220
- class User(
221
- val title: String,
222
- val subTitle: String? = null,
223
- val image: List<String>? = null,
224
- val dotColor: Color? = null,
225
- val tintColor: Color? = null,
226
- val onPress: (() -> Unit)? = null,
227
- val icons: List<String> = emptyList(),
228
- val isLoading: Boolean = false
229
- ) : HeaderTitle()
230
-
231
- class Location(
232
- val description: String? = null,
233
- val location: String,
234
- val tintColor: String? = null,
235
- val onPress: (() -> Unit)? = null,
236
- val isLoading: Boolean = false
237
- ) : HeaderTitle()
238
-
239
- class Journey(
240
- val start: String,
241
- val end: String? = null,
242
- val description: String? = null,
243
- val icon: String,
244
- val iconColor: String? = null,
245
- val tintColor: String? = null,
246
- val onPress: (() -> Unit)? = null,
247
- val isLoading: Boolean = false
248
- ) : HeaderTitle()
249
- }
250
-
251
- sealed class HeaderType {
252
- interface DefaultOrExtended {
253
- val useAnimated: Boolean
254
- val inputSearchProps: InputSearchProps?
255
- }
256
-
257
- data class Default(
258
- override val useAnimated: Boolean = false,
259
- override val inputSearchProps: InputSearchProps? = null
260
- ) : HeaderType(), DefaultOrExtended
261
-
262
- data class Extended(
263
- override val useAnimated: Boolean = false,
264
- override val inputSearchProps: InputSearchProps? = null
265
- ) : HeaderType(), DefaultOrExtended
266
-
267
- data object None : HeaderType()
268
-
269
- data class Animated(
270
- val aspectRatio: AnimatedHeaderRatio = AnimatedHeaderRatio.RATIO_16_9,
271
- val isSurface: Boolean = true,
272
- val layoutOffSet: Dp = 56.dp,
273
- val composable: @Composable (scrollState: Int) -> Unit = {}
274
- ) : HeaderType()
275
-
276
- data class Transparent(
277
- val isFullScreenContent: Boolean = false
278
- ) : HeaderType()
279
- }
280
-
281
- data class HeaderBackProps(
282
- val preventBack: PopupNotifyProps? = null,
283
- )
284
-
285
- data class HeaderColor(val tintIconColor: Color, val backgroundButton: Color, val borderColor: Color)
286
- fun getHeaderColor(headerType: HeaderType, opacity: Float, tintColor: Color?, defaultColor: Color): HeaderColor{
287
- return if(headerType is HeaderType.Animated) {
288
- if (opacity == 1f || !headerType.isSurface)
289
- HeaderColor(
290
- tintIconColor = Colors.black_17,
291
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
292
- borderColor = Colors.black_20.copy(alpha = 0.2f)
293
- )
294
- else
295
- HeaderColor(
296
- tintIconColor = Colors.black_01,
297
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
298
- borderColor = Color.Transparent
299
- )
300
- }
301
- else {
302
- if (tintColor == Colors.black_01)
303
- HeaderColor(
304
- tintIconColor = tintColor,
305
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
306
- borderColor = Colors.black_01.copy(alpha = 0.2f)
307
- )
308
- else
309
- HeaderColor(
310
- tintIconColor = tintColor ?: defaultColor,
311
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
312
- borderColor = Colors.black_20.copy(alpha = 0.2f)
313
- )
314
- }
315
- }
@@ -1,80 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.animation.core.animateFloatAsState
4
- import androidx.compose.foundation.background
5
- import androidx.compose.foundation.layout.Box
6
- import androidx.compose.foundation.layout.fillMaxSize
7
- import androidx.compose.foundation.layout.fillMaxWidth
8
- import androidx.compose.foundation.layout.height
9
- import androidx.compose.runtime.Composable
10
- import androidx.compose.runtime.getValue
11
- import androidx.compose.ui.Modifier
12
- import androidx.compose.ui.geometry.Offset
13
- import androidx.compose.ui.graphics.Brush
14
- import androidx.compose.ui.graphics.Color
15
- import androidx.compose.ui.platform.LocalDensity
16
- import androidx.compose.ui.unit.dp
17
- import vn.momo.kits.components.Image
18
- import vn.momo.kits.const.AppStatusBar
19
- import vn.momo.kits.const.AppTheme
20
- import vn.momo.kits.modifier.conditional
21
- import vn.momo.kits.navigation.LocalOptions
22
- import vn.momo.kits.navigation.LocalScrollState
23
-
24
- enum class AnimatedHeaderRatio(val value: Float){
25
- RATIO_16_9(16f / 9f),
26
- RATIO_1_1(1f),
27
- RATIO_3_2(3f / 2f)
28
- }
29
-
30
- @Composable
31
- fun HeaderBackground() {
32
- val density = LocalDensity.current
33
- val theme = AppTheme.current
34
- val options = LocalOptions.current
35
- val scrollState = LocalScrollState.current
36
- val backgroundColor = options.backgroundColor ?: AppTheme.current.colors.background.default
37
-
38
- val minHeight = AppStatusBar.current + HEADER_HEIGHT.dp
39
- val maxHeight = 154.dp
40
- val opacity by animateFloatAsState(
41
- targetValue = (1 - (scrollState.value * 1f / HEADER_HEIGHT * 1f)).coerceIn(0f, 1f),
42
- )
43
-
44
- val color = if (opacity == 0f) backgroundColor else Color(0xFFFDCADE)
45
- val height = when (options.headerType) {
46
- is HeaderType.Default -> minHeight
47
- is HeaderType.Extended -> {
48
- if (AppTheme.current.isHeaderImage()){
49
- if (opacity == 0f) minHeight else maxHeight
50
- } else {
51
- maxHeight
52
- }
53
- }
54
- else -> 0.dp
55
- }
56
-
57
- Box(Modifier.fillMaxWidth().height(height).background(backgroundColor)) {
58
- Box(Modifier
59
- .height(maxHeight)
60
- .fillMaxWidth()
61
- .conditional(!theme.isHeaderImage()) {
62
- background(Brush.linearGradient(
63
- colors = listOf(
64
- color,
65
- backgroundColor
66
- ),
67
- start = Offset(0f, 0f),
68
- end = Offset(0f, with(density) { maxHeight.toPx() })
69
- )
70
- )
71
- }
72
- ){
73
- if (!theme.isHeaderImage()) return@Box
74
- Image(
75
- source = theme.assets.headerBackground!!,
76
- modifier = Modifier.fillMaxSize(),
77
- )
78
- }
79
- }
80
- }
@@ -1,306 +0,0 @@
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.Row
8
- import androidx.compose.foundation.layout.height
9
- import androidx.compose.foundation.layout.offset
10
- import androidx.compose.foundation.layout.padding
11
- import androidx.compose.foundation.layout.size
12
- import androidx.compose.foundation.layout.width
13
- import androidx.compose.foundation.shape.CircleShape
14
- import androidx.compose.foundation.shape.RoundedCornerShape
15
- import androidx.compose.runtime.Composable
16
- import androidx.compose.runtime.LaunchedEffect
17
- import androidx.compose.runtime.derivedStateOf
18
- import androidx.compose.runtime.getValue
19
- import androidx.compose.runtime.mutableStateOf
20
- import androidx.compose.runtime.remember
21
- import androidx.compose.runtime.setValue
22
- import androidx.compose.ui.Alignment
23
- import androidx.compose.ui.Modifier
24
- import androidx.compose.ui.draw.clip
25
- import androidx.compose.ui.graphics.Color
26
- import androidx.compose.ui.unit.dp
27
- import vn.momo.kits.application.ApplicationContext
28
- import vn.momo.kits.application.MiniAppContext
29
- import vn.momo.kits.components.BadgeDot
30
- import vn.momo.kits.components.DotSize
31
- import vn.momo.kits.components.Icon
32
- import vn.momo.kits.const.Colors
33
- import vn.momo.kits.const.Spacing
34
- import vn.momo.kits.modifier.activeOpacityClickable
35
- import vn.momo.kits.navigation.LocalMaxApi
36
-
37
- @Composable
38
- fun HeaderRight(
39
- headerRight: HeaderRight,
40
- tintColor: Color? = null,
41
- headerColor: HeaderColor
42
- ) {
43
- when (headerRight) {
44
- is HeaderRight.None -> {}
45
- is HeaderRight.Custom -> {
46
- headerRight.content()
47
- }
48
- is HeaderRight.OnBoarding -> {}
49
- is HeaderRight.Toolkit -> {
50
- Toolkit(
51
- headerRight = headerRight,
52
- tintColor = tintColor,
53
- headerColor = headerColor
54
- )
55
- }
56
- }
57
- }
58
-
59
- @Composable
60
- fun Toolkit(
61
- headerRight: HeaderRight.Toolkit,
62
- tintColor: Color? = null,
63
- headerColor: HeaderColor
64
- ) {
65
- val api = LocalMaxApi.current
66
- val context = ApplicationContext.current
67
-
68
- var isFavorite by remember { mutableStateOf(false) }
69
- val isLoading by remember { mutableStateOf(false) }
70
-
71
- LaunchedEffect(context?.appCode) {
72
- api?.isFavoriteApp(mapOf("code" to context?.appCode)) { callback ->
73
- val response = callback?.get("response") as? Boolean
74
- isFavorite = response == true
75
- }
76
- }
77
-
78
- fun onPressShortcut() {
79
- api?.onToolAction(mapOf("item" to mapOf("key" to "onFavorite"), "context" to MiniAppContext.toMap(context))) { callback ->
80
- val response = callback?.get("response") as? Map<*, *>?
81
- val success = response?.get("success") as? Boolean
82
- if (success == true){
83
- isFavorite = !isFavorite
84
- }
85
- }
86
- }
87
-
88
- fun onPressMore() {
89
- api?.showTools(
90
- mapOf(
91
- "useSystemTools" to headerRight.useSystemTools,
92
- "tools" to headerRight.tools.map { it.toMap() },
93
- "context" to MiniAppContext.toMap(context)
94
- )
95
- ) { callback ->
96
- val response = callback?.get("response") as? String
97
- if (response != null) {
98
- headerRight.toolCallback?.invoke(response)
99
- }
100
- }
101
- }
102
-
103
- val navButtonConfig = getNavigationButtonConfig(
104
- headerRight,
105
- ::onPressShortcut,
106
- ::onPressMore
107
- )
108
-
109
- val showBadge = headerRight.tools.any { group ->
110
- group.items.any { it.showBadge }
111
- }
112
-
113
- val isShowShortcut by remember(headerRight.useShortcut, headerRight.useMore, context) {
114
- derivedStateOf {
115
- (headerRight.useShortcut == true) &&
116
- !(headerRight.useMore == true && context == null)
117
- }
118
- }
119
-
120
- val icon by remember(navButtonConfig.icon, isFavorite) {
121
- derivedStateOf {
122
- navButtonConfig.icon.takeUnless { it == "star" }
123
- ?: if (isFavorite) "pin_star_checked" else "pin_star"
124
- }
125
- }
126
-
127
- Row(
128
- verticalAlignment = Alignment.CenterVertically
129
- ) {
130
- if (isShowShortcut) {
131
- NavigationButton(
132
- disabled = isLoading,
133
- icon = icon,
134
- showBadge = showBadge,
135
- onClick = navButtonConfig.onPress,
136
- headerColor = headerColor
137
- )
138
- }
139
-
140
- Row(
141
- verticalAlignment = Alignment.CenterVertically,
142
- horizontalArrangement = Arrangement.Center,
143
- modifier = Modifier
144
- .padding(start = Spacing.S)
145
- .border(0.2.dp, headerColor.borderColor, shape = RoundedCornerShape(14.dp))
146
- .height(28.dp)
147
- .clip(shape = RoundedCornerShape(14.dp))
148
- .background(headerColor.backgroundButton)
149
- ) {
150
- if (context != null) {
151
- Icon(
152
- source = "help_center",
153
- size = 20.dp,
154
- color = headerColor.tintIconColor,
155
- modifier = Modifier.padding(4.dp).activeOpacityClickable {
156
- api?.showHelpCenter(
157
- mapOf(
158
- "appId" to context.appId,
159
- "code" to context.appCode,
160
- "name" to context.appName,
161
- "icon" to context.appIcon,
162
- "description" to context.description
163
- )
164
- ) {}
165
- }
166
- )
167
- Box(
168
- modifier = Modifier
169
- .width(0.5.dp)
170
- .height(12.dp)
171
- .background(tintColor ?: Colors.black_20)
172
- )
173
- }
174
- Icon(
175
- source = "16_basic_home",
176
- size = 20.dp,
177
- color = headerColor.tintIconColor,
178
- modifier = Modifier.padding(4.dp).activeOpacityClickable {
179
- api?.dismissAll { }
180
- }
181
- )
182
- }
183
- }
184
- }
185
-
186
-
187
-
188
- @Composable
189
- fun NavigationButton(
190
- disabled: Boolean,
191
- icon: String,
192
- showBadge: Boolean? = false,
193
- onClick: () -> Unit,
194
- headerColor: HeaderColor
195
- ) {
196
- Box(
197
- modifier = Modifier
198
- .size(28.dp)
199
- .activeOpacityClickable(enabled = !disabled, onClick = onClick)
200
- ) {
201
- Box(
202
- modifier = Modifier
203
- .matchParentSize()
204
- .clip(CircleShape)
205
- .background(headerColor.backgroundButton)
206
- .border(0.2.dp, headerColor.borderColor, CircleShape)
207
- )
208
- Box(
209
- modifier = Modifier.matchParentSize(),
210
- contentAlignment = Alignment.Center
211
- ) {
212
- Icon(
213
- source = icon,
214
- size = 20.dp,
215
- color = headerColor.tintIconColor
216
- )
217
- }
218
-
219
- if (showBadge == true) {
220
- BadgeDot(
221
- size = DotSize.Small,
222
- modifier = Modifier
223
- .align(Alignment.TopEnd)
224
- .offset(x = -Spacing.XXS, y = -Spacing.XXS)
225
- )
226
- }
227
- }
228
- }
229
-
230
- private fun getNavigationButtonConfig(
231
- headerRight: HeaderRight.Toolkit,
232
- onPressShortcut: () -> Unit,
233
- onPressMore: () -> Unit
234
- ): NavigationButtonConfig {
235
- val totalTools = headerRight.tools.sumOf { it.items.size }
236
- val config = NavigationButtonConfig(icon = "star", onPress = onPressShortcut)
237
- return if (totalTools > 1 || headerRight.useMore == true) {
238
- NavigationButtonConfig(
239
- icon = "navigation_more_icon",
240
- onPress = onPressMore
241
- )
242
- } else if (totalTools == 1 && headerRight.tools.isNotEmpty()) {
243
- val singleTool = headerRight.tools.first().items.firstOrNull()
244
- return if (singleTool != null){
245
- NavigationButtonConfig(
246
- icon = singleTool.icon,
247
- onPress = {
248
- headerRight.toolCallback?.invoke(singleTool.key)
249
- }
250
- )
251
- } else {
252
- config
253
- }
254
- } else {
255
- config
256
- }
257
- }
258
-
259
- sealed interface HeaderRight {
260
- data object None : HeaderRight
261
- data class Custom(
262
- val content: @Composable () -> Unit
263
- ) : HeaderRight
264
- data object OnBoarding : HeaderRight
265
- data class Toolkit(
266
- val useShortcut: Boolean = false,
267
- val useMore: Boolean = false,
268
- val useSystemTools: Boolean = true,
269
- val tools: List<ToolGroup> = emptyList(),
270
- val toolCallback: ((String) -> Unit)? = { _ -> }
271
- ) : HeaderRight
272
- }
273
-
274
- data class ToolGroup(
275
- val title: Map<String, String> = emptyMap(),
276
- val items: List<Tool>
277
- ) {
278
- fun toMap(): Map<String, Any> {
279
- return mapOf(
280
- "title" to title,
281
- "items" to items.map { it.toMap() }
282
- )
283
- }
284
- }
285
- data class Tool(
286
- val key: String,
287
- val icon: String,
288
- val showBadge: Boolean = false,
289
- val name: Map<String, String> = emptyMap(),
290
- val showRightIcon: Boolean = true,
291
- ) {
292
- fun toMap(): Map<String, Any> {
293
- return mapOf(
294
- "key" to key,
295
- "icon" to icon,
296
- "showBadge" to showBadge,
297
- "name" to name,
298
- "showRightIcon" to showRightIcon
299
- )
300
- }
301
- }
302
-
303
- data class NavigationButtonConfig(
304
- val icon: String,
305
- val onPress: () -> Unit
306
- )