@momo-kits/native-kits 0.169.15-beta.4-debug → 0.169.15-beta.5

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 (147) hide show
  1. package/ios/Navigation/BottomTab/BottomTab.swift +12 -7
  2. package/ios/Navigation/BottomTab/{LegacyBottomTabBar.swift → Legacy/LegacyBottomTabBar.swift} +54 -85
  3. package/ios/Navigation/BottomTab/Legacy/LegacyCurvedContainer.swift +63 -0
  4. package/ios/native-kits.podspec +1 -1
  5. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  6. package/package.json +1 -1
  7. package/build.gradle.kts +0 -11
  8. package/compose/build.gradle.kts +0 -198
  9. package/compose/compose.podspec +0 -47
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -206
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -421
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -758
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -261
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -406
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -111
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyBottomTabBar.kt +0 -262
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyCurvedContainer.kt +0 -86
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -400
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  140. package/gradle/libs.versions.toml +0 -67
  141. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  142. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  143. package/gradle.properties +0 -24
  144. package/gradlew +0 -252
  145. package/gradlew.bat +0 -94
  146. package/ios-demo/README.md +0 -120
  147. package/settings.gradle.kts +0 -64
@@ -1,167 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.animation.*
4
- import androidx.compose.animation.core.CubicBezierEasing
5
- import androidx.compose.animation.core.LinearEasing
6
- import androidx.compose.animation.core.animateDpAsState
7
- import androidx.compose.animation.core.tween
8
- import androidx.compose.foundation.ScrollState
9
- import androidx.compose.foundation.background
10
- import androidx.compose.foundation.border
11
- import androidx.compose.foundation.interaction.MutableInteractionSource
12
- import androidx.compose.foundation.layout.*
13
- import androidx.compose.material3.AlertDialogDefaults
14
- import androidx.compose.material3.FloatingActionButton
15
- import androidx.compose.material3.FloatingActionButtonDefaults
16
- import androidx.compose.material3.FloatingActionButtonElevation
17
- import androidx.compose.runtime.*
18
- import androidx.compose.runtime.saveable.rememberSaveable
19
- import androidx.compose.ui.Alignment
20
- import androidx.compose.ui.Modifier
21
- import androidx.compose.ui.graphics.Color
22
- import androidx.compose.ui.unit.Dp
23
- import androidx.compose.ui.unit.dp
24
- import kotlinx.coroutines.delay
25
- import kotlinx.coroutines.flow.MutableStateFlow
26
- import kotlinx.coroutines.flow.collectLatest
27
- import kotlinx.coroutines.launch
28
- import vn.momo.kits.application.IsShowBaseLineDebug
29
- import vn.momo.kits.components.Icon
30
- import vn.momo.kits.components.Text
31
- import vn.momo.kits.const.Colors
32
- import vn.momo.kits.const.Typography
33
- import vn.momo.kits.modifier.conditional
34
- import kotlin.time.Duration.Companion.milliseconds
35
-
36
- enum class FABSize { SMALL, DEFAULT }
37
- enum class FABPosition { END, CENTER }
38
-
39
- data class FloatingButtonProps(
40
- val icon: String,
41
- val iconColor: Color? = null,
42
- val label: String? = null,
43
- val onClick: () -> Unit,
44
- val size: FABSize = FABSize.DEFAULT,
45
- val bottom: Dp? = null,
46
- val scrollState: ScrollState? = null,
47
- val position: FABPosition? = FABPosition.END,
48
- )
49
-
50
- private val FabSmallSize = 36.dp
51
- private val FabDefaultSize = 48.dp
52
- private val FabExpandedWidth = 80.dp
53
- private val FabIconSizeSmall = 12.dp
54
- private val FabIconSizeDefault = 24.dp
55
- private val FabPaddingHorizontal = 12.dp
56
-
57
- @Composable
58
- internal fun FloatingButton(
59
- scrollPosition: Int,
60
- bottom: Dp,
61
- onClick: () -> Unit,
62
- containerColor: Color,
63
- contentColor: Color = containerColor,
64
- icon: String,
65
- iconColor: Color? = null,
66
- text: String? = null,
67
- elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(4.dp),
68
- size: FABSize = FABSize.DEFAULT,
69
- position: FABPosition = FABPosition.END,
70
- keyboardSize: Dp = 0.dp,
71
- ) {
72
- val scrollStateFlow = remember { MutableStateFlow(scrollPosition) }
73
- var lastScrollPosition by rememberSaveable { mutableStateOf(0) }
74
- var isExpanded by rememberSaveable { mutableStateOf(false) }
75
-
76
- val coroutineScope = rememberCoroutineScope()
77
-
78
- val baseSize = if (size == FABSize.SMALL) FabSmallSize else FabDefaultSize
79
- val width by animateDpAsState(
80
- targetValue = if (isExpanded && text != null) FabExpandedWidth else baseSize,
81
- animationSpec = tween(100, easing = CubicBezierEasing(0.2f, 0.2f, 0.2f, 0.2f))
82
- )
83
-
84
- LaunchedEffect(text) {
85
- if (text != null) {
86
- coroutineScope.launch {
87
- scrollStateFlow.collectLatest { newScroll ->
88
- isExpanded = newScroll <= lastScrollPosition
89
- delay(100.milliseconds)
90
- lastScrollPosition = newScroll
91
- }
92
- }
93
- }
94
- }
95
-
96
- LaunchedEffect(scrollPosition) {
97
- scrollStateFlow.value = scrollPosition
98
- }
99
-
100
- Box(
101
- modifier = Modifier
102
- .fillMaxSize()
103
- .padding(end = 12.dp, bottom = bottom)
104
- .offset(y = -keyboardSize)
105
- .background(Color.Transparent),
106
- contentAlignment = if (position == FABPosition.END) Alignment.BottomEnd else Alignment.BottomCenter,
107
- ) {
108
- FloatingActionButton(
109
- onClick = onClick,
110
- shape = AlertDialogDefaults.shape,
111
- containerColor = containerColor,
112
- contentColor = contentColor,
113
- elevation = elevation,
114
- interactionSource = remember { MutableInteractionSource() },
115
- modifier = Modifier
116
- .sizeIn(minWidth = width)
117
- .height(baseSize)
118
- .conditional(IsShowBaseLineDebug) {
119
- border(1.dp, Colors.blue_03)
120
- }
121
- ) {
122
- Row(
123
- modifier = Modifier.padding(
124
- start = if (isExpanded) FabPaddingHorizontal else 0.dp,
125
- end = if (isExpanded) FabPaddingHorizontal else 0.dp,
126
- ),
127
- verticalAlignment = Alignment.CenterVertically,
128
- horizontalArrangement = if (isExpanded) Arrangement.Start else Arrangement.Center
129
- ) {
130
- Icon(
131
- source = icon,
132
- size = if (size == FABSize.SMALL) FabIconSizeSmall else FabIconSizeDefault,
133
- color = iconColor ?: Color.White
134
- )
135
-
136
- AnimatedVisibility(
137
- visible = isExpanded,
138
- enter = fadeInExpandAnimation,
139
- exit = fadeOutShrinkAnimation,
140
- ) {
141
- Row {
142
- Spacer(Modifier.width(12.dp))
143
- Text(
144
- text = text ?: "",
145
- color = Color.White,
146
- style = Typography.actionDefaultBold
147
- )
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }
154
-
155
- private val fadeOutShrinkAnimation = fadeOut(
156
- animationSpec = tween(100, easing = LinearEasing)
157
- ) + shrinkHorizontally(
158
- animationSpec = tween(100, easing = LinearEasing),
159
- shrinkTowards = Alignment.Start
160
- )
161
-
162
- private val fadeInExpandAnimation = fadeIn(
163
- animationSpec = tween(100, easing = LinearEasing)
164
- ) + expandHorizontally(
165
- animationSpec = tween(100, easing = LinearEasing),
166
- expandFrom = Alignment.Start
167
- )
@@ -1,446 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import vn.momo.kits.modifier.InternalApi
4
-
5
- import androidx.compose.animation.core.animateFloatAsState
6
- import androidx.compose.foundation.background
7
- import androidx.compose.foundation.border
8
- import androidx.compose.foundation.layout.Arrangement
9
- import androidx.compose.foundation.layout.Box
10
- import androidx.compose.foundation.layout.Row
11
- import androidx.compose.foundation.layout.Spacer
12
- import androidx.compose.foundation.layout.fillMaxWidth
13
- import androidx.compose.foundation.layout.height
14
- import androidx.compose.foundation.layout.offset
15
- import androidx.compose.foundation.layout.padding
16
- import androidx.compose.foundation.layout.size
17
- import androidx.compose.foundation.layout.width
18
- import androidx.compose.foundation.layout.wrapContentHeight
19
- import androidx.compose.foundation.shape.RoundedCornerShape
20
- import androidx.compose.runtime.Composable
21
- import androidx.compose.runtime.CompositionLocalProvider
22
- import androidx.compose.runtime.compositionLocalOf
23
- import androidx.compose.runtime.getValue
24
- import androidx.compose.ui.Alignment
25
- import androidx.compose.ui.Modifier
26
- import androidx.compose.ui.draw.clipToBounds
27
- import androidx.compose.ui.draw.drawBehind
28
- import androidx.compose.ui.geometry.Offset
29
- import androidx.compose.ui.graphics.graphicsLayer
30
- import androidx.compose.ui.graphics.Brush
31
- import androidx.compose.ui.graphics.Color
32
- import androidx.compose.ui.layout.onGloballyPositioned
33
- import androidx.compose.ui.platform.LocalDensity
34
- import androidx.compose.ui.text.style.TextAlign
35
- import androidx.compose.ui.unit.Dp
36
- import androidx.compose.ui.unit.dp
37
- import vn.momo.kits.components.Icon
38
- import vn.momo.kits.components.Image
39
- import vn.momo.kits.components.InputSearchProps
40
- import vn.momo.kits.const.AppTheme
41
- import vn.momo.kits.const.Colors
42
- import vn.momo.kits.components.PopupNotifyProps
43
- import vn.momo.kits.application.IsShowBaseLineDebug
44
- import vn.momo.kits.const.Spacing
45
- import vn.momo.kits.layout.HEADER_BUTTON_SIZE
46
- import vn.momo.kits.layout.HEADER_CLUSTER_WIDTH
47
- import vn.momo.kits.layout.HEADER_ICON_SIZE
48
- import vn.momo.kits.layout.HEADER_TITLE_GAP
49
- import vn.momo.kits.layout.getScreenLayout
50
- import vn.momo.kits.layout.rememberHeaderLayout
51
- import vn.momo.kits.modifier.activeOpacityClickable
52
- import vn.momo.kits.modifier.conditional
53
- import vn.momo.kits.modifier.setAutomationId
54
- import vn.momo.kits.navigation.LocalHeaderRightWidthPx
55
- import vn.momo.kits.navigation.LocalNavigator
56
- import vn.momo.kits.navigation.LocalOptions
57
- import vn.momo.kits.navigation.LocalScrollState
58
- import vn.momo.kits.navigation.getInputSearchType
59
- import vn.momo.kits.navigation.usesDuoGlassHeader
60
- import vn.momo.kits.utils.horizontalSafeAreaPadding
61
-
62
- @InternalApi
63
- const val HEADER_HEIGHT = 52
64
- internal enum class InputSearchType { None, Header, Animated }
65
- enum class TitlePosition { LEFT, CENTER }
66
-
67
- // back, the gaps around the title and the right cluster
68
- private val HEADER_ACTIONS_WIDTH = HEADER_BUTTON_SIZE + HEADER_TITLE_GAP * 2 + HEADER_CLUSTER_WIDTH
69
-
70
- @Suppress("FrequentlyChangingValue")
71
- @Composable
72
- internal fun headerOpacity(): Float {
73
- val options = LocalOptions.current
74
- val scrollState = LocalScrollState.current
75
- val opacityHeight = when (val header = options.headerType) {
76
- is HeaderType.Animated -> with(LocalDensity.current) { header.layoutOffSet.roundToPx() }
77
- else -> HEADER_HEIGHT
78
- }
79
- val opacity by animateFloatAsState(
80
- targetValue = when {
81
- options.headerType is HeaderType.Transparent -> 0f
82
- opacityHeight <= 0 -> if (scrollState.value > 0) 1f else 0f
83
- else -> (scrollState.value / opacityHeight.toFloat()).coerceIn(0f, 1f)
84
- }
85
- )
86
- return opacity
87
- }
88
-
89
- // Back button and toolkit share the bar with the title unless the iPhone Duo side bar holds them.
90
- @Composable
91
- internal fun headerTitleMaxWidth(): Dp {
92
- val layout = getScreenLayout()
93
- val clearance = layout.statusBarClearance
94
- val clearanceWidth = clearance?.let { it.left + it.right } ?: 0.dp
95
- if (layout.sideBar != null) return layout.contentWidth - Spacing.M * 2 - clearanceWidth
96
- return rememberHeaderLayout(LocalOptions.current.contentLayout).frameWidth - HEADER_ACTIONS_WIDTH - clearanceWidth
97
- }
98
-
99
- // Scroll distance over which the Duo glass bar fades in.
100
- private val DUO_GLASS_FADE_DISTANCE = 16.dp
101
-
102
- // RN DuoGlassBackground: translucent surface with a hairline once content scrolls under it.
103
- @Suppress("FrequentlyChangingValue")
104
- @Composable
105
- private fun Modifier.duoGlassBar(): Modifier {
106
- val scrollState = LocalScrollState.current
107
- val fadePx = with(LocalDensity.current) { DUO_GLASS_FADE_DISTANCE.toPx() }
108
- val alpha by animateFloatAsState((scrollState.value / fadePx).coerceIn(0f, 1f), label = "DuoGlassAlpha")
109
- val colors = AppTheme.current.colors
110
- return background(colors.background.surface.copy(alpha = 0.8f * alpha))
111
- .drawBehind {
112
- val stroke = 0.5.dp.toPx()
113
- drawLine(
114
- color = colors.border.default.copy(alpha = alpha),
115
- start = Offset(0f, size.height - stroke / 2),
116
- end = Offset(size.width, size.height - stroke / 2),
117
- strokeWidth = stroke,
118
- )
119
- }
120
- }
121
-
122
- @Composable
123
- internal fun Header(onBackHandler: (() -> Unit)? = null) {
124
- val options = LocalOptions.current
125
- val navigator = LocalNavigator.current
126
- val headerRightWidthPx = LocalHeaderRightWidthPx.current
127
- val inputSearchType = getInputSearchType(options)
128
- val layout = getScreenLayout()
129
- val headerLayout = rememberHeaderLayout(options.contentLayout)
130
- val useSideBar = layout.sideBar != null
131
- // iPhone Duo inner portrait: the row sits on the status bar, between its clusters, with phone-size controls
132
- val clearance = layout.statusBarClearance
133
- val opacity = headerOpacity()
134
-
135
- val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
136
-
137
- val animatedAlpha by animateFloatAsState(targetValue = opacity, label = "BackgroundAlpha")
138
-
139
- val background = if (options.headerType is HeaderType.Transparent)
140
- options.backgroundColor ?: AppTheme.current.colors.background.surface
141
- else
142
- AppTheme.current.colors.background.surface
143
-
144
- if (options.headerType == HeaderType.None) return
145
-
146
- val titlePosition = options.titlePosition
147
- val titleColor = headerColor.tintIconColor
148
- .copy(alpha = if (inputSearchType == InputSearchType.Animated) 1f - animatedAlpha else 1f)
149
- // Centered title needs a full-width overlay to stay screen-centered, not boxed between back button and header right.
150
- val centerTitle = titlePosition == TitlePosition.CENTER && options.headerTitle is HeaderTitle.Default
151
-
152
- val useDuoGlass = options.usesDuoGlassHeader(layout)
153
- val headerImage = AppTheme.current.assets.headerBackground
154
- .takeUnless { options.headerType is HeaderType.Transparent || useDuoGlass }
155
-
156
- Box(
157
- Modifier.height(layout.headerHeight)
158
- .fillMaxWidth()
159
- .then(if (useDuoGlass) Modifier.duoGlassBar() else Modifier)
160
- .conditional(headerImage.isNullOrEmpty() && !useDuoGlass) {
161
- background(background.copy(alpha = animatedAlpha))
162
- }
163
- .conditional(IsShowBaseLineDebug) {
164
- border(1.dp, Colors.blue_03)
165
- },
166
- contentAlignment = Alignment.BottomCenter
167
- ) {
168
- if (!headerImage.isNullOrEmpty()) {
169
- Box(
170
- Modifier
171
- .matchParentSize()
172
- .clipToBounds()
173
- .graphicsLayer { alpha = animatedAlpha }
174
- .background(background)
175
- ) {
176
- Image(
177
- source = headerImage,
178
- loading = false,
179
- modifier = Modifier
180
- .fillMaxWidth()
181
- .wrapContentHeight(Alignment.Top, unbounded = true)
182
- .height(HEADER_BACKGROUND_HEIGHT),
183
- )
184
- }
185
- }
186
- Row(
187
- modifier = Modifier.height(layout.headerBarHeight)
188
- .fillMaxWidth()
189
- .horizontalSafeAreaPadding()
190
- .padding(
191
- start = headerLayout.frameInset + (clearance?.left ?: 0.dp),
192
- end = headerLayout.frameInset + (clearance?.right ?: 0.dp),
193
- ),
194
- verticalAlignment = Alignment.CenterVertically,
195
- horizontalArrangement = Arrangement.SpaceBetween
196
- ) {
197
- if (!options.hiddenBack && !useSideBar) {
198
- BackButton(
199
- borderColor = headerColor.borderColor,
200
- backgroundButton = headerColor.backgroundButton,
201
- tintIconColor = headerColor.tintIconColor,
202
- onBackHandler = {
203
- navigator.onBackSafe { }
204
- }
205
- )
206
- Spacer(Modifier.width(HEADER_TITLE_GAP))
207
- }
208
-
209
- if (centerTitle) {
210
- Spacer(Modifier.weight(1f))
211
- } else {
212
- HeaderContent(
213
- headerTitle = options.headerTitle,
214
- tintIconColor = titleColor,
215
- titlePosition = titlePosition,
216
- modifier = Modifier.weight(1f)
217
- )
218
- }
219
- Box(Modifier.onGloballyPositioned {
220
- if(headerRightWidthPx.intValue != it.size.width) headerRightWidthPx.intValue = it.size.width
221
- }){
222
- val headerRight = options.headerRight
223
- when {
224
- // on Duo the side bar column holds the header right (toolkit or custom), not this row
225
- useSideBar -> Unit
226
- else -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
227
- HeaderRight(headerRight, options.tintColor, headerColor)
228
- }
229
- }
230
- }
231
- }
232
- if (centerTitle) {
233
- // on the status bar row the clusters are lopsided, so both sides keep the wider one's room
234
- val centerInset = if (clearance != null) {
235
- val back = if (options.hiddenBack || useSideBar) 0.dp else HEADER_BUTTON_SIZE + HEADER_TITLE_GAP
236
- val right = with(LocalDensity.current) { headerRightWidthPx.intValue.toDp() }
237
- maxOf(clearance.left + back, clearance.right + right) + Spacing.S
238
- } else {
239
- 0.dp
240
- }
241
- Box(
242
- modifier = Modifier.height(layout.headerBarHeight)
243
- .fillMaxWidth()
244
- .horizontalSafeAreaPadding()
245
- .padding(horizontal = headerLayout.frameInset + centerInset),
246
- contentAlignment = Alignment.Center
247
- ) {
248
- HeaderContent(
249
- headerTitle = options.headerTitle,
250
- tintIconColor = titleColor,
251
- titlePosition = titlePosition,
252
- centerWidthFraction = if (clearance != null) 1f else 0.5f,
253
- modifier = Modifier.fillMaxWidth()
254
- )
255
- }
256
- }
257
- VerticalShadow(opacity)
258
- }
259
- }
260
-
261
- @Composable
262
- private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
263
- Box(
264
- modifier = Modifier
265
- .size(HEADER_BUTTON_SIZE)
266
- .background(backgroundButton, RoundedCornerShape(100))
267
- .border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
268
- .activeOpacityClickable(onClick = onBackHandler)
269
- .padding(Spacing.XS)
270
- .setAutomationId("btn_navigation_back"),
271
- contentAlignment = Alignment.Center
272
- ) {
273
- Icon(
274
- source = "arrow-back",
275
- color = tintIconColor,
276
- size = HEADER_ICON_SIZE,
277
- )
278
- }
279
- }
280
-
281
- @Composable
282
- internal fun HeaderContent(
283
- headerTitle: HeaderTitle,
284
- tintIconColor: Color,
285
- titlePosition: TitlePosition = TitlePosition.LEFT,
286
- centerWidthFraction: Float = 0.5f,
287
- modifier: Modifier = Modifier,
288
- ){
289
- Box(
290
- modifier = modifier,
291
- contentAlignment = if (titlePosition == TitlePosition.CENTER) Alignment.Center else Alignment.CenterStart
292
- ) {
293
- when (headerTitle){
294
- is HeaderTitle.Default -> {
295
- HeaderTitle(
296
- title = headerTitle.title,
297
- color = tintIconColor,
298
- modifier = Modifier.fillMaxWidth(fraction = if (titlePosition == TitlePosition.CENTER) centerWidthFraction else 1f),
299
- textAlign = if (titlePosition == TitlePosition.CENTER) TextAlign.Center else TextAlign.Start
300
- )
301
- }
302
- is HeaderTitle.Journey -> {
303
- HeaderJourney(
304
- data = headerTitle,
305
- tintIconColor = tintIconColor
306
- )
307
- }
308
- is HeaderTitle.Location -> {
309
- HeaderLocation(
310
- data = headerTitle,
311
- tintIconColor = tintIconColor
312
- )
313
- }
314
- is HeaderTitle.User -> {
315
- HeaderUser(
316
- data = headerTitle
317
- )
318
- }
319
- }
320
- }
321
- }
322
-
323
- @Composable
324
- internal fun VerticalShadow(opacity: Float){
325
- if(opacity == 1f){
326
- Box(modifier = Modifier
327
- .fillMaxWidth()
328
- .height(6.dp)
329
- .offset(x = 0.dp, y = 6.dp)
330
- .background(
331
- brush = Brush.verticalGradient(
332
- colors = listOf(Color.Black.copy(alpha = 0.05f), Color.Transparent)
333
- )
334
- )
335
- )
336
- }
337
- }
338
-
339
- sealed class HeaderTitle {
340
- class Default(val title: String) : HeaderTitle()
341
-
342
- class User(
343
- val title: String,
344
- val subTitle: String? = null,
345
- val image: List<String>? = null,
346
- val dotColor: Color? = null,
347
- val tintColor: Color? = null,
348
- val onPress: (() -> Unit)? = null,
349
- val icons: List<String> = emptyList(),
350
- val isLoading: Boolean = false
351
- ) : HeaderTitle()
352
-
353
- class Location(
354
- val description: String? = null,
355
- val location: String,
356
- val tintColor: String? = null,
357
- val onPress: (() -> Unit)? = null,
358
- val isLoading: Boolean = false
359
- ) : HeaderTitle()
360
-
361
- class Journey(
362
- val start: String,
363
- val end: String? = null,
364
- val description: String? = null,
365
- val icon: String,
366
- val iconColor: String? = null,
367
- val tintColor: String? = null,
368
- val onPress: (() -> Unit)? = null,
369
- val isLoading: Boolean = false
370
- ) : HeaderTitle()
371
- }
372
-
373
- sealed class HeaderType {
374
- interface DefaultOrExtended {
375
- val useAnimated: Boolean
376
- val inputSearchProps: InputSearchProps?
377
- }
378
-
379
- data class Default(
380
- override val useAnimated: Boolean = false,
381
- override val inputSearchProps: InputSearchProps? = null
382
- ) : HeaderType(), DefaultOrExtended
383
-
384
- data class Extended(
385
- override val useAnimated: Boolean = false,
386
- override val inputSearchProps: InputSearchProps? = null
387
- ) : HeaderType(), DefaultOrExtended
388
-
389
- data object None : HeaderType()
390
-
391
- data class Animated(
392
- val aspectRatio: AnimatedHeaderRatio = AnimatedHeaderRatio.RATIO_16_9,
393
- val isSurface: Boolean = true,
394
- val layoutOffSet: Dp = 56.dp,
395
- val height: Dp? = null,
396
- // Wide windows: fills the sides of the phone-sized banner, fading out downward.
397
- val bannerBackgroundColor: Color? = null,
398
- // Last so callers can keep passing it as a trailing lambda.
399
- val composable: @Composable (scrollState: Int) -> Unit = {},
400
- ) : HeaderType()
401
-
402
- data class Transparent(
403
- val isFullScreenContent: Boolean = false
404
- ) : HeaderType()
405
- }
406
-
407
- data class HeaderBackProps(
408
- val preventBack: PopupNotifyProps? = null,
409
- )
410
-
411
- @InternalApi
412
- data class HeaderColor(val tintIconColor: Color, val backgroundButton: Color, val borderColor: Color)
413
-
414
- // The enclosing header's colors, so a custom header right follows the bar (SwiftUI `\.headerColor`).
415
- internal val LocalHeaderColor = compositionLocalOf<HeaderColor?> { null }
416
-
417
- internal fun getHeaderColor(headerType: HeaderType, opacity: Float, tintColor: Color?, defaultColor: Color): HeaderColor{
418
- return if(headerType is HeaderType.Animated) {
419
- if (opacity == 1f || !headerType.isSurface)
420
- HeaderColor(
421
- tintIconColor = Colors.black_17,
422
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
423
- borderColor = Colors.black_20.copy(alpha = 0.2f)
424
- )
425
- else
426
- HeaderColor(
427
- tintIconColor = Colors.black_01,
428
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
429
- borderColor = Color.Transparent
430
- )
431
- }
432
- else {
433
- if (tintColor == Colors.black_01)
434
- HeaderColor(
435
- tintIconColor = tintColor,
436
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
437
- borderColor = Colors.black_01.copy(alpha = 0.2f)
438
- )
439
- else
440
- HeaderColor(
441
- tintIconColor = tintColor ?: defaultColor,
442
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
443
- borderColor = Colors.black_20.copy(alpha = 0.2f)
444
- )
445
- }
446
- }