@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.
Files changed (25) 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 +67 -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 +34 -14
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +29 -39
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +28 -29
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +3 -10
  10. package/gradle.properties +1 -1
  11. package/ios/Input/InputSearch.swift +23 -6
  12. package/ios/Layout/HeaderLayout.swift +67 -0
  13. package/ios/Navigation/Component/Header.swift +31 -46
  14. package/ios/Navigation/Component/HeaderJourney.swift +2 -1
  15. package/ios/Navigation/Component/HeaderLocation.swift +2 -1
  16. package/ios/Navigation/Component/HeaderRight.swift +18 -15
  17. package/ios/Navigation/Component/HeaderUser.swift +2 -1
  18. package/ios/Navigation/Component/SideBar.swift +4 -13
  19. package/ios/Navigation/Navigation.swift +6 -1
  20. package/ios/Navigation/StackScreen.swift +28 -11
  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/NavigationDemo.swift +11 -0
  25. package/package.json +1 -1
@@ -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,67 @@
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
+ /// Banner kept at `HeaderLayoutMetrics.bannerWidth`, centered: wide windows plus the iPhone Duo inner display.
34
+ public let isBannerCentered: Bool
35
+ /// Padding from each side of the safe area to the header row (back, title / search, right cluster).
36
+ public let frameInset: CGFloat
37
+ /// Width of the header row, so tabs and other header extensions can line up with it.
38
+ public let frameWidth: CGFloat
39
+ }
40
+
41
+ public extension ScreenLayout {
42
+ func headerLayout(_ contentLayout: ContentLayout = .grid) -> HeaderLayout {
43
+ let isLargeWindow = min(width, height) >= ModalMetrics.foldableMinWidth
44
+ let isWide = !isIPhoneDuo && !isDuoDevice && isLargeWindow
45
+ let safeWidth = width - insets.leading - insets.trailing
46
+ let frameInset = isWide && contentLayout == .stretch
47
+ ? max(HeaderLayoutMetrics.sidePadding, (safeWidth - HeaderLayoutMetrics.frameMaxWidth) / 2)
48
+ : HeaderLayoutMetrics.sidePadding
49
+ return HeaderLayout(
50
+ isWide: isWide,
51
+ isBannerCentered: isLargeWindow,
52
+ frameInset: frameInset,
53
+ frameWidth: safeWidth - frameInset * 2)
54
+ }
55
+ }
56
+
57
+ private struct ContentLayoutKey: EnvironmentKey {
58
+ static let defaultValue: ContentLayout = .grid
59
+ }
60
+
61
+ public extension EnvironmentValues {
62
+ /// The enclosing screen's `NavigationOptions.contentLayout`, set by `StackScreen`.
63
+ var contentLayout: ContentLayout {
64
+ get { self[ContentLayoutKey.self] }
65
+ set { self[ContentLayoutKey.self] = newValue }
66
+ }
67
+ }
@@ -6,10 +6,9 @@ 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
13
12
 
14
13
  public enum TitlePosition {
15
14
  case left, center
@@ -24,15 +23,19 @@ public struct AnimatedHeader {
24
23
  public var aspectRatio: AnimatedHeaderRatio = .ratio16_9
25
24
  public var isSurface: Bool = true
26
25
  public var composable: (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
26
+ /// Wide windows: fills the sides of the phone-sized banner, fading out downward.
27
+ public var bannerBackgroundColor: Color?
27
28
 
28
29
  public init(
29
30
  aspectRatio: AnimatedHeaderRatio = .ratio16_9,
30
31
  isSurface: Bool = true,
31
- composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
32
+ composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) },
33
+ bannerBackgroundColor: Color? = nil
32
34
  ) {
33
35
  self.aspectRatio = aspectRatio
34
36
  self.isSurface = isSurface
35
37
  self.composable = composable
38
+ self.bannerBackgroundColor = bannerBackgroundColor
36
39
  }
37
40
  }
38
41
 
@@ -286,10 +289,10 @@ func headerSearchProps(
286
289
  }
287
290
 
288
291
  /// Max title width: back button and toolkit share the bar unless the iPhone Duo side bar holds them.
