@momo-kits/native-kits 0.169.10-debug → 0.169.11-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/InputSearch.kt +20 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +67 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +7 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +34 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +29 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +28 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +3 -10
- package/gradle.properties +1 -1
- package/ios/Input/InputSearch.swift +23 -6
- package/ios/Layout/HeaderLayout.swift +67 -0
- package/ios/Navigation/Component/Header.swift +31 -46
- package/ios/Navigation/Component/HeaderJourney.swift +2 -1
- package/ios/Navigation/Component/HeaderLocation.swift +2 -1
- package/ios/Navigation/Component/HeaderRight.swift +18 -15
- package/ios/Navigation/Component/HeaderUser.swift +2 -1
- package/ios/Navigation/Component/SideBar.swift +4 -13
- package/ios/Navigation/Navigation.swift +6 -1
- package/ios/Navigation/StackScreen.swift +28 -11
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +11 -0
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -45,16 +45,25 @@ 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
|
|
48
50
|
import vn.momo.kits.modifier.conditional
|
|
49
51
|
import vn.momo.kits.utils.ifTrue
|
|
50
52
|
|
|
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
|
+
|
|
51
59
|
@Composable
|
|
52
60
|
internal fun RenderRightIconSearch(
|
|
53
61
|
loading: Boolean,
|
|
54
62
|
icon: String,
|
|
55
63
|
color: Color?,
|
|
56
64
|
onClick: () -> Unit,
|
|
57
|
-
iconModifier: Modifier = Modifier
|
|
65
|
+
iconModifier: Modifier = Modifier,
|
|
66
|
+
iconSize: Dp = InputSearchSize.Default.iconSize,
|
|
58
67
|
) {
|
|
59
68
|
if (loading) {
|
|
60
69
|
Box(Modifier.padding(horizontal = Spacing.S)) {
|
|
@@ -74,7 +83,7 @@ internal fun RenderRightIconSearch(
|
|
|
74
83
|
Icon(
|
|
75
84
|
source = icon,
|
|
76
85
|
color = color,
|
|
77
|
-
size =
|
|
86
|
+
size = iconSize,
|
|
78
87
|
modifier = iconModifier.padding(start = Spacing.S, end = 0.dp).clickable(
|
|
79
88
|
onClick = onClick,
|
|
80
89
|
interactionSource = remember { MutableInteractionSource() },
|
|
@@ -119,6 +128,11 @@ fun InputSearch(
|
|
|
119
128
|
text = remember { mutableStateOf("") },
|
|
120
129
|
),
|
|
121
130
|
) {
|
|
131
|
+
InputSearch(inputSearchProps, InputSearchSize.Default)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@Composable
|
|
135
|
+
internal fun InputSearch(inputSearchProps: InputSearchProps, size: InputSearchSize) {
|
|
122
136
|
var isFocused by remember { mutableStateOf(false) }
|
|
123
137
|
val disabledColor = AppTheme.current.colors.text.disable
|
|
124
138
|
var textColor = AppTheme.current.colors.text.default
|
|
@@ -156,7 +170,7 @@ fun InputSearch(
|
|
|
156
170
|
Row(
|
|
157
171
|
verticalAlignment = Alignment.CenterVertically, modifier = Modifier
|
|
158
172
|
.fillMaxWidth()
|
|
159
|
-
.height(
|
|
173
|
+
.height(size.height)
|
|
160
174
|
.conditional(IsShowBaseLineDebug) {
|
|
161
175
|
border(1.dp, Colors.blue_03)
|
|
162
176
|
}
|
|
@@ -203,7 +217,7 @@ fun InputSearch(
|
|
|
203
217
|
inputSearchProps.searchIcon?.invoke() ?: Icon(
|
|
204
218
|
source = "navigation_search",
|
|
205
219
|
modifier = Modifier.padding(end = Spacing.XS),
|
|
206
|
-
size =
|
|
220
|
+
size = size.iconSize,
|
|
207
221
|
color = AppTheme.current.colors.text.hint
|
|
208
222
|
)
|
|
209
223
|
Box(Modifier.weight(1f)) {
|
|
@@ -242,7 +256,8 @@ fun InputSearch(
|
|
|
242
256
|
inputSearchProps.icon,
|
|
243
257
|
iconTintColor,
|
|
244
258
|
inputSearchProps.onRightIconPressed,
|
|
245
|
-
iconModifier = inputSearchProps.iconModifier
|
|
259
|
+
iconModifier = inputSearchProps.iconModifier,
|
|
260
|
+
iconSize = size.iconSize,
|
|
246
261
|
)
|
|
247
262
|
}
|
|
248
263
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package vn.momo.kits.layout
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Composable
|
|
4
|
+
import androidx.compose.runtime.Immutable
|
|
5
|
+
import androidx.compose.runtime.remember
|
|
6
|
+
import androidx.compose.ui.unit.Dp
|
|
7
|
+
import androidx.compose.ui.unit.dp
|
|
8
|
+
import vn.momo.kits.const.DEFAULT_SCREEN_SIZE
|
|
9
|
+
import vn.momo.kits.const.Spacing
|
|
10
|
+
|
|
11
|
+
// Top navigation spec (Figma "Top Navigation · Màn hình gập"); mirrors RN and SwiftUI, keep in sync.
|
|
12
|
+
val HEADER_BUTTON_SIZE = 32.dp
|
|
13
|
+
val HEADER_ICON_SIZE = 20.dp
|
|
14
|
+
val HEADER_PILL_WIDTH = 72.dp
|
|
15
|
+
val HEADER_SEARCH_HEIGHT = 32.dp
|
|
16
|
+
val HEADER_FRAME_MAX_WIDTH = 600.dp
|
|
17
|
+
// Banner image width on every device: wide windows keep the phone size, centered.
|
|
18
|
+
val HEADER_BANNER_WIDTH = DEFAULT_SCREEN_SIZE.dp
|
|
19
|
+
internal val HEADER_TITLE_GAP = Spacing.S
|
|
20
|
+
internal val HEADER_SIDE_PADDING = Spacing.M
|
|
21
|
+
// shortcut + gap + help/home pill
|
|
22
|
+
val HEADER_CLUSTER_WIDTH = HEADER_BUTTON_SIZE + HEADER_TITLE_GAP + HEADER_PILL_WIDTH
|
|
23
|
+
|
|
24
|
+
/** How a screen lays out its content on wide windows; the header row follows it. */
|
|
25
|
+
enum class ContentLayout {
|
|
26
|
+
// 12 column grid: the header keeps the 12pt side padding.
|
|
27
|
+
Grid,
|
|
28
|
+
// One column of at most HEADER_FRAME_MAX_WIDTH, centered: the header row sits in the same frame.
|
|
29
|
+
Stretch,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Header geometry for the current window; see [headerLayoutOf]. */
|
|
33
|
+
@Immutable
|
|
34
|
+
data class HeaderLayout(
|
|
35
|
+
// short side >= FOLDABLE_MIN_WIDTH, iPhone Duo excluded (it has its own layout)
|
|
36
|
+
val isWide: Boolean,
|
|
37
|
+
// banner kept at HEADER_BANNER_WIDTH, centered: wide windows plus the iPhone Duo inner display
|
|
38
|
+
val isBannerCentered: Boolean,
|
|
39
|
+
// padding from each side of the safe area to the header row (back, title / search, right cluster)
|
|
40
|
+
val frameInset: Dp,
|
|
41
|
+
// width of the header row, so tabs and other header extensions can line up with it
|
|
42
|
+
val frameWidth: Dp,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
// Pass the screen's NavigationOptions.contentLayout so tabs and extensions line up with its header.
|
|
46
|
+
@Composable
|
|
47
|
+
fun rememberHeaderLayout(contentLayout: ContentLayout = ContentLayout.Grid): HeaderLayout {
|
|
48
|
+
val layout = getScreenLayout()
|
|
49
|
+
return remember(layout, contentLayout) { headerLayoutOf(layout, contentLayout) }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fun headerLayoutOf(layout: ScreenLayout, contentLayout: ContentLayout): HeaderLayout {
|
|
53
|
+
val isDuo = layout.isIPhoneDuo || layout.isIPhoneDuoDevice
|
|
54
|
+
val isLargeWindow = minOf(layout.width, layout.height) >= FOLDABLE_MIN_WIDTH
|
|
55
|
+
val isWide = !isDuo && isLargeWindow
|
|
56
|
+
val frameInset = if (isWide && contentLayout == ContentLayout.Stretch) {
|
|
57
|
+
maxOf(HEADER_SIDE_PADDING, (layout.contentWidth - HEADER_FRAME_MAX_WIDTH) / 2)
|
|
58
|
+
} else {
|
|
59
|
+
HEADER_SIDE_PADDING
|
|
60
|
+
}
|
|
61
|
+
return HeaderLayout(
|
|
62
|
+
isWide = isWide,
|
|
63
|
+
isBannerCentered = isLargeWindow,
|
|
64
|
+
frameInset = frameInset,
|
|
65
|
+
frameWidth = layout.contentWidth - frameInset * 2,
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -3,6 +3,7 @@ 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
|
|
6
7
|
import vn.momo.kits.navigation.bottomtab.setBottomTabOption
|
|
7
8
|
import vn.momo.kits.navigation.component.*
|
|
8
9
|
|
|
@@ -40,7 +41,8 @@ class Navigation(
|
|
|
40
41
|
footerTransparent: Boolean? = null,
|
|
41
42
|
footerUseMargin: Boolean? = null,
|
|
42
43
|
floatingButtonProps: FloatingButtonProps? = null,
|
|
43
|
-
keyboardOptions: KeyboardOptions? = null
|
|
44
|
+
keyboardOptions: KeyboardOptions? = null,
|
|
45
|
+
contentLayout: ContentLayout? = null,
|
|
44
46
|
) {
|
|
45
47
|
updateOptions(
|
|
46
48
|
options.copy(
|
|
@@ -60,6 +62,7 @@ class Navigation(
|
|
|
60
62
|
footerUseMargin = footerUseMargin ?: options.footerUseMargin,
|
|
61
63
|
floatingButtonProps = floatingButtonProps ?: options.floatingButtonProps,
|
|
62
64
|
keyboardOptions = keyboardOptions ?: options.keyboardOptions,
|
|
65
|
+
contentLayout = contentLayout ?: options.contentLayout,
|
|
63
66
|
)
|
|
64
67
|
)
|
|
65
68
|
}
|
|
@@ -97,7 +100,9 @@ data class NavigationOptions(
|
|
|
97
100
|
val footerTransparent: Boolean = false,
|
|
98
101
|
val footerUseMargin: Boolean = true,
|
|
99
102
|
val floatingButtonProps: FloatingButtonProps? = null,
|
|
100
|
-
val keyboardOptions: KeyboardOptions = KeyboardOptions()
|
|
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,
|
|
101
106
|
) {
|
|
102
107
|
internal fun hasFooter() : Boolean = footerComponent != null
|
|
103
108
|
}
|
|
@@ -23,6 +23,7 @@ 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
|
|
26
27
|
import androidx.compose.foundation.lazy.LazyListState
|
|
27
28
|
import androidx.compose.foundation.rememberScrollState
|
|
28
29
|
import androidx.compose.foundation.verticalScroll
|
|
@@ -55,6 +56,7 @@ import kotlinx.coroutines.flow.Flow
|
|
|
55
56
|
import kotlinx.coroutines.flow.filter
|
|
56
57
|
import kotlinx.coroutines.launch
|
|
57
58
|
import vn.momo.kits.components.InputSearch
|
|
59
|
+
import vn.momo.kits.components.InputSearchSize
|
|
58
60
|
import vn.momo.kits.const.AppNavigationBar
|
|
59
61
|
import vn.momo.kits.const.AppTheme
|
|
60
62
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
@@ -85,8 +87,11 @@ import vn.momo.kits.utils.horizontalSafeAreaPadding
|
|
|
85
87
|
import vn.momo.kits.layout.LocalScreenLayout
|
|
86
88
|
import vn.momo.kits.layout.ScreenLayout
|
|
87
89
|
import vn.momo.kits.layout.consumeHorizontalInsets
|
|
88
|
-
import vn.momo.kits.layout.
|
|
90
|
+
import vn.momo.kits.layout.HEADER_BANNER_WIDTH
|
|
91
|
+
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
92
|
+
import vn.momo.kits.layout.HEADER_TITLE_GAP
|
|
89
93
|
import vn.momo.kits.layout.getScreenLayout
|
|
94
|
+
import vn.momo.kits.layout.rememberHeaderLayout
|
|
90
95
|
import kotlin.time.Clock
|
|
91
96
|
import kotlin.time.Duration.Companion.milliseconds
|
|
92
97
|
import kotlin.time.ExperimentalTime
|
|
@@ -369,12 +374,25 @@ internal fun ScreenContent(content: @Composable () -> Unit, insetContent: Boolea
|
|
|
369
374
|
|
|
370
375
|
if (options.headerType is HeaderType.Animated) {
|
|
371
376
|
val animatedHeader = options.headerType
|
|
377
|
+
val isBannerCentered = rememberHeaderLayout(options.contentLayout).isBannerCentered
|
|
372
378
|
Box {
|
|
379
|
+
// wide windows and the iPhone Duo inner display keep the phone banner size, centered over
|
|
380
|
+
// a fill fading down from bannerBackgroundColor
|
|
381
|
+
val bannerWidth = if (isBannerCentered) Modifier.width(HEADER_BANNER_WIDTH) else Modifier.fillMaxWidth()
|
|
373
382
|
val bannerModifier = animatedHeader.height
|
|
374
|
-
?.let {
|
|
375
|
-
?:
|
|
376
|
-
Box(
|
|
377
|
-
animatedHeader.
|
|
383
|
+
?.let { bannerWidth.height(it) }
|
|
384
|
+
?: bannerWidth.aspectRatio(animatedHeader.aspectRatio.value)
|
|
385
|
+
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.TopCenter) {
|
|
386
|
+
val fill = animatedHeader.bannerBackgroundColor
|
|
387
|
+
if (isBannerCentered && fill != null) {
|
|
388
|
+
Box(
|
|
389
|
+
Modifier.matchParentSize()
|
|
390
|
+
.background(Brush.verticalGradient(listOf(fill, fill.copy(alpha = 0f))))
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
Box(bannerModifier) {
|
|
394
|
+
animatedHeader.composable.invoke(scrollState.value)
|
|
395
|
+
}
|
|
378
396
|
}
|
|
379
397
|
Box(
|
|
380
398
|
Modifier
|
|
@@ -507,17 +525,18 @@ internal fun SearchAnimated(
|
|
|
507
525
|
// collapsed, the search is centered in the bar row
|
|
508
526
|
val minTopPadding = screenLayout.headerStatusBarHeight + (screenLayout.headerBarHeight - HEADER_HEIGHT.dp) / 2
|
|
509
527
|
val maxTopPadding = screenLayout.headerHeight
|
|
510
|
-
// collapsed on the iPhone Duo status bar row, the search stays between its clusters
|
|
528
|
+
// collapsed on the iPhone Duo status bar row, the search stays between its clusters
|
|
511
529
|
val clearance = screenLayout.statusBarClearance
|
|
512
|
-
|
|
513
|
-
val
|
|
530
|
+
// stretch screens on wide windows keep the search in the header's centered frame
|
|
531
|
+
val sidePadding = rememberHeaderLayout(options.contentLayout).frameInset
|
|
532
|
+
val minStartPadding = sidePadding
|
|
514
533
|
val maxStartPadding = (clearance?.left ?: 0.dp) +
|
|
515
|
-
if (options.hiddenBack || useSideBar)
|
|
516
|
-
val minEndPadding =
|
|
534
|
+
if (options.hiddenBack || useSideBar) sidePadding else HEADER_BUTTON_SIZE + sidePadding + HEADER_TITLE_GAP
|
|
535
|
+
val minEndPadding = sidePadding
|
|
517
536
|
val maxEndPadding = (clearance?.right ?: 0.dp) + when {
|
|
518
|
-
options.headerRight is HeaderRight.None ->
|
|
519
|
-
useSideBar && options.headerRight is HeaderRight.Toolkit ->
|
|
520
|
-
else -> headerRightWidthDp + Spacing.M
|
|
537
|
+
options.headerRight is HeaderRight.None -> sidePadding
|
|
538
|
+
useSideBar && options.headerRight is HeaderRight.Toolkit -> sidePadding
|
|
539
|
+
else -> headerRightWidthDp + sidePadding + Spacing.M
|
|
521
540
|
}
|
|
522
541
|
|
|
523
542
|
val targetColor = lerp(
|
|
@@ -578,7 +597,8 @@ internal fun SearchAnimated(
|
|
|
578
597
|
onPressButtonText = {
|
|
579
598
|
navigator.pop()
|
|
580
599
|
}
|
|
581
|
-
)
|
|
600
|
+
),
|
|
601
|
+
size = InputSearchSize.Header,
|
|
582
602
|
)
|
|
583
603
|
}
|
|
584
604
|
}
|
|
@@ -42,8 +42,12 @@ 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.
|
|
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
|
|
46
49
|
import vn.momo.kits.layout.getScreenLayout
|
|
50
|
+
import vn.momo.kits.layout.rememberHeaderLayout
|
|
47
51
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
48
52
|
import vn.momo.kits.modifier.conditional
|
|
49
53
|
import vn.momo.kits.modifier.setAutomationId
|
|
@@ -60,10 +64,8 @@ const val HEADER_HEIGHT = 52
|
|
|
60
64
|
internal enum class InputSearchType { None, Header, Animated }
|
|
61
65
|
enum class TitlePosition { LEFT, CENTER }
|
|
62
66
|
|
|
63
|
-
|
|
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
|
|
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
|
|
67
69
|
|
|
68
70
|
@Suppress("FrequentlyChangingValue")
|
|
69
71
|
@Composable
|
|
@@ -91,7 +93,7 @@ internal fun headerTitleMaxWidth(): Dp {
|
|
|
91
93
|
val clearance = layout.statusBarClearance
|
|
92
94
|
val clearanceWidth = clearance?.let { it.left + it.right } ?: 0.dp
|
|
93
95
|
if (layout.sideBar != null) return layout.contentWidth - Spacing.M * 2 - clearanceWidth
|
|
94
|
-
return
|
|
96
|
+
return rememberHeaderLayout(LocalOptions.current.contentLayout).frameWidth - HEADER_ACTIONS_WIDTH - clearanceWidth
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// Scroll distance over which the Duo glass bar fades in.
|
|
@@ -124,10 +126,10 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
124
126
|
val headerRightWidthPx = LocalHeaderRightWidthPx.current
|
|
125
127
|
val inputSearchType = getInputSearchType(options)
|
|
126
128
|
val layout = getScreenLayout()
|
|
129
|
+
val headerLayout = rememberHeaderLayout(options.contentLayout)
|
|
127
130
|
val useSideBar = layout.sideBar != null
|
|
128
|
-
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters
|
|
131
|
+
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters, with phone-size controls
|
|
129
132
|
val clearance = layout.statusBarClearance
|
|
130
|
-
val statusBarRow = clearance != null && !useSideBar
|
|
131
133
|
val opacity = headerOpacity()
|
|
132
134
|
|
|
133
135
|
val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
|
|
@@ -186,31 +188,22 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
186
188
|
.fillMaxWidth()
|
|
187
189
|
.horizontalSafeAreaPadding()
|
|
188
190
|
.padding(
|
|
189
|
-
start =
|
|
190
|
-
end =
|
|
191
|
+
start = headerLayout.frameInset + (clearance?.left ?: 0.dp),
|
|
192
|
+
end = headerLayout.frameInset + (clearance?.right ?: 0.dp),
|
|
191
193
|
),
|
|
192
194
|
verticalAlignment = Alignment.CenterVertically,
|
|
193
195
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
194
196
|
) {
|
|
195
197
|
if (!options.hiddenBack && !useSideBar) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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))
|
|
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))
|
|
214
207
|
}
|
|
215
208
|
|
|
216
209
|
if (centerTitle) {
|
|
@@ -230,12 +223,6 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
230
223
|
when {
|
|
231
224
|
// on Duo the side bar column holds the header right (toolkit or custom), not this row
|
|
232
225
|
useSideBar -> Unit
|
|
233
|
-
statusBarRow && headerRight is HeaderRight.Toolkit -> Toolkit(
|
|
234
|
-
headerRight = headerRight,
|
|
235
|
-
tintColor = options.tintColor,
|
|
236
|
-
headerColor = headerColor,
|
|
237
|
-
layout = ToolkitLayout.SideBarRow,
|
|
238
|
-
)
|
|
239
226
|
else -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
|
|
240
227
|
HeaderRight(headerRight, options.tintColor, headerColor)
|
|
241
228
|
}
|
|
@@ -245,7 +232,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
245
232
|
if (centerTitle) {
|
|
246
233
|
// on the status bar row the clusters are lopsided, so both sides keep the wider one's room
|
|
247
234
|
val centerInset = if (clearance != null) {
|
|
248
|
-
val back = if (options.hiddenBack || useSideBar) 0.dp else
|
|
235
|
+
val back = if (options.hiddenBack || useSideBar) 0.dp else HEADER_BUTTON_SIZE + HEADER_TITLE_GAP
|
|
249
236
|
val right = with(LocalDensity.current) { headerRightWidthPx.intValue.toDp() }
|
|
250
237
|
maxOf(clearance.left + back, clearance.right + right) + Spacing.S
|
|
251
238
|
} else {
|
|
@@ -255,7 +242,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
255
242
|
modifier = Modifier.height(layout.headerBarHeight)
|
|
256
243
|
.fillMaxWidth()
|
|
257
244
|
.horizontalSafeAreaPadding()
|
|
258
|
-
.padding(horizontal =
|
|
245
|
+
.padding(horizontal = headerLayout.frameInset + centerInset),
|
|
259
246
|
contentAlignment = Alignment.Center
|
|
260
247
|
) {
|
|
261
248
|
HeaderContent(
|
|
@@ -275,7 +262,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
275
262
|
private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
|
|
276
263
|
Box(
|
|
277
264
|
modifier = Modifier
|
|
278
|
-
.size(
|
|
265
|
+
.size(HEADER_BUTTON_SIZE)
|
|
279
266
|
.background(backgroundButton, RoundedCornerShape(100))
|
|
280
267
|
.border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
|
|
281
268
|
.activeOpacityClickable(onClick = onBackHandler)
|
|
@@ -286,7 +273,7 @@ private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColo
|
|
|
286
273
|
Icon(
|
|
287
274
|
source = "arrow-back",
|
|
288
275
|
color = tintIconColor,
|
|
289
|
-
size =
|
|
276
|
+
size = HEADER_ICON_SIZE,
|
|
290
277
|
)
|
|
291
278
|
}
|
|
292
279
|
}
|
|
@@ -406,7 +393,10 @@ sealed class HeaderType {
|
|
|
406
393
|
val isSurface: Boolean = true,
|
|
407
394
|
val layoutOffSet: Dp = 56.dp,
|
|
408
395
|
val height: Dp? = null,
|
|
409
|
-
|
|
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 = {},
|
|
410
400
|
) : HeaderType()
|
|
411
401
|
|
|
412
402
|
data class Transparent(
|
|
@@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.Arrangement
|
|
|
8
8
|
import androidx.compose.foundation.layout.Box
|
|
9
9
|
import androidx.compose.foundation.layout.Column
|
|
10
10
|
import androidx.compose.foundation.layout.Row
|
|
11
|
+
import androidx.compose.foundation.layout.RowScope
|
|
12
|
+
import androidx.compose.foundation.layout.fillMaxHeight
|
|
11
13
|
import androidx.compose.foundation.layout.height
|
|
12
14
|
import androidx.compose.foundation.layout.offset
|
|
13
15
|
import androidx.compose.foundation.layout.padding
|
|
@@ -29,6 +31,9 @@ import androidx.compose.ui.graphics.Color
|
|
|
29
31
|
import androidx.compose.ui.unit.Dp
|
|
30
32
|
import androidx.compose.ui.unit.dp
|
|
31
33
|
import vn.momo.kits.layout.DuoMetrics
|
|
34
|
+
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
35
|
+
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
36
|
+
import vn.momo.kits.layout.HEADER_PILL_WIDTH
|
|
32
37
|
import vn.momo.kits.application.LocalContext
|
|
33
38
|
import vn.momo.kits.application.MiniAppContext
|
|
34
39
|
import vn.momo.kits.components.BadgeDot
|
|
@@ -81,8 +86,8 @@ internal fun toolkitColumnHeight(headerRight: HeaderRight.Toolkit): Dp {
|
|
|
81
86
|
return shortcut + if (groupCount > 1) DuoMetrics.itemPitch * groupCount else DuoMetrics.controlSize
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
// SideBarColumn: the iPhone Duo side bar;
|
|
85
|
-
internal enum class ToolkitLayout { Bar, SideBarColumn
|
|
89
|
+
// SideBarColumn: the iPhone Duo side bar, 48pt controls; Bar: every header row, iPhone Duo status bar row included.
|
|
90
|
+
internal enum class ToolkitLayout { Bar, SideBarColumn }
|
|
86
91
|
|
|
87
92
|
@Composable
|
|
88
93
|
internal fun Toolkit(
|
|
@@ -169,8 +174,7 @@ internal fun Toolkit(
|
|
|
169
174
|
}
|
|
170
175
|
|
|
171
176
|
if (layout != ToolkitLayout.Bar) {
|
|
172
|
-
|
|
173
|
-
val controls = @Composable {
|
|
177
|
+
Column(verticalArrangement = Arrangement.spacedBy(Spacing.M)) {
|
|
174
178
|
if (isShowShortcut) {
|
|
175
179
|
SideBarButton(
|
|
176
180
|
icon = icon,
|
|
@@ -180,7 +184,7 @@ internal fun Toolkit(
|
|
|
180
184
|
onClick = navButtonConfig.onPress,
|
|
181
185
|
)
|
|
182
186
|
}
|
|
183
|
-
SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1
|
|
187
|
+
SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1) { item ->
|
|
184
188
|
if (useHelpCenter) {
|
|
185
189
|
SideBarGroupItem(
|
|
186
190
|
icon = "help_center",
|
|
@@ -199,13 +203,6 @@ internal fun Toolkit(
|
|
|
199
203
|
)
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
|
-
if (horizontal) {
|
|
203
|
-
Row(horizontalArrangement = Arrangement.spacedBy(Spacing.M), verticalAlignment = Alignment.CenterVertically) {
|
|
204
|
-
controls()
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
Column(verticalArrangement = Arrangement.spacedBy(Spacing.M)) { controls() }
|
|
208
|
-
}
|
|
209
206
|
return
|
|
210
207
|
}
|
|
211
208
|
|
|
@@ -227,18 +224,14 @@ internal fun Toolkit(
|
|
|
227
224
|
horizontalArrangement = Arrangement.Center,
|
|
228
225
|
modifier = Modifier
|
|
229
226
|
.padding(start = Spacing.S)
|
|
230
|
-
.border(0.2.dp, headerColor.borderColor, shape =
|
|
231
|
-
.height(
|
|
232
|
-
.
|
|
227
|
+
.border(0.2.dp, headerColor.borderColor, shape = PILL_SHAPE)
|
|
228
|
+
.height(HEADER_BUTTON_SIZE)
|
|
229
|
+
.width(if (useHelpCenter) HEADER_PILL_WIDTH else HEADER_BUTTON_SIZE)
|
|
230
|
+
.clip(shape = PILL_SHAPE)
|
|
233
231
|
.background(headerColor.backgroundButton)
|
|
234
232
|
) {
|
|
235
233
|
if (useHelpCenter) {
|
|
236
|
-
|
|
237
|
-
source = "help_center",
|
|
238
|
-
size = 20.dp,
|
|
239
|
-
color = headerColor.tintIconColor,
|
|
240
|
-
modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressHelpCenter)
|
|
241
|
-
)
|
|
234
|
+
PillItem(icon = "help_center", headerColor = headerColor, onClick = ::onPressHelpCenter)
|
|
242
235
|
Box(
|
|
243
236
|
modifier = Modifier
|
|
244
237
|
.width(0.5.dp)
|
|
@@ -246,17 +239,23 @@ internal fun Toolkit(
|
|
|
246
239
|
.background(tintColor ?: Colors.black_20)
|
|
247
240
|
)
|
|
248
241
|
}
|
|
249
|
-
|
|
250
|
-
source = closeIcon,
|
|
251
|
-
size = 20.dp,
|
|
252
|
-
color = headerColor.tintIconColor,
|
|
253
|
-
modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressClose)
|
|
254
|
-
)
|
|
242
|
+
PillItem(icon = closeIcon, headerColor = headerColor, onClick = ::onPressClose)
|
|
255
243
|
}
|
|
256
244
|
}
|
|
257
245
|
}
|
|
258
246
|
|
|
247
|
+
private val PILL_SHAPE = RoundedCornerShape(percent = 50)
|
|
259
248
|
|
|
249
|
+
// One half of the help / home pill; each half takes an equal share of the pill width.
|
|
250
|
+
@Composable
|
|
251
|
+
private fun RowScope.PillItem(icon: String, headerColor: HeaderColor, onClick: () -> Unit) {
|
|
252
|
+
Box(
|
|
253
|
+
modifier = Modifier.weight(1f).fillMaxHeight().activeOpacityClickable(onClick = onClick),
|
|
254
|
+
contentAlignment = Alignment.Center,
|
|
255
|
+
) {
|
|
256
|
+
Icon(source = icon, size = HEADER_ICON_SIZE, color = headerColor.tintIconColor)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
260
259
|
|
|
261
260
|
// Colors follow the enclosing header, so it fits a `HeaderRight.Custom` next to the toolkit.
|
|
262
261
|
@Composable
|
|
@@ -288,7 +287,7 @@ internal fun NavigationButton(
|
|
|
288
287
|
) {
|
|
289
288
|
Box(
|
|
290
289
|
modifier = modifier
|
|
291
|
-
.size(
|
|
290
|
+
.size(HEADER_BUTTON_SIZE)
|
|
292
291
|
.activeOpacityClickable(enabled = !disabled, onClick = onClick)
|
|
293
292
|
) {
|
|
294
293
|
Box(
|
|
@@ -304,7 +303,7 @@ internal fun NavigationButton(
|
|
|
304
303
|
) {
|
|
305
304
|
Icon(
|
|
306
305
|
source = icon,
|
|
307
|
-
size =
|
|
306
|
+
size = HEADER_ICON_SIZE,
|
|
308
307
|
color = headerColor.tintIconColor
|
|
309
308
|
)
|
|
310
309
|
}
|
|
@@ -150,25 +150,18 @@ internal fun SideBarButton(
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
//
|
|
153
|
+
// Vertical capsule grouping related side bar controls, one item per 50pt.
|
|
154
154
|
@Composable
|
|
155
155
|
internal fun SideBarGroup(
|
|
156
156
|
headerColor: HeaderColor,
|
|
157
157
|
itemCount: Int,
|
|
158
|
-
horizontal: Boolean = false,
|
|
159
158
|
content: @Composable (itemModifier: Modifier) -> Unit,
|
|
160
159
|
) {
|
|
161
160
|
val length = if (itemCount > 1) DuoMetrics.itemPitch * itemCount else DuoMetrics.controlSize
|
|
162
161
|
val item = length / itemCount.coerceAtLeast(1)
|
|
163
162
|
val glass = Modifier.sideBarGlass(headerColor, RoundedCornerShape(Radius.XL))
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
content(Modifier.size(width = item, height = DuoMetrics.controlSize))
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
Column(Modifier.size(width = DuoMetrics.controlSize, height = length).then(glass)) {
|
|
170
|
-
content(Modifier.size(width = DuoMetrics.controlSize, height = item))
|
|
171
|
-
}
|
|
163
|
+
Column(Modifier.size(width = DuoMetrics.controlSize, height = length).then(glass)) {
|
|
164
|
+
content(Modifier.size(width = DuoMetrics.controlSize, height = item))
|
|
172
165
|
}
|
|
173
166
|
}
|
|
174
167
|
|
package/gradle.properties
CHANGED