@momo-kits/native-kits 0.169.8-beta.7-debug → 0.169.8-debug
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.
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +5 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +14 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +1 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +39 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +29 -28
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +10 -3
- package/gradle.properties +1 -1
- package/ios/Input/InputSearch.swift +6 -23
- package/ios/Navigation/BottomTab/BottomTabBar.swift +0 -9
- package/ios/Navigation/Component/Header.swift +46 -31
- package/ios/Navigation/Component/HeaderJourney.swift +1 -2
- package/ios/Navigation/Component/HeaderLocation.swift +1 -2
- package/ios/Navigation/Component/HeaderRight.swift +15 -18
- package/ios/Navigation/Component/HeaderUser.swift +1 -2
- package/ios/Navigation/Component/SideBar.swift +13 -4
- package/ios/Navigation/Navigation.swift +1 -31
- package/ios/Navigation/StackScreen.swift +14 -43
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +1 -13
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -63
- package/ios/Layout/HeaderLayout.swift +0 -60
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -9,20 +9,13 @@ import androidx.compose.runtime.Composable
|
|
|
9
9
|
import androidx.compose.runtime.remember
|
|
10
10
|
import androidx.compose.ui.Modifier
|
|
11
11
|
import androidx.compose.ui.draw.clip
|
|
12
|
-
import androidx.compose.ui.text.AnnotatedString
|
|
13
|
-
import androidx.compose.ui.text.SpanStyle
|
|
14
|
-
import androidx.compose.ui.text.buildAnnotatedString
|
|
15
|
-
import androidx.compose.ui.text.font.FontSynthesis
|
|
16
12
|
import androidx.compose.ui.text.style.TextAlign
|
|
17
|
-
import androidx.compose.ui.text.withStyle
|
|
18
13
|
import androidx.compose.ui.unit.dp
|
|
19
14
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
20
|
-
import vn.momo.kits.const.AppTheme
|
|
21
15
|
import vn.momo.kits.const.Colors
|
|
22
16
|
import vn.momo.kits.const.Radius
|
|
23
17
|
import vn.momo.kits.const.Spacing
|
|
24
18
|
import vn.momo.kits.const.Typography
|
|
25
|
-
import vn.momo.kits.const.getFontFamily
|
|
26
19
|
import vn.momo.kits.modifier.conditional
|
|
27
20
|
import vn.momo.kits.modifier.setAutomationId
|
|
28
21
|
|
|
@@ -69,7 +62,7 @@ fun Information(
|
|
|
69
62
|
iconSource = "24_notifications_alert_octagon"
|
|
70
63
|
}
|
|
71
64
|
|
|
72
|
-
val annotatedDescription =
|
|
65
|
+
val annotatedDescription = rememberHighlightedText(description, highlightText)
|
|
73
66
|
|
|
74
67
|
Column(
|
|
75
68
|
modifier = Modifier.border(
|
|
@@ -142,54 +135,3 @@ fun Information(
|
|
|
142
135
|
}
|
|
143
136
|
|
|
144
137
|
}
|
|
145
|
-
|
|
146
|
-
// Highlighted keywords keep the caller's text size; only the weight changes.
|
|
147
|
-
@Composable
|
|
148
|
-
internal fun rememberHighlightDescription(description: String, highlightText: List<String>): AnnotatedString {
|
|
149
|
-
// Host fonts are one file per weight: swap fontFamily and disable synthesis so the SemiBold file isn't
|
|
150
|
-
// faux-bolded again; fontWeight still applies when no host font is bundled and the system font is used.
|
|
151
|
-
val highlightWeight = Typography.headerXsSemibold.fontWeight
|
|
152
|
-
val highlightFontFamily = getFontFamily(AppTheme.current.font, highlightWeight)
|
|
153
|
-
return remember(description, highlightText, highlightFontFamily) {
|
|
154
|
-
highlightDescription(
|
|
155
|
-
description,
|
|
156
|
-
highlightText,
|
|
157
|
-
SpanStyle(
|
|
158
|
-
fontFamily = highlightFontFamily,
|
|
159
|
-
fontWeight = highlightWeight,
|
|
160
|
-
fontSynthesis = FontSynthesis.None,
|
|
161
|
-
),
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Whole-word matches only; the longest keyword wins when keywords overlap (RN parity).
|
|
167
|
-
private fun highlightDescription(
|
|
168
|
-
description: String,
|
|
169
|
-
highlightText: List<String>,
|
|
170
|
-
style: SpanStyle,
|
|
171
|
-
): AnnotatedString {
|
|
172
|
-
val keywords = highlightText.filter { it.isNotEmpty() }
|
|
173
|
-
if (keywords.isEmpty()) return AnnotatedString(description)
|
|
174
|
-
val regex = Regex(keywords.sortedByDescending { it.length }.joinToString("|") { Regex.escape(it) })
|
|
175
|
-
fun isWordChar(index: Int) = description.getOrNull(index)?.let { it.isLetterOrDigit() || it == '_' } == true
|
|
176
|
-
|
|
177
|
-
return buildAnnotatedString {
|
|
178
|
-
var lastIndex = 0
|
|
179
|
-
var searchFrom = 0
|
|
180
|
-
while (true) {
|
|
181
|
-
val match = regex.find(description, searchFrom) ?: break
|
|
182
|
-
val start = match.range.first
|
|
183
|
-
val end = match.range.last + 1
|
|
184
|
-
if (isWordChar(start - 1) || isWordChar(end)) {
|
|
185
|
-
searchFrom = start + 1
|
|
186
|
-
continue
|
|
187
|
-
}
|
|
188
|
-
append(description.substring(lastIndex, start))
|
|
189
|
-
withStyle(style) { append(match.value) }
|
|
190
|
-
lastIndex = end
|
|
191
|
-
searchFrom = end
|
|
192
|
-
}
|
|
193
|
-
append(description.substring(lastIndex))
|
|
194
|
-
}
|
|
195
|
-
}
|
|
@@ -45,25 +45,16 @@ import vn.momo.kits.application.IsShowBaseLineDebug
|
|
|
45
45
|
import vn.momo.kits.const.Typography
|
|
46
46
|
import vn.momo.kits.const.getFontFamily
|
|
47
47
|
import vn.momo.kits.const.scaleSize
|
|
48
|
-
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
49
|
-
import vn.momo.kits.layout.HEADER_SEARCH_HEIGHT
|
|
50
48
|
import vn.momo.kits.modifier.conditional
|
|
51
49
|
import vn.momo.kits.utils.ifTrue
|
|
52
50
|
|
|
53
|
-
// Body searches keep 36 / 24; the header search matches the 32pt header buttons.
|
|
54
|
-
internal enum class InputSearchSize(val height: Dp, val iconSize: Dp) {
|
|
55
|
-
Default(36.dp, 24.dp),
|
|
56
|
-
Header(HEADER_SEARCH_HEIGHT, HEADER_ICON_SIZE),
|
|
57
|
-
}
|
|
58
|
-
|
|
59
51
|
@Composable
|
|
60
52
|
internal fun RenderRightIconSearch(
|
|
61
53
|
loading: Boolean,
|
|
62
54
|
icon: String,
|
|
63
55
|
color: Color?,
|
|
64
56
|
onClick: () -> Unit,
|
|
65
|
-
iconModifier: Modifier = Modifier
|
|
66
|
-
iconSize: Dp = InputSearchSize.Default.iconSize,
|
|
57
|
+
iconModifier: Modifier = Modifier
|
|
67
58
|
) {
|
|
68
59
|
if (loading) {
|
|
69
60
|
Box(Modifier.padding(horizontal = Spacing.S)) {
|
|
@@ -83,7 +74,7 @@ internal fun RenderRightIconSearch(
|
|
|
83
74
|
Icon(
|
|
84
75
|
source = icon,
|
|
85
76
|
color = color,
|
|
86
|
-
size =
|
|
77
|
+
size = 24.dp,
|
|
87
78
|
modifier = iconModifier.padding(start = Spacing.S, end = 0.dp).clickable(
|
|
88
79
|
onClick = onClick,
|
|
89
80
|
interactionSource = remember { MutableInteractionSource() },
|
|
@@ -128,11 +119,6 @@ fun InputSearch(
|
|
|
128
119
|
text = remember { mutableStateOf("") },
|
|
129
120
|
),
|
|
130
121
|
) {
|
|
131
|
-
InputSearch(inputSearchProps, InputSearchSize.Default)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
@Composable
|
|
135
|
-
internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSize) {
|
|
136
122
|
var isFocused by remember { mutableStateOf(false) }
|
|
137
123
|
val disabledColor = AppTheme.current.colors.text.disable
|
|
138
124
|
var textColor = AppTheme.current.colors.text.default
|
|
@@ -170,7 +156,7 @@ internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSi
|
|
|
170
156
|
Row(
|
|
171
157
|
verticalAlignment = Alignment.CenterVertically, modifier = Modifier
|
|
172
158
|
.fillMaxWidth()
|
|
173
|
-
.height(
|
|
159
|
+
.height(36.dp)
|
|
174
160
|
.conditional(IsShowBaseLineDebug) {
|
|
175
161
|
border(1.dp, Colors.blue_03)
|
|
176
162
|
}
|
|
@@ -217,7 +203,7 @@ internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSi
|
|
|
217
203
|
inputSearchProps.searchIcon?.invoke() ?: Icon(
|
|
218
204
|
source = "navigation_search",
|
|
219
205
|
modifier = Modifier.padding(end = Spacing.XS),
|
|
220
|
-
size =
|
|
206
|
+
size = 24.dp,
|
|
221
207
|
color = AppTheme.current.colors.text.hint
|
|
222
208
|
)
|
|
223
209
|
Box(Modifier.weight(1f)) {
|
|
@@ -256,8 +242,7 @@ internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSi
|
|
|
256
242
|
inputSearchProps.icon,
|
|
257
243
|
iconTintColor,
|
|
258
244
|
inputSearchProps.onRightIconPressed,
|
|
259
|
-
iconModifier = inputSearchProps.iconModifier
|
|
260
|
-
iconSize = size.iconSize,
|
|
245
|
+
iconModifier = inputSearchProps.iconModifier
|
|
261
246
|
)
|
|
262
247
|
}
|
|
263
248
|
}
|
|
@@ -99,7 +99,7 @@ fun PopupNotify(
|
|
|
99
99
|
|
|
100
100
|
val density = LocalDensity.current
|
|
101
101
|
var scrollHeight: Dp by remember { mutableStateOf(0.dp) }
|
|
102
|
-
val description =
|
|
102
|
+
val description = rememberHighlightedText(props.description, props.highlightText)
|
|
103
103
|
|
|
104
104
|
LaunchedEffect(layoutResult.value) {
|
|
105
105
|
if ((layoutResult.value?.lineCount ?: 0) > 3) {
|
|
@@ -7,11 +7,15 @@ import androidx.compose.runtime.remember
|
|
|
7
7
|
import androidx.compose.ui.Modifier
|
|
8
8
|
import androidx.compose.ui.graphics.Color
|
|
9
9
|
import androidx.compose.ui.text.AnnotatedString
|
|
10
|
+
import androidx.compose.ui.text.SpanStyle
|
|
10
11
|
import androidx.compose.ui.text.TextLayoutResult
|
|
11
12
|
import androidx.compose.ui.text.TextStyle
|
|
13
|
+
import androidx.compose.ui.text.buildAnnotatedString
|
|
14
|
+
import androidx.compose.ui.text.font.FontSynthesis
|
|
12
15
|
import androidx.compose.ui.text.style.TextAlign
|
|
13
16
|
import androidx.compose.ui.text.style.TextDecoration
|
|
14
17
|
import androidx.compose.ui.text.style.TextOverflow
|
|
18
|
+
import androidx.compose.ui.text.withStyle
|
|
15
19
|
import androidx.compose.ui.unit.TextUnit
|
|
16
20
|
import androidx.compose.ui.unit.dp
|
|
17
21
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
@@ -118,3 +122,54 @@ fun Text(
|
|
|
118
122
|
)
|
|
119
123
|
}
|
|
120
124
|
|
|
125
|
+
// Highlighted keywords keep the caller's text size; only the weight changes.
|
|
126
|
+
@Composable
|
|
127
|
+
internal fun rememberHighlightedText(text: String, highlightText: List<String>): AnnotatedString {
|
|
128
|
+
// Host fonts are one file per weight: swap fontFamily and disable synthesis so the SemiBold file isn't
|
|
129
|
+
// faux-bolded again; fontWeight still applies when no host font is bundled and the system font is used.
|
|
130
|
+
val highlightWeight = Typography.headerXsSemibold.fontWeight
|
|
131
|
+
val highlightFontFamily = getFontFamily(AppTheme.current.font, highlightWeight)
|
|
132
|
+
return remember(text, highlightText, highlightFontFamily) {
|
|
133
|
+
buildHighlightedText(
|
|
134
|
+
text,
|
|
135
|
+
highlightText,
|
|
136
|
+
SpanStyle(
|
|
137
|
+
fontFamily = highlightFontFamily,
|
|
138
|
+
fontWeight = highlightWeight,
|
|
139
|
+
fontSynthesis = FontSynthesis.None,
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Whole-word matches only; the longest keyword wins when keywords overlap (RN parity).
|
|
146
|
+
private fun buildHighlightedText(
|
|
147
|
+
text: String,
|
|
148
|
+
highlightText: List<String>,
|
|
149
|
+
style: SpanStyle,
|
|
150
|
+
): AnnotatedString {
|
|
151
|
+
val keywords = highlightText.filter { it.isNotEmpty() }
|
|
152
|
+
if (keywords.isEmpty()) return AnnotatedString(text)
|
|
153
|
+
val regex = Regex(keywords.sortedByDescending { it.length }.joinToString("|") { Regex.escape(it) })
|
|
154
|
+
fun isWordChar(index: Int) = text.getOrNull(index)?.let { it.isLetterOrDigit() || it == '_' } == true
|
|
155
|
+
|
|
156
|
+
return buildAnnotatedString {
|
|
157
|
+
var lastIndex = 0
|
|
158
|
+
var searchFrom = 0
|
|
159
|
+
while (true) {
|
|
160
|
+
val match = regex.find(text, searchFrom) ?: break
|
|
161
|
+
val start = match.range.first
|
|
162
|
+
val end = match.range.last + 1
|
|
163
|
+
if (isWordChar(start - 1) || isWordChar(end)) {
|
|
164
|
+
searchFrom = start + 1
|
|
165
|
+
continue
|
|
166
|
+
}
|
|
167
|
+
append(text.substring(lastIndex, start))
|
|
168
|
+
withStyle(style) { append(match.value) }
|
|
169
|
+
lastIndex = end
|
|
170
|
+
searchFrom = end
|
|
171
|
+
}
|
|
172
|
+
append(text.substring(lastIndex))
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
@@ -3,7 +3,6 @@ package vn.momo.kits.navigation
|
|
|
3
3
|
import androidx.compose.foundation.gestures.ScrollableState
|
|
4
4
|
import androidx.compose.runtime.*
|
|
5
5
|
import androidx.compose.ui.graphics.Color
|
|
6
|
-
import vn.momo.kits.layout.ContentLayout
|
|
7
6
|
import vn.momo.kits.navigation.bottomtab.setBottomTabOption
|
|
8
7
|
import vn.momo.kits.navigation.component.*
|
|
9
8
|
|
|
@@ -41,8 +40,7 @@ class Navigation(
|
|
|
41
40
|
footerTransparent: Boolean? = null,
|
|
42
41
|
footerUseMargin: Boolean? = null,
|
|
43
42
|
floatingButtonProps: FloatingButtonProps? = null,
|
|
44
|
-
keyboardOptions: KeyboardOptions? = null
|
|
45
|
-
contentLayout: ContentLayout? = null,
|
|
43
|
+
keyboardOptions: KeyboardOptions? = null
|
|
46
44
|
) {
|
|
47
45
|
updateOptions(
|
|
48
46
|
options.copy(
|
|
@@ -62,7 +60,6 @@ class Navigation(
|
|
|
62
60
|
footerUseMargin = footerUseMargin ?: options.footerUseMargin,
|
|
63
61
|
floatingButtonProps = floatingButtonProps ?: options.floatingButtonProps,
|
|
64
62
|
keyboardOptions = keyboardOptions ?: options.keyboardOptions,
|
|
65
|
-
contentLayout = contentLayout ?: options.contentLayout,
|
|
66
63
|
)
|
|
67
64
|
)
|
|
68
65
|
}
|
|
@@ -100,9 +97,7 @@ data class NavigationOptions(
|
|
|
100
97
|
val footerTransparent: Boolean = false,
|
|
101
98
|
val footerUseMargin: Boolean = true,
|
|
102
99
|
val floatingButtonProps: FloatingButtonProps? = null,
|
|
103
|
-
val keyboardOptions: KeyboardOptions = KeyboardOptions()
|
|
104
|
-
// Wide windows: Stretch puts the header row in the centered 600pt content frame.
|
|
105
|
-
val contentLayout: ContentLayout = ContentLayout.Grid,
|
|
100
|
+
val keyboardOptions: KeyboardOptions = KeyboardOptions()
|
|
106
101
|
) {
|
|
107
102
|
internal fun hasFooter() : Boolean = footerComponent != null
|
|
108
103
|
}
|
|
@@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.ime
|
|
|
23
23
|
import androidx.compose.foundation.layout.imePadding
|
|
24
24
|
import androidx.compose.foundation.layout.offset
|
|
25
25
|
import androidx.compose.foundation.layout.padding
|
|
26
|
-
import androidx.compose.foundation.layout.width
|
|
27
26
|
import androidx.compose.foundation.lazy.LazyListState
|
|
28
27
|
import androidx.compose.foundation.rememberScrollState
|
|
29
28
|
import androidx.compose.foundation.verticalScroll
|
|
@@ -56,7 +55,6 @@ import kotlinx.coroutines.flow.Flow
|
|
|
56
55
|
import kotlinx.coroutines.flow.filter
|
|
57
56
|
import kotlinx.coroutines.launch
|
|
58
57
|
import vn.momo.kits.components.InputSearch
|
|
59
|
-
import vn.momo.kits.components.InputSearchSize
|
|
60
58
|
import vn.momo.kits.const.AppNavigationBar
|
|
61
59
|
import vn.momo.kits.const.AppTheme
|
|
62
60
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
@@ -87,11 +85,8 @@ import vn.momo.kits.utils.horizontalSafeAreaPadding
|
|
|
87
85
|
import vn.momo.kits.layout.LocalScreenLayout
|
|
88
86
|
import vn.momo.kits.layout.ScreenLayout
|
|
89
87
|
import vn.momo.kits.layout.consumeHorizontalInsets
|
|
90
|
-
import vn.momo.kits.layout.
|
|
91
|
-
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
92
|
-
import vn.momo.kits.layout.HEADER_TITLE_GAP
|
|
88
|
+
import vn.momo.kits.layout.DuoMetrics
|
|
93
89
|
import vn.momo.kits.layout.getScreenLayout
|
|
94
|
-
import vn.momo.kits.layout.rememberHeaderLayout
|
|
95
90
|
import kotlin.time.Clock
|
|
96
91
|
import kotlin.time.Duration.Companion.milliseconds
|
|
97
92
|
import kotlin.time.ExperimentalTime
|
|
@@ -376,24 +371,12 @@ internal fun ScreenContent(content: @Composable () -> Unit, insetContent: Boolea
|
|
|
376
371
|
|
|
377
372
|
if (options.headerType is HeaderType.Animated) {
|
|
378
373
|
val animatedHeader = options.headerType
|
|
379
|
-
val isWide = rememberHeaderLayout(options.contentLayout).isWide
|
|
380
374
|
Box {
|
|
381
|
-
// wide windows keep the phone banner size, centered over a fill fading down from bannerBackgroundColor
|
|
382
|
-
val bannerWidth = if (isWide) Modifier.width(HEADER_BANNER_WIDTH) else Modifier.fillMaxWidth()
|
|
383
375
|
val bannerModifier = animatedHeader.height
|
|
384
|
-
?.let {
|
|
385
|
-
?:
|
|
386
|
-
Box(
|
|
387
|
-
|
|
388
|
-
if (isWide && fill != null) {
|
|
389
|
-
Box(
|
|
390
|
-
Modifier.matchParentSize()
|
|
391
|
-
.background(Brush.verticalGradient(listOf(fill, fill.copy(alpha = 0f))))
|
|
392
|
-
)
|
|
393
|
-
}
|
|
394
|
-
Box(bannerModifier) {
|
|
395
|
-
animatedHeader.composable.invoke(scrollState.value)
|
|
396
|
-
}
|
|
376
|
+
?.let { Modifier.fillMaxWidth().height(it) }
|
|
377
|
+
?: Modifier.fillMaxWidth().aspectRatio(animatedHeader.aspectRatio.value)
|
|
378
|
+
Box(bannerModifier) {
|
|
379
|
+
animatedHeader.composable.invoke(scrollState.value)
|
|
397
380
|
}
|
|
398
381
|
Box(
|
|
399
382
|
Modifier
|
|
@@ -526,18 +509,17 @@ internal fun SearchAnimated(
|
|
|
526
509
|
// collapsed, the search is centered in the bar row
|
|
527
510
|
val minTopPadding = screenLayout.headerStatusBarHeight + (screenLayout.headerBarHeight - HEADER_HEIGHT.dp) / 2
|
|
528
511
|
val maxTopPadding = screenLayout.headerHeight
|
|
529
|
-
// collapsed on the iPhone Duo status bar row, the search stays between its clusters
|
|
512
|
+
// collapsed on the iPhone Duo status bar row, the search stays between its clusters (48pt back there)
|
|
530
513
|
val clearance = screenLayout.statusBarClearance
|
|
531
|
-
|
|
532
|
-
val
|
|
533
|
-
val minStartPadding = sidePadding
|
|
514
|
+
val backWidth = if (clearance != null && !useSideBar) DuoMetrics.controlSize else 28.dp
|
|
515
|
+
val minStartPadding = Spacing.M
|
|
534
516
|
val maxStartPadding = (clearance?.left ?: 0.dp) +
|
|
535
|
-
if (options.hiddenBack || useSideBar)
|
|
536
|
-
val minEndPadding =
|
|
517
|
+
if (options.hiddenBack || useSideBar) Spacing.M else backWidth + Spacing.M + Spacing.S
|
|
518
|
+
val minEndPadding = Spacing.M
|
|
537
519
|
val maxEndPadding = (clearance?.right ?: 0.dp) + when {
|
|
538
|
-
options.headerRight is HeaderRight.None ->
|
|
539
|
-
useSideBar && options.headerRight is HeaderRight.Toolkit ->
|
|
540
|
-
else -> headerRightWidthDp +
|
|
520
|
+
options.headerRight is HeaderRight.None -> Spacing.M
|
|
521
|
+
useSideBar && options.headerRight is HeaderRight.Toolkit -> Spacing.M
|
|
522
|
+
else -> headerRightWidthDp + Spacing.M * 2
|
|
541
523
|
}
|
|
542
524
|
|
|
543
525
|
val targetColor = lerp(
|
|
@@ -598,8 +580,7 @@ internal fun SearchAnimated(
|
|
|
598
580
|
onPressButtonText = {
|
|
599
581
|
navigator.pop()
|
|
600
582
|
}
|
|
601
|
-
)
|
|
602
|
-
size = InputSearchSize.Header,
|
|
583
|
+
)
|
|
603
584
|
)
|
|
604
585
|
}
|
|
605
586
|
}
|
|
@@ -139,19 +139,10 @@ internal fun HorizontalTabBar(
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
cta?.let { CenterAction(it, Modifier.align(Alignment.TopCenter)
|
|
142
|
+
cta?.let { CenterAction(it, Modifier.align(Alignment.TopCenter)) }
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// Offset of the center action column from the bar top: the items are centered in the container (which
|
|
147
|
-
// starts ctaLift down), so the column is placed for its label to start on the tab labels' line.
|
|
148
|
-
private fun centerActionTop() = with(TabBarMetrics) {
|
|
149
|
-
val itemHeight = indicatorHeight + itemIconLabelGap + labelHeight
|
|
150
|
-
val itemLabelTop = ctaLift + paddingVertical + (height - paddingVertical * 2 - itemHeight) / 2 +
|
|
151
|
-
indicatorHeight + itemIconLabelGap
|
|
152
|
-
itemLabelTop - ctaLabelGap - ctaSize
|
|
153
|
-
}
|
|
154
|
-
|
|
155
146
|
// One active indicator per bar (Background/tonal with its inner shadows) sliding to the selected item
|
|
156
147
|
// along x (horizontal bar) or y (rail); it lands in place on the first measure and slides from then on.
|
|
157
148
|
@Composable
|
|
@@ -42,12 +42,8 @@ import vn.momo.kits.const.Colors
|
|
|
42
42
|
import vn.momo.kits.components.PopupNotifyProps
|
|
43
43
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
44
44
|
import vn.momo.kits.const.Spacing
|
|
45
|
-
import vn.momo.kits.layout.
|
|
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
|
|
45
|
+
import vn.momo.kits.layout.DuoMetrics
|
|
49
46
|
import vn.momo.kits.layout.getScreenLayout
|
|
50
|
-
import vn.momo.kits.layout.rememberHeaderLayout
|
|
51
47
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
52
48
|
import vn.momo.kits.modifier.conditional
|
|
53
49
|
import vn.momo.kits.modifier.setAutomationId
|
|
@@ -64,8 +60,10 @@ const val HEADER_HEIGHT = 52
|
|
|
64
60
|
internal enum class InputSearchType { None, Header, Animated }
|
|
65
61
|
enum class TitlePosition { LEFT, CENTER }
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
private val HEADER_ACTIONS_WIDTH = 172.dp
|
|
64
|
+
|
|
65
|
+
// Extra width the 48pt back and toolkit take on the iPhone Duo status bar row.
|
|
66
|
+
private val STATUS_BAR_ROW_ACTIONS_EXTRA = 55.dp
|
|
69
67
|
|
|
70
68
|
@Suppress("FrequentlyChangingValue")
|
|
71
69
|
@Composable
|
|
@@ -93,7 +91,7 @@ internal fun headerTitleMaxWidth(): Dp {
|
|
|
93
91
|
val clearance = layout.statusBarClearance
|
|
94
92
|
val clearanceWidth = clearance?.let { it.left + it.right } ?: 0.dp
|
|
95
93
|
if (layout.sideBar != null) return layout.contentWidth - Spacing.M * 2 - clearanceWidth
|
|
96
|
-
return
|
|
94
|
+
return layout.width - HEADER_ACTIONS_WIDTH - (if (clearance != null) STATUS_BAR_ROW_ACTIONS_EXTRA else 0.dp) - clearanceWidth
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
// Scroll distance over which the Duo glass bar fades in.
|
|
@@ -126,10 +124,10 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
126
124
|
val headerRightWidthPx = LocalHeaderRightWidthPx.current
|
|
127
125
|
val inputSearchType = getInputSearchType(options)
|
|
128
126
|
val layout = getScreenLayout()
|
|
129
|
-
val headerLayout = rememberHeaderLayout(options.contentLayout)
|
|
130
127
|
val useSideBar = layout.sideBar != null
|
|
131
|
-
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters
|
|
128
|
+
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters
|
|
132
129
|
val clearance = layout.statusBarClearance
|
|
130
|
+
val statusBarRow = clearance != null && !useSideBar
|
|
133
131
|
val opacity = headerOpacity()
|
|
134
132
|
|
|
135
133
|
val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
|
|
@@ -188,22 +186,31 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
188
186
|
.fillMaxWidth()
|
|
189
187
|
.horizontalSafeAreaPadding()
|
|
190
188
|
.padding(
|
|
191
|
-
start =
|
|
192
|
-
end =
|
|
189
|
+
start = Spacing.M + (clearance?.left ?: 0.dp),
|
|
190
|
+
end = Spacing.M + (clearance?.right ?: 0.dp),
|
|
193
191
|
),
|
|
194
192
|
verticalAlignment = Alignment.CenterVertically,
|
|
195
193
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
196
194
|
) {
|
|
197
195
|
if (!options.hiddenBack && !useSideBar) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
navigator.onBackSafe {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
196
|
+
if (statusBarRow) {
|
|
197
|
+
SideBarButton(
|
|
198
|
+
icon = "arrow-back",
|
|
199
|
+
headerColor = headerColor,
|
|
200
|
+
automationId = "btn_navigation_back",
|
|
201
|
+
onClick = { navigator.onBackSafe { } },
|
|
202
|
+
)
|
|
203
|
+
} else {
|
|
204
|
+
BackButton(
|
|
205
|
+
borderColor = headerColor.borderColor,
|
|
206
|
+
backgroundButton = headerColor.backgroundButton,
|
|
207
|
+
tintIconColor = headerColor.tintIconColor,
|
|
208
|
+
onBackHandler = {
|
|
209
|
+
navigator.onBackSafe { }
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
Spacer(Modifier.width(Spacing.S))
|
|
207
214
|
}
|
|
208
215
|
|
|
209
216
|
if (centerTitle) {
|
|
@@ -223,6 +230,12 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
223
230
|
when {
|
|
224
231
|
// on Duo the side bar column holds the header right (toolkit or custom), not this row
|
|
225
232
|
useSideBar -> Unit
|
|
233
|
+
statusBarRow && headerRight is HeaderRight.Toolkit -> Toolkit(
|
|
234
|
+
headerRight = headerRight,
|
|
235
|
+
tintColor = options.tintColor,
|
|
236
|
+
headerColor = headerColor,
|
|
237
|
+
layout = ToolkitLayout.SideBarRow,
|
|
238
|
+
)
|
|
226
239
|
else -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
|
|
227
240
|
HeaderRight(headerRight, options.tintColor, headerColor)
|
|
228
241
|
}
|
|
@@ -232,7 +245,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
232
245
|
if (centerTitle) {
|
|
233
246
|
// on the status bar row the clusters are lopsided, so both sides keep the wider one's room
|
|
234
247
|
val centerInset = if (clearance != null) {
|
|
235
|
-
val back = if (options.hiddenBack || useSideBar) 0.dp else
|
|
248
|
+
val back = if (options.hiddenBack || useSideBar) 0.dp else DuoMetrics.controlSize + Spacing.S
|
|
236
249
|
val right = with(LocalDensity.current) { headerRightWidthPx.intValue.toDp() }
|
|
237
250
|
maxOf(clearance.left + back, clearance.right + right) + Spacing.S
|
|
238
251
|
} else {
|
|
@@ -242,7 +255,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
242
255
|
modifier = Modifier.height(layout.headerBarHeight)
|
|
243
256
|
.fillMaxWidth()
|
|
244
257
|
.horizontalSafeAreaPadding()
|
|
245
|
-
.padding(horizontal =
|
|
258
|
+
.padding(horizontal = Spacing.M + centerInset),
|
|
246
259
|
contentAlignment = Alignment.Center
|
|
247
260
|
) {
|
|
248
261
|
HeaderContent(
|
|
@@ -262,7 +275,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
262
275
|
private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
|
|
263
276
|
Box(
|
|
264
277
|
modifier = Modifier
|
|
265
|
-
.size(
|
|
278
|
+
.size(28.dp)
|
|
266
279
|
.background(backgroundButton, RoundedCornerShape(100))
|
|
267
280
|
.border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
|
|
268
281
|
.activeOpacityClickable(onClick = onBackHandler)
|
|
@@ -273,7 +286,7 @@ private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColo
|
|
|
273
286
|
Icon(
|
|
274
287
|
source = "arrow-back",
|
|
275
288
|
color = tintIconColor,
|
|
276
|
-
size =
|
|
289
|
+
size = 20.dp,
|
|
277
290
|
)
|
|
278
291
|
}
|
|
279
292
|
}
|
|
@@ -393,10 +406,7 @@ sealed class HeaderType {
|
|
|
393
406
|
val isSurface: Boolean = true,
|
|
394
407
|
val layoutOffSet: Dp = 56.dp,
|
|
395
408
|
val height: Dp? = null,
|
|
396
|
-
|
|
397
|
-
val bannerBackgroundColor: Color? = null,
|
|
398
|
-
// Last so callers can keep passing it as a trailing lambda.
|
|
399
|
-
val composable: @Composable (scrollState: Int) -> Unit = {},
|
|
409
|
+
val composable: @Composable (scrollState: Int) -> Unit = {}
|
|
400
410
|
) : HeaderType()
|
|
401
411
|
|
|
402
412
|
data class Transparent(
|