289
- func headerTitleMaxWidth(_ layout: ScreenLayout) -> CGFloat {
292
+ func headerTitleMaxWidth(_ layout: ScreenLayout, _ contentLayout: ContentLayout) -> CGFloat {
290
293
  let clearance = layout.statusBarClearance.map { $0.left + $0.right } ?? 0
291
294
  if layout.sideBar != nil { return layout.contentWidth - Spacing.M * 2 - clearance }
292
- return layout.width - headerActionsWidth - (layout.statusBarClearance != nil ? statusBarRowActionsExtra : 0) - clearance
295
+ return layout.headerLayout(contentLayout).frameWidth - headerActionsWidth - clearance
293
296
  }
294
297
 
295
298
  // MARK: - Header
@@ -339,21 +342,21 @@ public struct NavigationHeader: View {
339
342
  }
340
343
 
341
344
  @Environment(\.screenLayout) private var layout
345
+ @Environment(\.contentLayout) private var contentLayout
342
346
  @Environment(\.appTheme) private var theme
343
347
  @OptionalEnvironmentObject private var navigator: Navigator?
344
348
  @State private var headerRightWidth: CGFloat = 0
345
349
 
350
+ private var headerLayout: HeaderLayout { layout.headerLayout(contentLayout) }
351
+
346
352
  /// iPhone Duo side bar holds back and the toolkit; a custom header right stays in the bar.
347
353
  private var useSideBar: Bool { layout.sideBar != nil }
348
354
 
349
- /// iPhone Duo inner portrait: the row sits on the status bar, between its clusters, with 48pt controls.
350
- private var statusBarRow: Bool { layout.statusBarClearance != nil && !useSideBar }
351
-
352
355
  /// Max centered title width; on the status bar row the clusters are lopsided, so both sides
353
356
  /// keep the wider one's room.
354
357
  private var centerTitleMaxWidth: CGFloat {
355
- guard let clearance = layout.statusBarClearance else { return (layout.contentWidth - Spacing.M * 2) / 2 }
356
- let back = goBack == nil || useSideBar ? 0 : DuoMetrics.controlSize + Spacing.S
358
+ guard let clearance = layout.statusBarClearance else { return headerLayout.frameWidth / 2 }
359
+ let back = goBack == nil || useSideBar ? 0 : HeaderLayoutMetrics.buttonSize + HeaderLayoutMetrics.titleGap
357
360
  let inset = max(clearance.left + back, clearance.right + headerRightWidth) + Spacing.S
358
361
  return max(layout.contentWidth - (Spacing.M + inset) * 2, 0)
359
362
  }
@@ -378,17 +381,8 @@ public struct NavigationHeader: View {
378
381
  ZStack {
379
382
  HStack(spacing: 0) {
380
383
  if let goBack, !useSideBar {
381
- if statusBarRow {
382
- SideBarButton(
383
- icon: "arrow-back",
384
- headerColor: headerColor,
385
- accessibilityId: "btn_navigation_back",
386
- action: goBack
387
- )
388
- } else {
389
- BackButton(color: headerColor, onBack: goBack)
390
- }
391
- Spacer().frame(width: Spacing.S)
384
+ BackButton(color: headerColor, onBack: goBack)
385
+ Spacer().frame(width: HeaderLayoutMetrics.titleGap)
392
386
  }
393
387
 
394
388
  if centerTitle {
@@ -399,33 +393,23 @@ public struct NavigationHeader: View {
399
393
  }
400
394
 
401
395
  if let headerRight, !(useSideBar && toolkitHeaderRight(headerRight) != nil) {
402
- Group {
403
- if statusBarRow, let toolkit = toolkitHeaderRight(headerRight) {
404
- Toolkit(
405
- headerRight: toolkit.data ?? HeaderRightData(),
406
- tintColor: toolkit.tintColor,
407
- layout: .sideBarRow
408
- )
409
- } else {
410
- AnyView(headerRight())
411
- }
412
- }
413
- .environment(\.headerColor, headerColor)
414
- .background(
415
- GeometryReader { geo in
416
- Color.clear.preference(key: HeaderRightWidthKey.self, value: geo.size.width)
417
- }
418
- )
396
+ AnyView(headerRight())
397
+ .environment(\.headerColor, headerColor)
398
+ .background(
399
+ GeometryReader { geo in
400
+ Color.clear.preference(key: HeaderRightWidthKey.self, value: geo.size.width)
401
+ }
402
+ )
419
403
  }
420
404
  }
421
- .padding(.leading, Spacing.M + (layout.statusBarClearance?.left ?? 0))
422
- .padding(.trailing, Spacing.M + (layout.statusBarClearance?.right ?? 0))
405
+ .padding(.leading, headerLayout.frameInset + (layout.statusBarClearance?.left ?? 0))
406
+ .padding(.trailing, headerLayout.frameInset + (layout.statusBarClearance?.right ?? 0))
423
407
 
424
408
  if centerTitle {
425
409
  titleArea(centered: true)
426
410
  // Compose caps a centered title at half the bar
427
411
  .frame(maxWidth: centerTitleMaxWidth)
428
- .padding(.horizontal, Spacing.M)
412
+ .padding(.horizontal, headerLayout.frameInset)
429
413
  }
430
414
  }
431
415
  .onPreferenceChange(HeaderRightWidthKey.self) { headerRightWidth = $0 }
@@ -448,6 +432,7 @@ public struct NavigationHeader: View {
448
432
  theme: theme,
449
433
  pop: navigator.map { navigator in { navigator.pop() } }
450
434
  ))
435
+ .headerSize()
451
436
  } else {
452
437
  switch headerTitle {
453
438
  case let .user(data)?:
@@ -501,7 +486,7 @@ struct HeaderBarBackground: View {
501
486
 
502
487
  // MARK: - Back button
503
488
 
504
- /// Mirrors Compose's `BackButton`: a 28pt circle with the back arrow.
489
+ /// Mirrors Compose's `BackButton`: a 32pt circle with the back arrow.
505
490
  private struct BackButton: View {
506
491
  let color: HeaderColor
507
492
  let onBack: () -> Void
@@ -511,8 +496,8 @@ private struct BackButton: View {
511
496
  Circle()
512
497
  .fill(color.backgroundButton)
513
498
  .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))
499
+ .frame(width: HeaderLayoutMetrics.buttonSize, height: HeaderLayoutMetrics.buttonSize)
500
+ .overlay(Icon(source: "arrow-back", size: HeaderLayoutMetrics.iconSize, color: color.tintIconColor))
516
501
  }
517
502
  .buttonStyle(ActiveOpacityButtonStyle())
518
503
  .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)
@@ -138,9 +138,9 @@ private struct NavigationButtonConfig {
138
138
  let onPress: () -> Void
139
139
  }
140
140
 
141
- /// `sideBarColumn`: the iPhone Duo side bar; `sideBarRow`: the Duo header row on the status bar, same 48pt controls.
141
+ /// `sideBarColumn`: the iPhone Duo side bar, 48pt controls; `bar`: every header row, iPhone Duo status bar row included.
142
142
  enum ToolkitLayout {
143
- case bar, sideBarColumn, sideBarRow
143
+ case bar, sideBarColumn
144
144
  }
145
145
 
146
146
  struct Toolkit: View {
@@ -293,16 +293,14 @@ struct Toolkit: View {
293
293
  case .bar:
294
294
  horizontalBody
295
295
  case .sideBarColumn:
296
- VStack(spacing: Spacing.M) { sideBarControls(horizontal: false) }
297
- case .sideBarRow:
298
- HStack(spacing: Spacing.M) { sideBarControls(horizontal: true) }
296
+ VStack(spacing: Spacing.M) { sideBarControls }
299
297
  }
300
298
  }
301
299
  .onAppear(perform: loadFavoriteState)
302
300
  }
303
301
 
304
302
  @ViewBuilder
305
- private func sideBarControls(horizontal: Bool) -> some View {
303
+ private var sideBarControls: some View {
306
304
  let config = navigationButtonConfig
307
305
  let useHelpCenter = usesHelpCenter(context)
308
306
  if showsShortcut(headerRight, context) {
@@ -314,7 +312,7 @@ struct Toolkit: View {
314
312
  action: config.onPress
315
313
  )
316
314
  }
317
- SideBarGroup(headerColor: headerColor, itemCount: useHelpCenter ? 2 : 1, horizontal: horizontal) {
315
+ SideBarGroup(headerColor: headerColor, itemCount: useHelpCenter ? 2 : 1) {
318
316
  if useHelpCenter {
319
317
  SideBarGroupItem(
320
318
  icon: "help_center",
@@ -354,25 +352,30 @@ struct Toolkit: View {
354
352
  }
355
353
  toolButton(icon: headerRight.closeIcon, accessibilityId: "btn_navigation_close", action: onPressClose)
356
354
  }
357
- .frame(width: usesHelpCenter(context) ? 65 : 28, height: 28)
355
+ .frame(
356
+ width: usesHelpCenter(context) ? HeaderLayoutMetrics.pillWidth : HeaderLayoutMetrics.buttonSize,
357
+ height: HeaderLayoutMetrics.buttonSize
358
+ )
358
359
  .background(headerColor.backgroundButton)
359
- .cornerRadius(14)
360
- .overlay(RoundedRectangle(cornerRadius: 14).stroke(headerColor.borderColor, lineWidth: 0.2))
360
+ .clipShape(Capsule())
361
+ .overlay(Capsule().stroke(headerColor.borderColor, lineWidth: 0.2))
361
362
  .padding(.leading, Spacing.S)
362
363
  }
363
364
  }
364
365
 
366
+ /// One half of the help / home pill; each half takes an equal share of the pill width.
365
367
  private func toolButton(icon: String, accessibilityId: String, action: @escaping () -> Void) -> some View {
366
368
  SwiftUI.Button(action: action) {
367
- Icon(source: icon, size: 20, color: headerColor.tintIconColor)
368
- .padding(4)
369
+ Icon(source: icon, size: HeaderLayoutMetrics.iconSize, color: headerColor.tintIconColor)
370
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
371
+ .contentShape(Rectangle())
369
372
  }
370
373
  .buttonStyle(ActiveOpacityButtonStyle())
371
374
  .accessibilityIdentifier(accessibilityId)
372
375
  }
373
376
  }
374
377
 
375
- /// Mirrors Compose's `NavigationButton`: the 28pt circular shortcut / more button.
378
+ /// Mirrors Compose's `NavigationButton`: the 32pt circular shortcut / more button.
376
379
  public struct NavigationButton: View {
377
380
  var disabled: Bool
378
381
  var icon: String
@@ -405,9 +408,9 @@ public struct NavigationButton: View {
405
408
  Circle()
406
409
  .fill(colors.backgroundButton)
407
410
  .overlay(Circle().stroke(colors.borderColor, lineWidth: 0.2))
408
- Icon(source: icon, size: 20, color: colors.tintIconColor)
411
+ Icon(source: icon, size: HeaderLayoutMetrics.iconSize, color: colors.tintIconColor)
409
412
  }
410
- .frame(width: 28, height: 28)
413
+ .frame(width: HeaderLayoutMetrics.buttonSize, height: HeaderLayoutMetrics.buttonSize)
411
414
  .overlay(alignment: .topTrailing) {
412
415
  if showBadge {
413
416
  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
  }
@@ -136,26 +136,17 @@ struct SideBarButton: View {
136
136
  }
137
137
  }
138
138
 
139
- /// 48pt glass capsule grouping related controls, one item per 50pt: vertical in the side bar,
140
- /// horizontal on a header row.
139
+ /// 48pt vertical glass capsule grouping related side bar controls, one item per 50pt.
141
140
  struct SideBarGroup<Content: View>: View {
142
141
  let headerColor: HeaderColor
143
142
  let itemCount: Int
144
- var horizontal: Bool = false
145
143
  @ViewBuilder let content: () -> Content
146
144
 
147
145
  var body: some View {
148
146
  let length = itemCount > 1 ? DuoMetrics.itemPitch * CGFloat(itemCount) : DuoMetrics.controlSize
149
- Group {
150
- if horizontal {
151
- HStack(spacing: 0) { content() }
152
- .frame(width: length, height: DuoMetrics.controlSize)
153
- } else {
154
- VStack(spacing: 0) { content() }
155
- .frame(width: DuoMetrics.controlSize, height: length)
156
- }
157
- }
158
- .modifier(SideBarGlass(headerColor: headerColor, shape: RoundedRectangle(cornerRadius: Radius.XL)))
147
+ VStack(spacing: 0) { content() }
148
+ .frame(width: DuoMetrics.controlSize, height: length)
149
+ .modifier(SideBarGlass(headerColor: headerColor, shape: RoundedRectangle(cornerRadius: Radius.XL)))
159
150
  }
160
151
  }
161
152
 
@@ -86,6 +86,8 @@ public struct NavigationOptions {
86
86
  public var inputSearchProps: InputSearchProps?
87
87
  public var fabProps: FabProps?
88
88
  public var onBackHandler: (() -> Void)?
89
+ /// Wide windows: `.stretch` puts the header row in the centered 600pt content frame.
90
+ public var contentLayout: ContentLayout
89
91
 
90
92
  public init(
91
93
  screenName: String? = nil,
@@ -114,7 +116,8 @@ public struct NavigationOptions {
114
116
  layoutOffset: CGFloat = 56,
115
117
  inputSearchProps: InputSearchProps? = nil,
116
118
  fabProps: FabProps? = nil,
117
- onBackHandler: (() -> Void)? = nil
119
+ onBackHandler: (() -> Void)? = nil,
120
+ contentLayout: ContentLayout = .grid
118
121
  ) {
119
122
  self.screenName = screenName
120
123
  self.title = title
@@ -143,6 +146,7 @@ public struct NavigationOptions {
143
146
  self.inputSearchProps = inputSearchProps
144
147
  self.fabProps = fabProps
145
148
  self.onBackHandler = onBackHandler
149
+ self.contentLayout = contentLayout
146
150
  }
147
151
  }
148
152
 
@@ -186,6 +190,7 @@ struct OptionsStackScreen: View {
186
190
  layoutOffset: options.layoutOffset,
187
191
  inputSearchProps: options.inputSearchProps,
188
192
  fabProps: options.fabProps,
193
+ contentLayout: options.contentLayout,
189
194
  screenName: screenName,
190
195
  content: content
191
196
  )
@@ -33,6 +33,7 @@ public struct StackScreen<Content: View>: View {
33
33
  var layoutOffset: CGFloat
34
34
  var inputSearchProps: InputSearchProps?
35
35
  var fabProps: FabProps?
36
+ var contentLayout: ContentLayout = .grid
36
37
  var screenName: String = ""
37
38
  var content: () -> Content
38
39
 
@@ -64,6 +65,7 @@ public struct StackScreen<Content: View>: View {
64
65
  layoutOffset: CGFloat = 56,
65
66
  inputSearchProps: InputSearchProps? = nil,
66
67
  fabProps: FabProps? = nil,
68
+ contentLayout: ContentLayout = .grid,
67
69
  screenName: String = "",
68
70
  @ViewBuilder content: @escaping () -> Content
69
71
  ) {
@@ -94,6 +96,7 @@ public struct StackScreen<Content: View>: View {
94
96
  self.layoutOffset = layoutOffset
95
97
  self.inputSearchProps = inputSearchProps
96
98
  self.fabProps = fabProps
99
+ self.contentLayout = contentLayout
97
100
  self.screenName = screenName
98
101
  self.content = content
99
102
  }
@@ -306,6 +309,7 @@ public struct StackScreen<Content: View>: View {
306
309
  }
307
310
  }
308
311
  .ignoresSafeArea(.keyboard, edges: .bottom)
312
+ .environment(\.contentLayout, contentLayout)
309
313
  .onChange(of: scrollOffset) { updateHeaderHide($0) }
310
314
  .onAppear { reportEmptySideBar() }
311
315
  .onChange(of: showsSideBar) { _ in reportEmptySideBar() }
@@ -504,18 +508,28 @@ public struct StackScreen<Content: View>: View {
504
508
  }
505
509
 
506
510
  private func heroGlassStart(_ animatedHeader: AnimatedHeader) -> CGFloat {
507
- max(layout.width / animatedHeader.aspectRatio.value - layout.headerHeight, 0)
511
+ max(bannerWidth / animatedHeader.aspectRatio.value - layout.headerHeight, 0)
512
+ }
513
+
514
+ /// Wide windows and the iPhone Duo inner display keep the phone banner size, centered; phones fill the width.
515
+ private var bannerWidth: CGFloat {
516
+ layout.headerLayout(contentLayout).isBannerCentered ? HeaderLayoutMetrics.bannerWidth : layout.width
508
517
  }
509
518
 
510
519
  /// The banner fills the width at its aspect ratio; the body starts `layoutOffset` below the
511
- /// header band so it overlaps the banner's lower part.
520
+ /// header band so it overlaps the banner's lower part. On wide windows and the Duo inner display
521
+ /// `bannerBackgroundColor` fills the sides, fading out downward.
512
522
  @ViewBuilder
513
523
  private func animatedHeroBody(_ animatedHeader: AnimatedHeader) -> some View {
514
- let width = layout.width
524
+ let width = bannerWidth
515
525
  let imageHeight = width / animatedHeader.aspectRatio.value
516
526
  let contentTopInset = layout.headerHeight + layoutOffset
517
527
 
518
528
  ZStack(alignment: .top) {
529
+ if width < layout.width, let fill = animatedHeader.bannerBackgroundColor {
530
+ LinearGradient(colors: [fill, fill.opacity(0)], startPoint: .top, endPoint: .bottom)
531
+ .frame(width: layout.width, height: imageHeight)
532
+ }
519
533
  animatedHeader.composable(scrollOffset)
520
534
  .frame(width: width, height: imageHeight)
521
535
  .clipped()
@@ -733,14 +747,15 @@ private struct SearchAnimatedHeader: View {
733
747
  var hasToolkit: Bool = false
734
748
 
735
749
  @Environment(\.screenLayout) private var layout
750
+ @Environment(\.contentLayout) private var contentLayout
736
751
  @Environment(\.appTheme) private var theme
737
752
  @OptionalEnvironmentObject private var navigator: Navigator?
738
753
 
739
- private var maxEndInset: CGFloat {
754
+ private func maxEndInset(_ side: CGFloat) -> CGFloat {
740
755
  if useSideBar && hasToolkit {
741
- return Spacing.M
756
+ return side
742
757
  }
743
- return headerRightWidth + (hasHeaderRight ? Spacing.M * 2 : Spacing.M)
758
+ return headerRightWidth + (hasHeaderRight ? side + Spacing.M : side)
744
759
  }
745
760
 
746
761
  var body: some View {
@@ -750,12 +765,13 @@ private struct SearchAnimatedHeader: View {
750
765
  let rowTop = layout.headerStatusBarHeight - layout.insets.top
751
766
  let minTop = rowTop + (layout.headerBarHeight - HEADER_HEIGHT) / 2
752
767
  let maxTop = layout.headerHeight - layout.insets.top
753
- let minSide = Spacing.M
754
- // collapsed on the iPhone Duo status bar row, the search stays between its clusters (48pt back there)
768
+ // stretch screens on wide windows keep the search in the header's centered frame
769
+ let minSide = layout.headerLayout(contentLayout).frameInset
770
+ // collapsed on the iPhone Duo status bar row, the search stays between its clusters
755
771
  let clearance = layout.statusBarClearance
756
- let backWidth: CGFloat = clearance != nil && !useSideBar ? DuoMetrics.controlSize : 28
757
- let maxStart = (clearance?.left ?? 0) + (hiddenBack || useSideBar ? Spacing.M : backWidth + Spacing.M + Spacing.S)
758
- let maxEnd = (clearance?.right ?? 0) + maxEndInset
772
+ let backInset = HeaderLayoutMetrics.buttonSize + HeaderLayoutMetrics.titleGap
773
+ let maxStart = (clearance?.left ?? 0) + (hiddenBack || useSideBar ? minSide : backInset + minSide)
774
+ let maxEnd = (clearance?.right ?? 0) + maxEndInset(minSide)
759
775
 
760
776
  // one progress for all three, so the field docks with its final insets and never covers the toolkit
761
777
  let progress = min(scroll / HEADER_HEIGHT, 1)
@@ -771,6 +787,7 @@ private struct SearchAnimatedHeader: View {
771
787
  theme: theme,
772
788
  pop: navigator.map { navigator in { navigator.pop() } }
773
789
  ))
790
+ .headerSize()
774
791
  .frame(height: HEADER_HEIGHT)
775
792
  .padding(.leading, start)
776
793
  .padding(.trailing, end)
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.169.10'
3
+ s.version = '0.169.11'
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.10'
3
+ s.version = '0.169.11'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }