@momo-kits/native-kits 0.169.8-beta.3-debug → 0.169.8-beta.4-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.
Files changed (26) hide show
  1. package/compose/build.gradle.kts +1 -1
  2. package/compose/compose.podspec +1 -1
  3. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +63 -0
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +7 -2
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +33 -12
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +1 -10
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +21 -11
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +24 -17
  10. package/gradle.properties +1 -1
  11. package/ios/Input/InputSearch.swift +23 -6
  12. package/ios/Layout/HeaderLayout.swift +60 -0
  13. package/ios/Navigation/BottomTab/BottomTabBar.swift +0 -9
  14. package/ios/Navigation/Component/Header.swift +25 -15
  15. package/ios/Navigation/Component/HeaderJourney.swift +2 -1
  16. package/ios/Navigation/Component/HeaderLocation.swift +2 -1
  17. package/ios/Navigation/Component/HeaderRight.swift +13 -8
  18. package/ios/Navigation/Component/HeaderUser.swift +2 -1
  19. package/ios/Navigation/Navigation.swift +6 -26
  20. package/ios/Navigation/StackScreen.swift +30 -26
  21. package/ios/native-kits.podspec +1 -1
  22. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  23. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
  24. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +1 -13
  25. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +11 -0
  26. package/package.json +1 -1
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.169.8-beta.3-debug"
43
+ version = "0.169.8-beta.4-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.169.8-beta.3-debug'
3
+ spec.version = '0.169.8-beta.4-debug'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -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 = 24.dp,
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(36.dp)
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 = 24.dp,
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,63 @@
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
+ // padding from each side of the safe area to the header row (back, title / search, right cluster)
38
+ val frameInset: Dp,
39
+ // width of the header row, so tabs and other header extensions can line up with it
40
+ val frameWidth: Dp,
41
+ )
42
+
43
+ // Pass the screen's NavigationOptions.contentLayout so tabs and extensions line up with its header.
44
+ @Composable
45
+ fun rememberHeaderLayout(contentLayout: ContentLayout = ContentLayout.Grid): HeaderLayout {
46
+ val layout = getScreenLayout()
47
+ return remember(layout, contentLayout) { headerLayoutOf(layout, contentLayout) }
48
+ }
49
+
50
+ fun headerLayoutOf(layout: ScreenLayout, contentLayout: ContentLayout): HeaderLayout {
51
+ val isDuo = layout.isIPhoneDuo || layout.isIPhoneDuoDevice
52
+ val isWide = !isDuo && minOf(layout.width, layout.height) >= FOLDABLE_MIN_WIDTH
53
+ val frameInset = if (isWide && contentLayout == ContentLayout.Stretch) {
54
+ maxOf(HEADER_SIDE_PADDING, (layout.contentWidth - HEADER_FRAME_MAX_WIDTH) / 2)
55
+ } else {
56
+ HEADER_SIDE_PADDING
57
+ }
58
+ return HeaderLayout(
59
+ isWide = isWide,
60
+ frameInset = frameInset,
61
+ frameWidth = layout.contentWidth - frameInset * 2,
62
+ )
63
+ }
@@ -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
@@ -86,7 +88,11 @@ import vn.momo.kits.layout.LocalScreenLayout
86
88
  import vn.momo.kits.layout.ScreenLayout
87
89
  import vn.momo.kits.layout.consumeHorizontalInsets
88
90
  import vn.momo.kits.layout.DuoMetrics
91
+ import vn.momo.kits.layout.HEADER_BANNER_WIDTH
92
+ import vn.momo.kits.layout.HEADER_BUTTON_SIZE
93
+ import vn.momo.kits.layout.HEADER_TITLE_GAP
89
94
  import vn.momo.kits.layout.getScreenLayout
95
+ import vn.momo.kits.layout.rememberHeaderLayout
90
96
  import kotlin.time.Clock
91
97
  import kotlin.time.Duration.Companion.milliseconds
92
98
  import kotlin.time.ExperimentalTime
@@ -371,12 +377,24 @@ internal fun ScreenContent(content: @Composable () -> Unit, insetContent: Boolea
371
377
 
372
378
  if (options.headerType is HeaderType.Animated) {
373
379
  val animatedHeader = options.headerType
380
+ val isWide = rememberHeaderLayout(options.contentLayout).isWide
374
381
  Box {
382
+ // wide windows keep the phone banner size, centered over a fill fading down from bannerBackgroundColor
383
+ val bannerWidth = if (isWide) Modifier.width(HEADER_BANNER_WIDTH) else Modifier.fillMaxWidth()
375
384
  val bannerModifier = animatedHeader.height
376
- ?.let { Modifier.fillMaxWidth().height(it) }
377
- ?: Modifier.fillMaxWidth().aspectRatio(animatedHeader.aspectRatio.value)
378
- Box(bannerModifier) {
379
- animatedHeader.composable.invoke(scrollState.value)
385
+ ?.let { bannerWidth.height(it) }
386
+ ?: bannerWidth.aspectRatio(animatedHeader.aspectRatio.value)
387
+ Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.TopCenter) {
388
+ val fill = animatedHeader.bannerBackgroundColor
389
+ if (isWide && fill != null) {
390
+ Box(
391
+ Modifier.matchParentSize()
392
+ .background(Brush.verticalGradient(listOf(fill, fill.copy(alpha = 0f))))
393
+ )
394
+ }
395
+ Box(bannerModifier) {
396
+ animatedHeader.composable.invoke(scrollState.value)
397
+ }
380
398
  }
381
399
  Box(
382
400
  Modifier
@@ -511,15 +529,17 @@ internal fun SearchAnimated(
511
529
  val maxTopPadding = screenLayout.headerHeight
512
530
  // collapsed on the iPhone Duo status bar row, the search stays between its clusters (48pt back there)
513
531
  val clearance = screenLayout.statusBarClearance
514
- val backWidth = if (clearance != null && !useSideBar) DuoMetrics.controlSize else 28.dp
515
- val minStartPadding = Spacing.M
532
+ val backWidth = if (clearance != null && !useSideBar) DuoMetrics.controlSize else HEADER_BUTTON_SIZE
533
+ // stretch screens on wide windows keep the search in the header's centered frame
534
+ val sidePadding = rememberHeaderLayout(options.contentLayout).frameInset
535
+ val minStartPadding = sidePadding
516
536
  val maxStartPadding = (clearance?.left ?: 0.dp) +
517
- if (options.hiddenBack || useSideBar) Spacing.M else backWidth + Spacing.M + Spacing.S
518
- val minEndPadding = Spacing.M
537
+ if (options.hiddenBack || useSideBar) sidePadding else backWidth + sidePadding + HEADER_TITLE_GAP
538
+ val minEndPadding = sidePadding
519
539
  val maxEndPadding = (clearance?.right ?: 0.dp) + when {
520
- options.headerRight is HeaderRight.None -> Spacing.M
521
- useSideBar && options.headerRight is HeaderRight.Toolkit -> Spacing.M
522
- else -> headerRightWidthDp + Spacing.M * 2
540
+ options.headerRight is HeaderRight.None -> sidePadding
541
+ useSideBar && options.headerRight is HeaderRight.Toolkit -> sidePadding
542
+ else -> headerRightWidthDp + sidePadding + Spacing.M
523
543
  }
524
544
 
525
545
  val targetColor = lerp(
@@ -580,7 +600,8 @@ internal fun SearchAnimated(
580
600
  onPressButtonText = {
581
601
  navigator.pop()
582
602
  }
583
- )
603
+ ),
604
+ size = InputSearchSize.Header,
584
605
  )
585
606
  }
586
607
  }
@@ -139,19 +139,10 @@ internal fun HorizontalTabBar(
139
139
  }
140
140
  }
141
141
  }
142
- cta?.let { CenterAction(it, Modifier.align(Alignment.TopCenter).offset(y = centerActionTop())) }
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
@@ -43,7 +43,12 @@ import vn.momo.kits.components.PopupNotifyProps
43
43
  import vn.momo.kits.application.IsShowBaseLineDebug
44
44
  import vn.momo.kits.const.Spacing
45
45
  import vn.momo.kits.layout.DuoMetrics
46
+ import vn.momo.kits.layout.HEADER_BUTTON_SIZE
47
+ import vn.momo.kits.layout.HEADER_CLUSTER_WIDTH
48
+ import vn.momo.kits.layout.HEADER_ICON_SIZE
49
+ import vn.momo.kits.layout.HEADER_TITLE_GAP
46
50
  import vn.momo.kits.layout.getScreenLayout
51
+ import vn.momo.kits.layout.rememberHeaderLayout
47
52
  import vn.momo.kits.modifier.activeOpacityClickable
48
53
  import vn.momo.kits.modifier.conditional
49
54
  import vn.momo.kits.modifier.setAutomationId
@@ -60,10 +65,11 @@ const val HEADER_HEIGHT = 52
60
65
  internal enum class InputSearchType { None, Header, Animated }
61
66
  enum class TitlePosition { LEFT, CENTER }
62
67
 
63
- private val HEADER_ACTIONS_WIDTH = 172.dp
68
+ // back, the gaps around the title and the right cluster
69
+ private val HEADER_ACTIONS_WIDTH = HEADER_BUTTON_SIZE + HEADER_TITLE_GAP * 2 + HEADER_CLUSTER_WIDTH
64
70
 
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
71
+ // Side padding, 48pt back and toolkit on the iPhone Duo status bar row.
72
+ private val STATUS_BAR_ROW_ACTIONS_WIDTH = 227.dp
67
73
 
68
74
  @Suppress("FrequentlyChangingValue")
69
75
  @Composable
@@ -91,7 +97,8 @@ internal fun headerTitleMaxWidth(): Dp {
91
97
  val clearance = layout.statusBarClearance
92
98
  val clearanceWidth = clearance?.let { it.left + it.right } ?: 0.dp
93
99
  if (layout.sideBar != null) return layout.contentWidth - Spacing.M * 2 - clearanceWidth
94
- return layout.width - HEADER_ACTIONS_WIDTH - (if (clearance != null) STATUS_BAR_ROW_ACTIONS_EXTRA else 0.dp) - clearanceWidth
100
+ if (clearance != null) return layout.width - STATUS_BAR_ROW_ACTIONS_WIDTH - clearanceWidth
101
+ return rememberHeaderLayout(LocalOptions.current.contentLayout).frameWidth - HEADER_ACTIONS_WIDTH
95
102
  }
96
103
 
97
104
  // Scroll distance over which the Duo glass bar fades in.
@@ -124,6 +131,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
124
131
  val headerRightWidthPx = LocalHeaderRightWidthPx.current
125
132
  val inputSearchType = getInputSearchType(options)
126
133
  val layout = getScreenLayout()
134
+ val headerLayout = rememberHeaderLayout(options.contentLayout)
127
135
  val useSideBar = layout.sideBar != null
128
136
  // iPhone Duo inner portrait: the row sits on the status bar, between its clusters
129
137
  val clearance = layout.statusBarClearance
@@ -186,8 +194,8 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
186
194
  .fillMaxWidth()
187
195
  .horizontalSafeAreaPadding()
188
196
  .padding(
189
- start = Spacing.M + (clearance?.left ?: 0.dp),
190
- end = Spacing.M + (clearance?.right ?: 0.dp),
197
+ start = headerLayout.frameInset + (clearance?.left ?: 0.dp),
198
+ end = headerLayout.frameInset + (clearance?.right ?: 0.dp),
191
199
  ),
192
200
  verticalAlignment = Alignment.CenterVertically,
193
201
  horizontalArrangement = Arrangement.SpaceBetween
@@ -210,7 +218,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
210
218
  }
211
219
  )
212
220
  }
213
- Spacer(Modifier.width(Spacing.S))
221
+ Spacer(Modifier.width(HEADER_TITLE_GAP))
214
222
  }
215
223
 
216
224
  if (centerTitle) {
@@ -255,7 +263,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
255
263
  modifier = Modifier.height(layout.headerBarHeight)
256
264
  .fillMaxWidth()
257
265
  .horizontalSafeAreaPadding()
258
- .padding(horizontal = Spacing.M + centerInset),
266
+ .padding(horizontal = headerLayout.frameInset + centerInset),
259
267
  contentAlignment = Alignment.Center
260
268
  ) {
261
269
  HeaderContent(
@@ -275,7 +283,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
275
283
  private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
276
284
  Box(
277
285
  modifier = Modifier
278
- .size(28.dp)
286
+ .size(HEADER_BUTTON_SIZE)
279
287
  .background(backgroundButton, RoundedCornerShape(100))
280
288
  .border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
281
289
  .activeOpacityClickable(onClick = onBackHandler)
@@ -286,7 +294,7 @@ private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColo
286
294
  Icon(
287
295
  source = "arrow-back",
288
296
  color = tintIconColor,
289
- size = 20.dp,
297
+ size = HEADER_ICON_SIZE,
290
298
  )
291
299
  }
292
300
  }
@@ -406,7 +414,9 @@ sealed class HeaderType {
406
414
  val isSurface: Boolean = true,
407
415
  val layoutOffSet: Dp = 56.dp,
408
416
  val height: Dp? = null,
409
- val composable: @Composable (scrollState: Int) -> Unit = {}
417
+ val composable: @Composable (scrollState: Int) -> Unit = {},
418
+ // Wide windows: fills the sides of the phone-sized banner, fading out downward.
419
+ val bannerBackgroundColor: Color? = null,
410
420
  ) : HeaderType()
411
421
 
412
422
  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
@@ -225,18 +230,14 @@ internal fun Toolkit(
225
230
  horizontalArrangement = Arrangement.Center,
226
231
  modifier = Modifier
227
232
  .padding(start = Spacing.S)
228
- .border(0.2.dp, headerColor.borderColor, shape = RoundedCornerShape(14.dp))
229
- .height(28.dp)
230
- .clip(shape = RoundedCornerShape(14.dp))
233
+ .border(0.2.dp, headerColor.borderColor, shape = PILL_SHAPE)
234
+ .height(HEADER_BUTTON_SIZE)
235
+ .width(if (useHelpCenter) HEADER_PILL_WIDTH else HEADER_BUTTON_SIZE)
236
+ .clip(shape = PILL_SHAPE)
231
237
  .background(headerColor.backgroundButton)
232
238
  ) {
233
239
  if (useHelpCenter) {
234
- Icon(
235
- source = "help_center",
236
- size = 20.dp,
237
- color = headerColor.tintIconColor,
238
- modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressHelpCenter)
239
- )
240
+ PillItem(icon = "help_center", headerColor = headerColor, onClick = ::onPressHelpCenter)
240
241
  Box(
241
242
  modifier = Modifier
242
243
  .width(0.5.dp)
@@ -244,17 +245,23 @@ internal fun Toolkit(
244
245
  .background(tintColor ?: Colors.black_20)
245
246
  )
246
247
  }
247
- Icon(
248
- source = closeIcon,
249
- size = 20.dp,
250
- color = headerColor.tintIconColor,
251
- modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressClose)
252
- )
248
+ PillItem(icon = closeIcon, headerColor = headerColor, onClick = ::onPressClose)
253
249
  }
254
250
  }
255
251
  }
256
252
 
253
+ private val PILL_SHAPE = RoundedCornerShape(percent = 50)
257
254
 
255
+ // One half of the help / home pill; each half takes an equal share of the pill width.
256
+ @Composable
257
+ private fun RowScope.PillItem(icon: String, headerColor: HeaderColor, onClick: () -> Unit) {
258
+ Box(
259
+ modifier = Modifier.weight(1f).fillMaxHeight().activeOpacityClickable(onClick = onClick),
260
+ contentAlignment = Alignment.Center,
261
+ ) {
262
+ Icon(source = icon, size = HEADER_ICON_SIZE, color = headerColor.tintIconColor)
263
+ }
264
+ }
258
265
 
259
266
  // Colors follow the enclosing header, so it fits a `HeaderRight.Custom` next to the toolkit.
260
267
  @Composable
@@ -286,7 +293,7 @@ internal fun NavigationButton(
286
293
  ) {
287
294
  Box(
288
295
  modifier = modifier
289
- .size(28.dp)
296
+ .size(HEADER_BUTTON_SIZE)
290
297
  .activeOpacityClickable(enabled = !disabled, onClick = onClick)
291
298
  ) {
292
299
  Box(
@@ -302,7 +309,7 @@ internal fun NavigationButton(
302
309
  ) {
303
310
  Icon(
304
311
  source = icon,
305
- size = 20.dp,
312
+ size = HEADER_ICON_SIZE,
306
313
  color = headerColor.tintIconColor
307
314
  )
308
315
  }
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.169.8-beta.3
21
+ version=0.169.8-beta.4
22
22
 
23
23
  repo=GitLab
24
24
  url=https://artifacts.mservice.com.vn/repository/maven-momo-app/
@@ -1,5 +1,13 @@
1
1
  import SwiftUI
2
2
 
3
+ /// Body searches keep 36 / 24; the header search matches the 32pt header buttons.
4
+ enum InputSearchSize {
5
+ case `default`, header
6
+
7
+ var height: CGFloat { self == .header ? HeaderLayoutMetrics.searchHeight : 36 }
8
+ var iconSize: CGFloat { self == .header ? HeaderLayoutMetrics.iconSize : 24 }
9
+ }
10
+
3
11
  // MARK: - RenderRightIconSearch
4
12
 
5
13
  struct RenderRightIconSearch: View {
@@ -7,6 +15,7 @@ struct RenderRightIconSearch: View {
7
15
  let loading: Bool
8
16
  let icon: String
9
17
  let color: Color
18
+ var size: InputSearchSize = .default
10
19
  let onClick: () -> Void
11
20
 
12
21
  var body: some View {
@@ -17,13 +26,13 @@ struct RenderRightIconSearch: View {
17
26
  .padding(.horizontal, Spacing.S)
18
27
  }
19
28
  if !icon.isEmpty {
20
- // Compose: a 1pt rule inset S from the top and bottom of the 36pt bar.
29
+ // Compose: a 1pt rule inset S from the top and bottom of the bar.
21
30
  Rectangle()
22
31
  .fill(theme.colors.primary)
23
- .frame(width: 1, height: 36 - Spacing.S * 2)
32
+ .frame(width: 1, height: size.height - Spacing.S * 2)
24
33
  .padding(.leading, Spacing.S)
25
34
 
26
- Icon(source: icon, size: 24, color: color)
35
+ Icon(source: icon, size: size.iconSize, color: color)
27
36
  .padding(.leading, Spacing.S)
28
37
  .onTapGesture(perform: onClick)
29
38
  }
@@ -137,6 +146,7 @@ public struct InputSearch: View {
137
146
  var clearCondition: (() -> Bool)? = nil
138
147
  var onClearPress: () -> Void = {}
139
148
  var onSubmit: () -> Void = {}
149
+ var size: InputSearchSize = .default
140
150
 
141
151
  @State private var isFocused = false
142
152
  @State private var isBlurred = false
@@ -226,7 +236,7 @@ public struct InputSearch: View {
226
236
  if let searchIcon = searchIcon {
227
237
  searchIcon()
228
238
  } else {
229
- Icon(source: "navigation_search", size: 24, color: theme.colors.text.hint)
239
+ Icon(source: "navigation_search", size: size.iconSize, color: theme.colors.text.hint)
230
240
  .padding(.trailing, Spacing.XS)
231
241
  }
232
242
 
@@ -275,11 +285,11 @@ public struct InputSearch: View {
275
285
  .padding(.leading, Spacing.XS)
276
286
  }
277
287
 
278
- RenderRightIconSearch(loading: loading, icon: icon, color: iconColor, onClick: onRightIconPressed)
288
+ RenderRightIconSearch(loading: loading, icon: icon, color: iconColor, size: size, onClick: onRightIconPressed)
279
289
  }
280
290
  .padding(.horizontal, Spacing.M)
281
291
  .frame(maxWidth: .infinity, alignment: .leading)
282
- .frame(height: 36)
292
+ .frame(height: size.height)
283
293
  .background(
284
294
  RoundedRectangle(cornerRadius: Radius.XL)
285
295
  .fill(backgroundColor ?? theme.colors.background.surface)
@@ -298,6 +308,13 @@ public struct InputSearch: View {
298
308
  }
299
309
  }
300
310
 
311
+ /// The header search: 32pt tall with a 20pt icon, level with the header buttons.
312
+ func headerSize() -> InputSearch {
313
+ var copy = self
314
+ copy.size = .header
315
+ return copy
316
+ }
317
+
301
318
  // MARK: - Helper Functions
302
319
 
303
320
  func getBorderColor(isFocused: Bool, error: String, disabled: Bool) -> Color {
@@ -0,0 +1,60 @@
1
+ // Top navigation spec (Figma "Top Navigation · Màn hình gập"). Mirrors Compose `layout/HeaderLayout.kt`
2
+ // and RN; keep the three in sync.
3
+
4
+ import SwiftUI
5
+
6
+ /// Header spec values, in points. Public so custom header rights and extensions can match them.
7
+ public enum HeaderLayoutMetrics {
8
+ public static let buttonSize: CGFloat = 32
9
+ public static let iconSize: CGFloat = 20
10
+ public static let pillWidth: CGFloat = 72
11
+ public static let searchHeight: CGFloat = 32
12
+ public static let titleGap: CGFloat = Spacing.S
13
+ public static let sidePadding: CGFloat = Spacing.M
14
+ /// shortcut + gap + help/home pill
15
+ public static let clusterWidth: CGFloat = buttonSize + titleGap + pillWidth
16
+ public static let frameMaxWidth: CGFloat = 600
17
+ /// Banner image width on every device: wide windows keep the phone size, centered.
18
+ public static let bannerWidth: CGFloat = 375
19
+ }
20
+
21
+ /// How a screen lays out its content on wide windows; the header row follows it.
22
+ public enum ContentLayout: Equatable {
23
+ /// 12 column grid: the header keeps the 12pt side padding.
24
+ case grid
25
+ /// One column of at most `HeaderLayoutMetrics.frameMaxWidth`, centered: the header row sits in the same frame.
26
+ case stretch
27
+ }
28
+
29
+ /// Header geometry for a window; see `ScreenLayout.headerLayout(_:)`.
30
+ public struct HeaderLayout: Equatable {
31
+ /// Short side >= 600, iPhone Duo excluded (it has its own layout).
32
+ public let isWide: Bool
33
+ /// Padding from each side of the safe area to the header row (back, title / search, right cluster).
34
+ public let frameInset: CGFloat
35
+ /// Width of the header row, so tabs and other header extensions can line up with it.
36
+ public let frameWidth: CGFloat
37
+ }
38
+
39
+ public extension ScreenLayout {
40
+ func headerLayout(_ contentLayout: ContentLayout = .grid) -> HeaderLayout {
41
+ let isWide = !isIPhoneDuo && !isDuoDevice && min(width, height) >= ModalMetrics.foldableMinWidth
42
+ let safeWidth = width - insets.leading - insets.trailing
43
+ let frameInset = isWide && contentLayout == .stretch
44
+ ? max(HeaderLayoutMetrics.sidePadding, (safeWidth - HeaderLayoutMetrics.frameMaxWidth) / 2)
45
+ : HeaderLayoutMetrics.sidePadding
46
+ return HeaderLayout(isWide: isWide, frameInset: frameInset, frameWidth: safeWidth - frameInset * 2)
47
+ }
48
+ }
49
+
50
+ private struct ContentLayoutKey: EnvironmentKey {
51
+ static let defaultValue: ContentLayout = .grid
52
+ }
53
+
54
+ public extension EnvironmentValues {
55
+ /// The enclosing screen's `NavigationOptions.contentLayout`, set by `StackScreen`.
56
+ var contentLayout: ContentLayout {
57
+ get { self[ContentLayoutKey.self] }
58
+ set { self[ContentLayoutKey.self] = newValue }
59
+ }
60
+ }
@@ -166,19 +166,10 @@ struct HorizontalTabBar: View {
166
166
 
167
167
  if let cta {
168
168
  CenterAction(data: cta)
169
- .offset(y: centerActionTop)
170
169
  }
171
170
  }
172
171
  .frame(width: width)
173
172
  }
174
-
175
- /// Offset of the center action column from the bar top: the items sit at the top of the container
176
- /// (which starts ctaLift down), so the column is placed for its label to start on the tab labels' line.
177
- private var centerActionTop: CGFloat {
178
- let itemLabelTop = TabBarMetrics.ctaLift + TabBarMetrics.paddingVertical
179
- + TabBarMetrics.indicatorHeight + TabBarMetrics.itemIconLabelGap
180
- return itemLabelTop - TabBarMetrics.ctaLabelGap - TabBarMetrics.ctaSize
181
- }
182
173
  }
183
174
 
184
175
  /// One active indicator per bar: Background/tonal with its inner light (white 12% from below) and
@@ -6,10 +6,11 @@ import SwiftUI
6
6
  /// Header bar height, mirrors Compose's `HEADER_HEIGHT`.
7
7
  public let HEADER_HEIGHT: CGFloat = 52
8
8
 
9
- /// Room the back button and toolkit take from the bar (Compose `HEADER_ACTIONS_WIDTH`).
10
- let headerActionsWidth: CGFloat = 172
11
- // Extra width the 48pt back and toolkit take on the iPhone Duo status bar row.
12
- private let statusBarRowActionsExtra: CGFloat = 55
9
+ /// Room the back button, the gaps around the title and the right cluster take from the header row
10
+ /// (Compose `HEADER_ACTIONS_WIDTH`).
11
+ let headerActionsWidth: CGFloat = HeaderLayoutMetrics.buttonSize + HeaderLayoutMetrics.titleGap * 2 + HeaderLayoutMetrics.clusterWidth
12
+ // Side padding, 48pt back and toolkit on the iPhone Duo status bar row.
13
+ private let statusBarRowActionsWidth: CGFloat = 227
13
14
 
14
15
  public enum TitlePosition {
15
16
  case left, center
@@ -24,15 +25,19 @@ public struct AnimatedHeader {
24
25
  public var aspectRatio: AnimatedHeaderRatio = .ratio16_9
25
26
  public var isSurface: Bool = true
26
27
  public var composable: (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
28
+ /// Wide windows: fills the sides of the phone-sized banner, fading out downward.
29
+ public var bannerBackgroundColor: Color?
27
30
 
28
31
  public init(
29
32
  aspectRatio: AnimatedHeaderRatio = .ratio16_9,
30
33
  isSurface: Bool = true,
31
- composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
34
+ composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) },
35
+ bannerBackgroundColor: Color? = nil
32
36
  ) {
33
37
  self.aspectRatio = aspectRatio
34
38
  self.isSurface = isSurface
35
39
  self.composable = composable
40
+ self.bannerBackgroundColor = bannerBackgroundColor
36
41
  }
37
42
  }
38
43
 
@@ -286,10 +291,11 @@ func headerSearchProps(
286
291
  }
287
292
 
288
293
  /// Max title width: back button and toolkit share the bar unless the iPhone Duo side bar holds them.
289
- func headerTitleMaxWidth(_ layout: ScreenLayout) -> CGFloat {
294
+ func headerTitleMaxWidth(_ layout: ScreenLayout, _ contentLayout: ContentLayout) -> CGFloat {
290
295
  let clearance = layout.statusBarClearance.map { $0.left + $0.right } ?? 0
291
296
  if layout.sideBar != nil { return layout.contentWidth - Spacing.M * 2 - clearance }
292
- return layout.width - headerActionsWidth - (layout.statusBarClearance != nil ? statusBarRowActionsExtra : 0) - clearance
297
+ if layout.statusBarClearance != nil { return layout.width - statusBarRowActionsWidth - clearance }
298
+ return layout.headerLayout(contentLayout).frameWidth - headerActionsWidth
293
299
  }
294
300
 
295
301
  // MARK: - Header
@@ -339,10 +345,13 @@ public struct NavigationHeader: View {
339
345
  }
340
346
 
341
347
  @Environment(\.screenLayout) private var layout
348
+ @Environment(\.contentLayout) private var contentLayout
342
349
  @Environment(\.appTheme) private var theme
343
350
  @OptionalEnvironmentObject private var navigator: Navigator?
344
351
  @State private var headerRightWidth: CGFloat = 0
345
352
 
353
+ private var headerLayout: HeaderLayout { layout.headerLayout(contentLayout) }
354
+
346
355
  /// iPhone Duo side bar holds back and the toolkit; a custom header right stays in the bar.
347
356
  private var useSideBar: Bool { layout.sideBar != nil }
348
357
 
@@ -352,7 +361,7 @@ public struct NavigationHeader: View {
352
361
  /// Max centered title width; on the status bar row the clusters are lopsided, so both sides
353
362
  /// keep the wider one's room.
354
363
  private var centerTitleMaxWidth: CGFloat {
355
- guard let clearance = layout.statusBarClearance else { return (layout.contentWidth - Spacing.M * 2) / 2 }
364
+ guard let clearance = layout.statusBarClearance else { return headerLayout.frameWidth / 2 }
356
365
  let back = goBack == nil || useSideBar ? 0 : DuoMetrics.controlSize + Spacing.S
357
366
  let inset = max(clearance.left + back, clearance.right + headerRightWidth) + Spacing.S
358
367
  return max(layout.contentWidth - (Spacing.M + inset) * 2, 0)
@@ -388,7 +397,7 @@ public struct NavigationHeader: View {
388
397
  } else {
389
398
  BackButton(color: headerColor, onBack: goBack)
390
399
  }
391
- Spacer().frame(width: Spacing.S)
400
+ Spacer().frame(width: HeaderLayoutMetrics.titleGap)
392
401
  }
393
402
 
394
403
  if centerTitle {
@@ -418,14 +427,14 @@ public struct NavigationHeader: View {
418
427
  )
419
428
  }
420
429
  }
421
- .padding(.leading, Spacing.M + (layout.statusBarClearance?.left ?? 0))
422
- .padding(.trailing, Spacing.M + (layout.statusBarClearance?.right ?? 0))
430
+ .padding(.leading, headerLayout.frameInset + (layout.statusBarClearance?.left ?? 0))
431
+ .padding(.trailing, headerLayout.frameInset + (layout.statusBarClearance?.right ?? 0))
423
432
 
424
433
  if centerTitle {
425
434
  titleArea(centered: true)
426
435
  // Compose caps a centered title at half the bar
427
436
  .frame(maxWidth: centerTitleMaxWidth)
428
- .padding(.horizontal, Spacing.M)
437
+ .padding(.horizontal, headerLayout.frameInset)
429
438
  }
430
439
  }
431
440
  .onPreferenceChange(HeaderRightWidthKey.self) { headerRightWidth = $0 }
@@ -448,6 +457,7 @@ public struct NavigationHeader: View {
448
457
  theme: theme,
449
458
  pop: navigator.map { navigator in { navigator.pop() } }
450
459
  ))
460
+ .headerSize()
451
461
  } else {
452
462
  switch headerTitle {
453
463
  case let .user(data)?:
@@ -501,7 +511,7 @@ struct HeaderBarBackground: View {
501
511
 
502
512
  // MARK: - Back button
503
513
 
504
- /// Mirrors Compose's `BackButton`: a 28pt circle with the back arrow.
514
+ /// Mirrors Compose's `BackButton`: a 32pt circle with the back arrow.
505
515
  private struct BackButton: View {
506
516
  let color: HeaderColor
507
517
  let onBack: () -> Void
@@ -511,8 +521,8 @@ private struct BackButton: View {
511
521
  Circle()
512
522
  .fill(color.backgroundButton)
513
523
  .overlay(Circle().stroke(color.borderColor, lineWidth: 0.2))
514
- .frame(width: 28, height: 28)
515
- .overlay(Icon(source: "arrow-back", size: 20, color: color.tintIconColor))
524
+ .frame(width: HeaderLayoutMetrics.buttonSize, height: HeaderLayoutMetrics.buttonSize)
525
+ .overlay(Icon(source: "arrow-back", size: HeaderLayoutMetrics.iconSize, color: color.tintIconColor))
516
526
  }
517
527
  .buttonStyle(ActiveOpacityButtonStyle())
518
528
  .accessibilityIdentifier("btn_navigation_back")
@@ -13,6 +13,7 @@ public struct HeaderJourneyView: View {
13
13
  }
14
14
 
15
15
  @Environment(\.screenLayout) private var layout
16
+ @Environment(\.contentLayout) private var contentLayout
16
17
 
17
18
  public var body: some View {
18
19
  if data.isLoading {
@@ -45,7 +46,7 @@ public struct HeaderJourneyView: View {
45
46
  MomoText(description, typography: .descriptionXsRegular, color: tint, maxLines: 1)
46
47
  }
47
48
  }
48
- .frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
49
+ .frame(maxWidth: headerTitleMaxWidth(layout, contentLayout), alignment: .leading)
49
50
  }
50
51
  .buttonStyle(ActiveOpacityButtonStyle())
51
52
  .disabled(data.onPress == nil)
@@ -13,6 +13,7 @@ public struct HeaderLocationView: View {
13
13
  }
14
14
 
15
15
  @Environment(\.screenLayout) private var layout
16
+ @Environment(\.contentLayout) private var contentLayout
16
17
 
17
18
  public var body: some View {
18
19
  if data.isLoading {
@@ -34,7 +35,7 @@ public struct HeaderLocationView: View {
34
35
  Icon(source: "16_arrow_chevron_down_small", size: 16, color: tint)
35
36
  }
36
37
  }
37
- .frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
38
+ .frame(maxWidth: headerTitleMaxWidth(layout, contentLayout), alignment: .leading)
38
39
  }
39
40
  .buttonStyle(ActiveOpacityButtonStyle())
40
41
  .disabled(data.onPress == nil)
@@ -354,25 +354,30 @@ struct Toolkit: View {
354
354
  }
355
355
  toolButton(icon: headerRight.closeIcon, accessibilityId: "btn_navigation_close", action: onPressClose)
356
356
  }
357
- .frame(width: usesHelpCenter(context) ? 65 : 28, height: 28)
357
+ .frame(
358
+ width: usesHelpCenter(context) ? HeaderLayoutMetrics.pillWidth : HeaderLayoutMetrics.buttonSize,
359
+ height: HeaderLayoutMetrics.buttonSize
360
+ )
358
361
  .background(headerColor.backgroundButton)
359
- .cornerRadius(14)
360
- .overlay(RoundedRectangle(cornerRadius: 14).stroke(headerColor.borderColor, lineWidth: 0.2))
362
+ .clipShape(Capsule())
363
+ .overlay(Capsule().stroke(headerColor.borderColor, lineWidth: 0.2))
361
364
  .padding(.leading, Spacing.S)
362
365
  }
363
366
  }
364
367
 
368
+ /// One half of the help / home pill; each half takes an equal share of the pill width.
365
369
  private func toolButton(icon: String, accessibilityId: String, action: @escaping () -> Void) -> some View {
366
370
  SwiftUI.Button(action: action) {
367
- Icon(source: icon, size: 20, color: headerColor.tintIconColor)
368
- .padding(4)
371
+ Icon(source: icon, size: HeaderLayoutMetrics.iconSize, color: headerColor.tintIconColor)
372
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
373
+ .contentShape(Rectangle())
369
374
  }
370
375
  .buttonStyle(ActiveOpacityButtonStyle())
371
376
  .accessibilityIdentifier(accessibilityId)
372
377
  }
373
378
  }
374
379
 
375
- /// Mirrors Compose's `NavigationButton`: the 28pt circular shortcut / more button.
380
+ /// Mirrors Compose's `NavigationButton`: the 32pt circular shortcut / more button.
376
381
  public struct NavigationButton: View {
377
382
  var disabled: Bool
378
383
  var icon: String
@@ -405,9 +410,9 @@ public struct NavigationButton: View {
405
410
  Circle()
406
411
  .fill(colors.backgroundButton)
407
412
  .overlay(Circle().stroke(colors.borderColor, lineWidth: 0.2))
408
- Icon(source: icon, size: 20, color: colors.tintIconColor)
413
+ Icon(source: icon, size: HeaderLayoutMetrics.iconSize, color: colors.tintIconColor)
409
414
  }
410
- .frame(width: 28, height: 28)
415
+ .frame(width: HeaderLayoutMetrics.buttonSize, height: HeaderLayoutMetrics.buttonSize)
411
416
  .overlay(alignment: .topTrailing) {
412
417
  if showBadge {
413
418
  BadgeDot(size: .small).offset(x: -Spacing.XXS, y: -Spacing.XXS)
@@ -13,6 +13,7 @@ public struct HeaderUserView: View {
13
13
  private let avatarSize: CGFloat = Spacing.XXL // 32
14
14
 
15
15
  @Environment(\.screenLayout) private var layout
16
+ @Environment(\.contentLayout) private var contentLayout
16
17
 
17
18
  public var body: some View {
18
19
  if data.isLoading {
@@ -67,7 +68,7 @@ public struct HeaderUserView: View {
67
68
  }
68
69
  }
69
70
  }
70
- .frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
71
+ .frame(maxWidth: headerTitleMaxWidth(layout, contentLayout), alignment: .leading)
71
72
 
72
73
  Spacer(minLength: 0)
73
74
  }
@@ -14,9 +14,6 @@ public final class Navigation: ObservableObject {
14
14
  private weak var registry: DynamicScreenRegistry?
15
15
  /// What the footer (or navigation bar) takes from the window bottom; lifts snack bars.
16
16
  var bottomObstruction: CGFloat = 0
17
- /// A tab that pads itself asks (via `floatingTabBarEdgeToEdge()`) to run edge to edge behind the floating
18
- /// bar and the home indicator; the kit then stops reserving that space. Compose's `bottomTabEdgeToEdge`.
19
- @Published var bottomTabEdgeToEdge = false
20
17
 
21
18
  init(
22
19
  id: Int = -1,
@@ -87,6 +84,8 @@ public struct NavigationOptions {
87
84
  public var inputSearchProps: InputSearchProps?
88
85
  public var fabProps: FabProps?
89
86
  public var onBackHandler: (() -> Void)?
87
+ /// Wide windows: `.stretch` puts the header row in the centered 600pt content frame.
88
+ public var contentLayout: ContentLayout
90
89
 
91
90
  public init(
92
91
  screenName: String? = nil,
@@ -115,7 +114,8 @@ public struct NavigationOptions {
115
114
  layoutOffset: CGFloat = 56,
116
115
  inputSearchProps: InputSearchProps? = nil,
117
116
  fabProps: FabProps? = nil,
118
- onBackHandler: (() -> Void)? = nil
117
+ onBackHandler: (() -> Void)? = nil,
118
+ contentLayout: ContentLayout = .grid
119
119
  ) {
120
120
  self.screenName = screenName
121
121
  self.title = title
@@ -144,6 +144,7 @@ public struct NavigationOptions {
144
144
  self.inputSearchProps = inputSearchProps
145
145
  self.fabProps = fabProps
146
146
  self.onBackHandler = onBackHandler
147
+ self.contentLayout = contentLayout
147
148
  }
148
149
  }
149
150
 
@@ -187,30 +188,9 @@ struct OptionsStackScreen: View {
187
188
  layoutOffset: options.layoutOffset,
188
189
  inputSearchProps: options.inputSearchProps,
189
190
  fabProps: options.fabProps,
191
+ contentLayout: options.contentLayout,
190
192
  screenName: screenName,
191
193
  content: content
192
194
  )
193
195
  }
194
196
  }
195
-
196
- // MARK: - Edge-to-edge tab content
197
-
198
- public extension View {
199
- /// Compose's `floatingTabBarContentPadding()`: the content of a `BottomTab` tab runs edge to edge behind
200
- /// the floating tab bar and the home indicator, and pads its own bottom (e.g. a full-screen native view
201
- /// with its own safe area). No effect outside a tab.
202
- func floatingTabBarEdgeToEdge() -> some View {
203
- modifier(FloatingTabBarEdgeToEdge())
204
- }
205
- }
206
-
207
- private struct FloatingTabBarEdgeToEdge: ViewModifier {
208
- @OptionalEnvironmentObject private var navigation: Navigation?
209
-
210
- func body(content: Content) -> some View {
211
- content.onAppear {
212
- guard let navigation, navigation.bottomTabIndex != -1, !navigation.bottomTabEdgeToEdge else { return }
213
- navigation.bottomTabEdgeToEdge = true
214
- }
215
- }
216
- }
@@ -34,6 +34,7 @@ public struct StackScreen<Content: View>: View {
34
34
  var layoutOffset: CGFloat
35
35
  var inputSearchProps: InputSearchProps?
36
36
  var fabProps: FabProps?
37
+ var contentLayout: ContentLayout = .grid
37
38
  var screenName: String = ""
38
39
  var content: () -> Content
39
40
 
@@ -65,6 +66,7 @@ public struct StackScreen<Content: View>: View {
65
66
  layoutOffset: CGFloat = 56,
66
67
  inputSearchProps: InputSearchProps? = nil,
67
68
  fabProps: FabProps? = nil,
69
+ contentLayout: ContentLayout = .grid,
68
70
  screenName: String = "",
69
71
  @ViewBuilder content: @escaping () -> Content
70
72
  ) {
@@ -95,6 +97,7 @@ public struct StackScreen<Content: View>: View {
95
97
  self.layoutOffset = layoutOffset
96
98
  self.inputSearchProps = inputSearchProps
97
99
  self.fabProps = fabProps
100
+ self.contentLayout = contentLayout
98
101
  self.screenName = screenName
99
102
  self.content = content
100
103
  }
@@ -161,16 +164,6 @@ public struct StackScreen<Content: View>: View {
161
164
  && inputSearchProps == nil && !headerTransparent && !fullScreenContent
162
165
  }
163
166
 
164
- /// Bottom room for the tab's content: clear of the floating bar, unless the tab runs edge to edge
165
- /// (`floatingTabBarEdgeToEdge()`), when it also covers the home indicator that BottomTab keeps clear of
166
- /// (a negative inset extends the content past the tab's frame).
167
- private var contentBottomInset: CGFloat {
168
- guard let navigation, navigation.bottomTabIndex != -1, navigation.bottomTabEdgeToEdge else {
169
- return duoTabBarInsets.overlay
170
- }
171
- return -layout.insets.bottom
172
- }
173
-
174
167
  /// iPhone Duo: the header leaves with the content and slides back in on a reverse scroll
175
168
  /// (RN DuoQuickReturnHeader). The side bar is drawn apart from the header, so it stays put.
176
169
  private var useQuickReturn: Bool {
@@ -307,6 +300,7 @@ public struct StackScreen<Content: View>: View {
307
300
  }
308
301
  }
309
302
  .ignoresSafeArea(.keyboard, edges: .bottom)
303
+ .environment(\.contentLayout, contentLayout)
310
304
  .onChange(of: scrollOffset) { updateHeaderHide($0) }
311
305
  .onAppear { reportEmptySideBar() }
312
306
  .onChange(of: showsSideBar) { _ in reportEmptySideBar() }
@@ -389,7 +383,7 @@ public struct StackScreen<Content: View>: View {
389
383
  scrollOffset: $scrollOffset,
390
384
  scrollToTopCallback: scrollToTopCallback,
391
385
  animatedSearchInset: animatedSearchInset,
392
- bottomInset: contentBottomInset,
386
+ bottomInset: duoTabBarInsets.overlay,
393
387
  snapDistance: searchSnapDistance,
394
388
  onScrollIdle: settleHeader,
395
389
  content: { animatedHeroBody(animatedHeader) }
@@ -422,7 +416,7 @@ public struct StackScreen<Content: View>: View {
422
416
  scrollOffset: $scrollOffset,
423
417
  scrollToTopCallback: scrollToTopCallback,
424
418
  animatedSearchInset: animatedSearchInset,
425
- bottomInset: contentBottomInset,
419
+ bottomInset: duoTabBarInsets.overlay,
426
420
  snapDistance: searchSnapDistance,
427
421
  onScrollIdle: settleHeader,
428
422
  content: { duoInsetContent }
@@ -443,7 +437,7 @@ public struct StackScreen<Content: View>: View {
443
437
  scrollOffset: $scrollOffset,
444
438
  scrollToTopCallback: scrollToTopCallback,
445
439
  topInset: layout.headerHeight - layout.insets.top,
446
- bottomInset: contentBottomInset,
440
+ bottomInset: duoTabBarInsets.overlay,
447
441
  snapDistance: searchSnapDistance,
448
442
  onScrollIdle: settleHeader,
449
443
  content: content
@@ -489,7 +483,7 @@ public struct StackScreen<Content: View>: View {
489
483
  scrollOffset: $scrollOffset,
490
484
  scrollToTopCallback: scrollToTopCallback,
491
485
  animatedSearchInset: animatedSearchInset,
492
- bottomInset: contentBottomInset,
486
+ bottomInset: duoTabBarInsets.overlay,
493
487
  snapDistance: searchSnapDistance,
494
488
  onScrollIdle: settleHeader,
495
489
  content: content
@@ -506,18 +500,28 @@ public struct StackScreen<Content: View>: View {
506
500
  }
507
501
 
508
502
  private func heroGlassStart(_ animatedHeader: AnimatedHeader) -> CGFloat {
509
- max(layout.width / animatedHeader.aspectRatio.value - layout.headerHeight, 0)
503
+ max(bannerWidth / animatedHeader.aspectRatio.value - layout.headerHeight, 0)
504
+ }
505
+
506
+ /// Wide windows keep the phone banner size, centered; phones fill the width.
507
+ private var bannerWidth: CGFloat {
508
+ layout.headerLayout(contentLayout).isWide ? HeaderLayoutMetrics.bannerWidth : layout.width
510
509
  }
511
510
 
512
511
  /// The banner fills the width at its aspect ratio; the body starts `layoutOffset` below the
513
- /// header band so it overlaps the banner's lower part.
512
+ /// header band so it overlaps the banner's lower part. On wide windows `bannerBackgroundColor`
513
+ /// fills the sides, fading out downward.
514
514
  @ViewBuilder
515
515
  private func animatedHeroBody(_ animatedHeader: AnimatedHeader) -> some View {
516
- let width = layout.width
516
+ let width = bannerWidth
517
517
  let imageHeight = width / animatedHeader.aspectRatio.value
518
518
  let contentTopInset = layout.headerHeight + layoutOffset
519
519
 
520
520
  ZStack(alignment: .top) {
521
+ if width < layout.width, let fill = animatedHeader.bannerBackgroundColor {
522
+ LinearGradient(colors: [fill, fill.opacity(0)], startPoint: .top, endPoint: .bottom)
523
+ .frame(width: layout.width, height: imageHeight)
524
+ }
521
525
  animatedHeader.composable(scrollOffset)
522
526
  .frame(width: width, height: imageHeight)
523
527
  .clipped()
@@ -571,8 +575,7 @@ private struct StackScreenContent<Content: View>: View {
571
575
  /// Room for a header the content scrolls under (iPhone Duo glass header).
572
576
  var topInset: CGFloat = 0
573
577
  /// Room for the floating tab bar that overlays the content: scrolling content runs under it and
574
- /// ends clear of it, static content stays above it. Negative for an edge-to-edge tab: the content
575
- /// reaches that far past its frame.
578
+ /// ends clear of it, static content stays above it.
576
579
  var bottomInset: CGFloat = 0
577
580
  /// Compose's animated-search snap: a scroll that comes to rest part way through this distance
578
581
  /// finishes the move, up or back down.
@@ -633,8 +636,6 @@ private struct StackScreenContent<Content: View>: View {
633
636
  }
634
637
  }
635
638
  .coordinateSpace(name: scrollSpace)
636
- // an edge-to-edge tab's scroll reaches past its frame, under the home indicator
637
- .padding(.bottom, min(bottomInset, 0))
638
639
  .modifier(ScrollRest(offset: scrollOffset, onRest: scrollDidRest))
639
640
  // Status-bar tap (MoMoStatusBarTap swizzle) scrolls to top and notifies the consumer.
640
641
  .onReceive(NotificationCenter.default.publisher(for: MoMoStatusBarTap.notificationName)) { _ in
@@ -735,6 +736,7 @@ private struct SearchAnimatedHeader: View {
735
736
  var hasToolkit: Bool = false
736
737
 
737
738
  @Environment(\.screenLayout) private var layout
739
+ @Environment(\.contentLayout) private var contentLayout
738
740
  @Environment(\.appTheme) private var theme
739
741
  @OptionalEnvironmentObject private var navigator: Navigator?
740
742
 
@@ -745,14 +747,15 @@ private struct SearchAnimatedHeader: View {
745
747
  let rowTop = layout.headerStatusBarHeight - layout.insets.top
746
748
  let minTop = rowTop + (layout.headerBarHeight - HEADER_HEIGHT) / 2
747
749
  let maxTop = layout.headerHeight - layout.insets.top
748
- let minSide = Spacing.M
750
+ // stretch screens on wide windows keep the search in the header's centered frame
751
+ let minSide = layout.headerLayout(contentLayout).frameInset
749
752
  // collapsed on the iPhone Duo status bar row, the search stays between its clusters (48pt back there)
750
753
  let clearance = layout.statusBarClearance
751
- let backWidth: CGFloat = clearance != nil && !useSideBar ? DuoMetrics.controlSize : 28
752
- let maxStart = (clearance?.left ?? 0) + (hiddenBack || useSideBar ? Spacing.M : backWidth + Spacing.M + Spacing.S)
754
+ let backWidth: CGFloat = clearance != nil && !useSideBar ? DuoMetrics.controlSize : HeaderLayoutMetrics.buttonSize
755
+ let maxStart = (clearance?.left ?? 0) + (hiddenBack || useSideBar ? minSide : backWidth + minSide + HeaderLayoutMetrics.titleGap)
753
756
  let maxEnd = (clearance?.right ?? 0) + (useSideBar && hasToolkit
754
- ? Spacing.M
755
- : headerRightWidth + (hasHeaderRight ? Spacing.M * 2 : Spacing.M))
757
+ ? minSide
758
+ : headerRightWidth + (hasHeaderRight ? minSide + Spacing.M : minSide))
756
759
 
757
760
  // one progress for all three, so the field docks with its final insets and never covers the toolkit
758
761
  let progress = min(scroll / HEADER_HEIGHT, 1)
@@ -768,6 +771,7 @@ private struct SearchAnimatedHeader: View {
768
771
  theme: theme,
769
772
  pop: navigator.map { navigator in { navigator.pop() } }
770
773
  ))
774
+ .headerSize()
771
775
  .frame(height: HEADER_HEIGHT)
772
776
  .padding(.leading, start)
773
777
  .padding(.trailing, end)
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.169.8-beta.3'
3
+ s.version = '0.169.8-beta.4'
4
4
  s.summary = 'MoMoUIKits for iOS'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKitsDemo'
3
- s.version = '0.169.8-beta.3'
3
+ s.version = '0.169.8-beta.4'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -30,6 +30,7 @@ struct AnimatedHeaderDemoContent: View {
30
30
 
31
31
  @State private var ratio: AnimatedHeaderRatio = .ratio16_9
32
32
  @State private var isSurface = true
33
+ @State private var isStretch = true
33
34
 
34
35
  private let imageUrl = "https://static.momocdn.net/app/img/booking/holiday/mid_atumn_dldl.jpeg"
35
36
 
@@ -47,6 +48,11 @@ struct AnimatedHeaderDemoContent: View {
47
48
  MomoText("Surface")
48
49
  }
49
50
 
51
+ // wide windows (short side >= 600): phone-sized banner, sides filled with the banner color
52
+ Toggle(isOn: $isStretch) {
53
+ MomoText("Stretch content layout")
54
+ }
55
+
50
56
  MoMoUIKits.Button(
51
57
  title: "Show Animated Header",
52
58
  action: show,
@@ -63,6 +69,7 @@ struct AnimatedHeaderDemoContent: View {
63
69
  private func show() {
64
70
  let ratio = ratio
65
71
  let isSurface = isSurface
72
+ let contentLayout: ContentLayout = isStretch ? .stretch : .grid
66
73
  let url = imageUrl
67
74
  navigator.push(
68
75
  { AnimatedHeaderTargetScreen(ratio: ratio) },
@@ -77,8 +84,10 @@ struct AnimatedHeaderDemoContent: View {
77
84
  .frame(maxWidth: .infinity, maxHeight: .infinity)
78
85
  .clipped()
79
86
  )
80
- }
81
- )
87
+ },
88
+ bannerBackgroundColor: Colors.pink09
89
+ ),
90
+ contentLayout: contentLayout
82
91
  )
83
92
  )
84
93
  }
@@ -39,8 +39,6 @@ private struct DemoConfig: Hashable {
39
39
  var initialRouteName = "Momo"
40
40
  var compressionBehavior: DuoBarCompressionBehavior = .toolbar
41
41
  var backToInitialTab = true
42
- // a sticky footer in the tab's content body, to check it clears the floating bar
43
- var footer = false
44
42
 
45
43
  var visibleTabs: [TabConfig] { Array(tabs.prefix(tabCount)) }
46
44
  }
@@ -109,10 +107,7 @@ struct BottomTabDemoContent: View {
109
107
  icon: tab.icon,
110
108
  showDot: tab.showDot,
111
109
  badgeLabel: tab.badgeLabel,
112
- options: NavigationOptions(
113
- headerTitle: .default(tab.label),
114
- footer: config.footer ? { AnyView(demoFooter) } : nil
115
- ),
110
+ options: NavigationOptions(headerTitle: .default(tab.label)),
116
111
  screen: { TabContent(name: tab.name, config: $config, focused: $focused) }
117
112
  )
118
113
  },
@@ -129,10 +124,6 @@ struct BottomTabDemoContent: View {
129
124
  .onAppear { ctaLottieLoader.load() }
130
125
  }
131
126
 
132
- private var demoFooter: some View {
133
- MoMoUIKits.Button(title: "Footer trong content", action: {}, isFull: true)
134
- }
135
-
136
127
  private var floatingButton: BottomTabFloatingButton? {
137
128
  guard config.special else { return nil }
138
129
  guard config.ctaLottie else {
@@ -211,9 +202,6 @@ private struct TabContent: View {
211
202
  ])
212
203
  Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
213
204
  options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
214
- Options(title: "footer",
215
- hint: "Footer dính trong content body, kiểm tra nó nằm trên thanh tab nổi",
216
- options: yesNo(config.footer) { config.footer = $0 })
217
205
  }
218
206
 
219
207
  Section(title: "Nút giữa (floatingButton)") {
@@ -273,7 +273,9 @@ private struct HeaderTypesScreen: View {
273
273
 
274
274
  @EnvironmentObject private var navigation: Navigation
275
275
  @Environment(\.applicationEnvironment) private var applicationEnvironment
276
+ @Environment(\.screenLayout) private var layout
276
277
  @State private var kind: AnyHashable = Kind.default
278
+ @State private var contentLayout: AnyHashable = ContentLayout.grid
277
279
  @State private var titlePosition: AnyHashable = TitlePosition.left
278
280
  @State private var showBack = true
279
281
  @State private var headerRight: AnyHashable = HeaderRightOption.toolkit
@@ -295,6 +297,15 @@ private struct HeaderTypesScreen: View {
295
297
  }, label: position == .left ? "LEFT" : "CENTER")
296
298
  }
297
299
  Divider()
300
+ // stretch only differs on wide windows (short side >= 600, iPhone Duo excluded)
301
+ let headerLayout = layout.headerLayout(contentLayout.base as? ContentLayout ?? .grid)
302
+ MomoText("Content Layout · wide: \(headerLayout.isWide), frame inset: \(Int(headerLayout.frameInset))")
303
+ ForEach([ContentLayout.grid, ContentLayout.stretch], id: \.self) { item in
304
+ Radio(value: item, groupValue: $contentLayout, onChange: {
305
+ navigation.setOptions { $0.contentLayout = item }
306
+ }, label: item == .grid ? "Grid" : "Stretch")
307
+ }
308
+ Divider()
298
309
  Checkbox($showBack, onChange: { checked in
299
310
  navigation.setOptions { $0.hiddenBack = !checked }
300
311
  }, title: "Show Back")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.169.8-beta.3-debug",
3
+ "version": "0.169.8-beta.4-debug",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "publish:local": "bash publish.sh local"