@momo-kits/native-kits 0.168.1-beta.3 → 0.168.1-beta.30

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 (40) hide show
  1. package/CLAUDE.md +14 -10
  2. package/README.md +2 -10
  3. package/ios/Application/ApplicationEnvironment.swift +7 -6
  4. package/ios/Application/DesignSystemKits.swift +163 -0
  5. package/ios/Application/DesignSystemKitsPayload.swift +68 -0
  6. package/ios/Badge/BadgeRibbon.swift +8 -1
  7. package/ios/Extensions/Color++.swift +2 -4
  8. package/ios/Input/Input.swift +13 -3
  9. package/ios/Input/InputPhoneNumber.swift +1 -3
  10. package/ios/Input/InputSearch.swift +1 -2
  11. package/ios/Input/InputTextArea.swift +5 -3
  12. package/ios/InputMoney/InputMoney.swift +6 -7
  13. package/ios/Layout/ScreenLayout.swift +65 -10
  14. package/ios/Navigation/BottomSheet.swift +152 -21
  15. package/ios/Navigation/BottomTab/BottomTab.swift +12 -18
  16. package/ios/Navigation/BottomTab/BottomTabBar.swift +255 -114
  17. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  18. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  19. package/ios/Navigation/BottomTab/DuoTabBar.swift +63 -172
  20. package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
  21. package/ios/Navigation/Component/HeaderBackground.swift +22 -1
  22. package/ios/Navigation/Component/SnackBar.swift +4 -0
  23. package/ios/Navigation/ModalScreen.swift +7 -3
  24. package/ios/Navigation/StackScreen.swift +6 -8
  25. package/ios/Popup/PopupDisplay.swift +2 -2
  26. package/ios/Popup/PopupInput.swift +2 -2
  27. package/ios/Popup/PopupLayout.swift +15 -10
  28. package/ios/Popup/PopupNotify.swift +2 -2
  29. package/ios/Stepper/Stepper.swift +1 -2
  30. package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
  31. package/ios/Typography/FontScale.swift +29 -15
  32. package/ios/Typography/Text.swift +86 -12
  33. package/ios/Typography/Typography.swift +2 -2
  34. package/ios/native-kits.podspec +1 -1
  35. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  36. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +224 -59
  37. package/package.json +1 -1
  38. package/publish.sh +2 -7
  39. package/ios/Typography/FontScaleStore.swift +0 -58
  40. package/ios/Typography/KitDesignSystem.swift +0 -17
@@ -2,27 +2,13 @@
2
2
  // DuoTabBar.swift
3
3
  // MoMoUIKits
4
4
  //
5
- // iPhone Duo tab bar, port of RN `BottomTab/DuoTabBar.tsx` (Figma Fold-Design-System MT1/MT2):
6
- // a glass rail in the side bar, or a floating glass bar when unfolded portrait.
5
+ // iPhone Duo tab bar, port of RN `BottomTab/DuoTabBar.tsx` (Figma "Specs Navigation", DS-984):
6
+ // a rail in the side bar, or the horizontal bar at 65% of the short side when unfolded portrait.
7
7
  //
8
8
 
9
9
  import SwiftUI
10
10
 
11
- private let itemSize = DuoMetrics.controlSize
12
- private let iconSize: CGFloat = 28
13
- private let qrIconSize: CGFloat = 24
14
- private let railPadding: CGFloat = 6
15
- private let railGap = Spacing.XXS
16
- // selection bubble overflows the 48 rail cell by 5 above and below (Figma MT2)
17
- private let railBubbleWidth: CGFloat = 44
18
- private let railBubbleHeight: CGFloat = 58
19
- let duoFloatingTabBarHeight: CGFloat = 62
20
- private let floatingPadding = Spacing.XS
21
- private let floatingQrSize: CGFloat = 44
22
- // floating bar spans 6 of the 8 portrait grid columns, like the content
23
- private let gridColumns: CGFloat = 8
24
- private let gridSpan: CGFloat = 6
25
- private let tabSpring = Animation.interpolatingSpring(mass: 0.8, stiffness: 220, damping: 18)
11
+ private let compactSize = DuoMetrics.controlSize
26
12
 
27
13
  /// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
28
14
  struct DuoTabBarInsets: Equatable {
@@ -43,58 +29,33 @@ extension EnvironmentValues {
43
29
  }
44
30
  }
45
31
 
46
- /// Rail plus the QR button under it; compressed, the rail is a single button.
32
+ /// Rail container plus the center action under it; compressed, the rail is a single button.
47
33
  func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
48
- let count = CGFloat(itemCount)
49
- let rail = compressed ? itemSize : railPadding * 2 + count * itemSize + max(count - 1, 0) * railGap
50
- return rail + (hasQr ? Spacing.M + itemSize : 0)
34
+ let rail = compressed
35
+ ? compactSize
36
+ : CGFloat(itemCount) * TabBarMetrics.railItemHeight + TabBarMetrics.railPaddingBottom
37
+ return rail + (hasQr ? TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight : 0)
51
38
  }
52
39
 
53
40
  extension ScreenLayout {
41
+ /// The horizontal bar sits above the home indicator area.
42
+ var duoFloatingTabBarBottom: CGFloat {
43
+ TabBarMetrics.bottomGap(insets.bottom)
44
+ }
45
+
54
46
  func duoTabBarInsets(itemCount: Int, hasFloatingButton: Bool, tabBarCompressed: Bool = false) -> DuoTabBarInsets {
55
- guard isIPhoneDuo else { return DuoTabBarInsets() }
56
- guard let sideBar else {
57
- return DuoTabBarInsets(overlay: duoFloatingTabBarHeight + Spacing.M)
47
+ // the horizontal bar floats over the content (phone and unfolded Duo); the overlay is measured
48
+ // from the bottom safe area, the bar reaches into it
49
+ guard isIPhoneDuo, let sideBar else {
50
+ // the center action's button rises above the bar, tab content leaves room for it too
51
+ let ctaLift = hasFloatingButton && itemCount % 2 == 0 ? TabBarMetrics.ctaLift : 0
52
+ return DuoTabBarInsets(overlay: TabBarMetrics.height + ctaLift + duoFloatingTabBarBottom - insets.bottom)
58
53
  }
59
54
  let rail = duoRailHeight(itemCount: itemCount, hasQr: hasFloatingButton, compressed: tabBarCompressed)
60
55
  return DuoTabBarInsets(sideBarReserve: sideBar.bottom + rail + DuoBarCompression.groupGap)
61
56
  }
62
57
  }
63
58
 
64
- /// Glass on iOS 26, a system blur before it (RN GlassView's fallback).
65
- struct DuoBarMaterial<S: Shape>: ViewModifier {
66
- let shape: S
67
- var visible: Bool = true
68
-
69
- func body(content: Content) -> some View {
70
- content.background(material.allowsHitTesting(false))
71
- }
72
-
73
- @ViewBuilder
74
- private var material: some View {
75
- #if compiler(>=6.2)
76
- if #available(iOS 26.0, *) {
77
- // glass materializes by toggling its effect, it does not fade with opacity
78
- Color.clear
79
- .glassEffect(visible ? .regular : .identity, in: shape)
80
- .shadow(color: Color.black.opacity(visible ? 0.16 : 0), radius: 16, x: 0, y: 6)
81
- .animation(.easeInOut(duration: 0.25), value: visible)
82
- } else {
83
- blur
84
- }
85
- #else
86
- blur
87
- #endif
88
- }
89
-
90
- private var blur: some View {
91
- shape.fill(.regularMaterial)
92
- .shadow(color: Color.black.opacity(0.16), radius: 16, x: 0, y: 6)
93
- .opacity(visible ? 1 : 0)
94
- .animation(.easeInOut(duration: 0.25), value: visible)
95
- }
96
- }
97
-
98
59
  struct DuoTabBar: View {
99
60
  let items: [BottomTabItem]
100
61
  let floatingButton: BottomTabFloatingButton?
@@ -115,7 +76,7 @@ struct DuoTabBar: View {
115
76
  }
116
77
  }
117
78
 
118
- /// Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E).
79
+ /// Vertical bar anchored to the bottom of the side bar, center action below it.
119
80
  /// When the side bar is short it can shrink to one button showing the current tab
120
81
  /// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
121
82
  private struct DuoRailTabBar: View {
@@ -131,15 +92,15 @@ private struct DuoRailTabBar: View {
131
92
  private var isRight: Bool { sideBar.edge == .right }
132
93
 
133
94
  var body: some View {
134
- VStack(spacing: Spacing.M) {
95
+ VStack(spacing: TabBarMetrics.railCtaGap) {
135
96
  if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
136
97
  SwiftUI.Button(action: compression.expandTabBar) {
137
- DuoTabIcon(item: items[selectedIndex], selected: true)
138
- .frame(width: itemSize, height: itemSize)
98
+ TabIcon(item: items[selectedIndex], selected: true, vertical: true)
99
+ .frame(width: compactSize, height: compactSize)
139
100
  .contentShape(Circle())
140
101
  }
141
102
  .buttonStyle(.plain)
142
- .modifier(DuoBarMaterial(shape: Circle()))
103
+ .modifier(TabBarContainer(shape: Circle()))
143
104
  .accessibilityLabel(items[selectedIndex].label)
144
105
  .accessibilityIdentifier("bottom_tab_bar")
145
106
  } else {
@@ -147,9 +108,12 @@ private struct DuoRailTabBar: View {
147
108
  }
148
109
 
149
110
  if let floatingButton {
150
- DuoQrButton(data: floatingButton, size: itemSize)
111
+ RailCenterAction(data: floatingButton)
151
112
  }
152
113
  }
114
+ // the rail lines up with the header buttons in the side bar: centered on a 48 lane kept
115
+ // Spacing.M from the strip's inner edge; the wider rail and center action overflow it evenly
116
+ .frame(width: compactSize)
153
117
  .padding(isRight ? .leading : .trailing, Spacing.M)
154
118
  .frame(width: sideBar.width, alignment: isRight ? .leading : .trailing)
155
119
  .padding(.bottom, sideBar.bottom)
@@ -157,39 +121,42 @@ private struct DuoRailTabBar: View {
157
121
  .ignoresSafeArea()
158
122
  }
159
123
 
160
- /// Glass column of tab items with the sliding selection bubble.
124
+ /// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
161
125
  private var rail: some View {
162
126
  ZStack(alignment: .top) {
163
- Capsule()
164
- .fill(theme.colors.background.selected)
165
- .frame(width: railBubbleWidth, height: railBubbleHeight)
166
- .offset(y: railPadding - (railBubbleHeight - itemSize) / 2
167
- + CGFloat(selectedIndex) * (itemSize + railGap))
168
- .animation(tabSpring, value: selectedIndex)
127
+ ActiveIndicator(radius: TabBarMetrics.railIndicatorRadius)
128
+ .frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railIndicatorHeight)
129
+ .offset(y: Spacing.XS + CGFloat(selectedIndex) * TabBarMetrics.railItemHeight)
130
+ .animation(TabBarMetrics.indicatorMotion, value: selectedIndex)
169
131
 
170
- VStack(spacing: railGap) {
132
+ VStack(spacing: 0) {
171
133
  ForEach(items.indices, id: \.self) { index in
172
134
  SwiftUI.Button {
173
135
  onTabSelected(index)
174
136
  compression.onTabSelected()
175
137
  } label: {
176
- DuoTabIcon(item: items[index], selected: index == selectedIndex)
177
- .frame(width: itemSize, height: itemSize)
178
- .contentShape(Rectangle())
138
+ VStack(spacing: 0) {
139
+ TabItemContent(item: items[index], selected: index == selectedIndex, vertical: true, fixedFontScale: true)
140
+ }
141
+ .frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railItemHeight)
142
+ .contentShape(Rectangle())
179
143
  }
180
144
  .buttonStyle(.plain)
181
145
  .accessibilityLabel(items[index].label)
146
+ .accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
182
147
  }
183
148
  }
184
- .padding(.vertical, railPadding)
185
149
  }
186
- .frame(width: itemSize)
187
- .modifier(DuoBarMaterial(shape: RoundedRectangle(cornerRadius: Radius.XL)))
150
+ .padding(.horizontal, TabBarMetrics.railPaddingHorizontal)
151
+ .padding(.bottom, TabBarMetrics.railPaddingBottom)
152
+ .frame(width: TabBarMetrics.railContainerWidth)
153
+ .modifier(TabBarContainer(shape: RoundedRectangle(cornerRadius: Radius.XL)))
154
+ .accessibilityElement(children: .contain)
188
155
  .accessibilityIdentifier("bottom_tab_bar")
189
156
  }
190
157
  }
191
158
 
192
- /// Floating labelled bar for the unfolded portrait display, QR in the middle cell (Figma MT1-M).
159
+ /// Horizontal navigation bar of the unfolded display: 65% of the short side, centered.
193
160
  private struct DuoFloatingTabBar: View {
194
161
  let items: [BottomTabItem]
195
162
  let floatingButton: BottomTabFloatingButton?
@@ -197,108 +164,32 @@ private struct DuoFloatingTabBar: View {
197
164
  let onTabSelected: (Int) -> Void
198
165
 
199
166
  @Environment(\.screenLayout) private var layout
200
- @Environment(\.appTheme) private var theme
201
-
202
- private var barWidth: CGFloat {
203
- let columnWidth = (layout.width - 2 * Spacing.M - (gridColumns - 1) * Spacing.M) / gridColumns
204
- return columnWidth * gridSpan + (gridSpan - 1) * Spacing.M
205
- }
206
-
207
- private var useQr: Bool { floatingButton != nil && items.count % 2 == 0 }
208
- private var middle: Int { items.count / 2 }
209
- private var cellCount: Int { items.count + (useQr ? 1 : 0) }
210
- private var cellWidth: CGFloat { (barWidth - floatingPadding * 2) / CGFloat(max(cellCount, 1)) }
211
- private var visualIndex: Int { useQr && selectedIndex >= middle ? selectedIndex + 1 : selectedIndex }
212
167
 
213
168
  var body: some View {
214
- ZStack(alignment: .leading) {
215
- Capsule()
216
- .fill(theme.colors.background.selected)
217
- .frame(width: cellWidth)
218
- .offset(x: CGFloat(visualIndex) * cellWidth)
219
- .animation(tabSpring, value: visualIndex)
220
-
221
- HStack(spacing: 0) {
222
- ForEach(0..<cellCount, id: \.self) { cell in
223
- if useQr && cell == middle, let floatingButton {
224
- DuoQrButton(data: floatingButton, size: floatingQrSize)
225
- .frame(width: cellWidth)
226
- } else {
227
- let index = useQr && cell > middle ? cell - 1 : cell
228
- tabCell(index)
229
- }
230
- }
231
- }
232
- }
233
- .padding(floatingPadding)
234
- .frame(width: barWidth, height: duoFloatingTabBarHeight)
235
- .modifier(DuoBarMaterial(shape: Capsule()))
236
- .accessibilityIdentifier("bottom_tab_bar")
237
- .padding(.bottom, layout.insets.bottom + Spacing.M)
169
+ HorizontalTabBar(
170
+ items: items,
171
+ floatingButton: floatingButton,
172
+ selectedIndex: selectedIndex,
173
+ onTabSelected: onTabSelected,
174
+ width: TabBarMetrics.horizontalBarWidth(layout),
175
+ fixedFontScale: true
176
+ )
177
+ .padding(.bottom, layout.duoFloatingTabBarBottom)
238
178
  .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
239
179
  .ignoresSafeArea()
240
180
  }
241
-
242
- private func tabCell(_ index: Int) -> some View {
243
- let selected = index == selectedIndex
244
- return SwiftUI.Button { onTabSelected(index) } label: {
245
- VStack(spacing: Spacing.XXS) {
246
- DuoTabIcon(item: items[index], selected: selected)
247
- MomoText(
248
- items[index].label,
249
- typography: .labelXsMedium,
250
- color: selected ? theme.colors.primary : theme.colors.text.default,
251
- textAlign: .center,
252
- maxLines: 1
253
- )
254
- }
255
- .frame(width: cellWidth)
256
- .frame(maxHeight: .infinity)
257
- .contentShape(Rectangle())
258
- }
259
- .buttonStyle(.plain)
260
- .accessibilityLabel(items[index].label)
261
- }
262
- }
263
-
264
- private struct DuoTabIcon: View {
265
- let item: BottomTabItem
266
- let selected: Bool
267
-
268
- @Environment(\.appTheme) private var theme
269
-
270
- private var badgeLabel: String? {
271
- guard let label = item.badgeLabel else { return nil }
272
- if let n = Int(label), n == 0 { return nil }
273
- return label
274
- }
275
-
276
- var body: some View {
277
- Icon(source: item.icon, size: iconSize, color: selected ? theme.colors.primary : theme.colors.text.default)
278
- .overlay(alignment: .topTrailing) {
279
- if let badgeLabel, !badgeLabel.isEmpty {
280
- Badge(label: badgeLabel).offset(x: Spacing.S, y: -Spacing.XS)
281
- } else if badgeLabel != nil || item.showDot {
282
- BadgeDot(size: .small)
283
- }
284
- }
285
- }
286
181
  }
287
182
 
288
- private struct DuoQrButton: View {
183
+ /// Center action of the rail: round button with its label, under the container.
184
+ private struct RailCenterAction: View {
289
185
  let data: BottomTabFloatingButton
290
- let size: CGFloat
291
-
292
- @Environment(\.appTheme) private var theme
293
186
 
294
187
  var body: some View {
295
- SwiftUI.Button(action: data.onPress) {
296
- Circle()
297
- .fill(theme.colors.primary)
298
- .frame(width: size, height: size)
299
- .overlay(Icon(source: data.icon, size: qrIconSize, color: Colors.black01))
300
- }
301
- .buttonStyle(.plain)
302
- .accessibilityLabel(data.label)
188
+ SwiftUI.Button(action: data.onPress) { EmptyView() }
189
+ .buttonStyle(CenterActionStyle(size: TabBarMetrics.railCtaSize, vertical: true, icon: data.icon,
190
+ label: data.label, fixedFontScale: true))
191
+ .frame(width: TabBarMetrics.railCtaWidth, height: TabBarMetrics.railCtaHeight)
192
+ .accessibilityLabel(data.label)
193
+ .accessibilityIdentifier(data.label)
303
194
  }
304
195
  }
@@ -0,0 +1,88 @@
1
+ //
2
+ // TabBarMetrics.swift
3
+ // MoMoUIKits
4
+ //
5
+ // Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from Compose's
6
+ // `navigation/bottomtab/TabBarMetrics.kt` and RN `BottomTab/metrics.ts`.
7
+ // Horizontal: floating container with items split evenly, center action in a notch.
8
+ // Vertical: iPhone Duo rail, center action under the container.
9
+ //
10
+
11
+ import SwiftUI
12
+
13
+ enum TabBarMetrics {
14
+ static let height: CGFloat = 68
15
+ static let margin = Spacing.S
16
+ static let paddingVertical = Spacing.S
17
+ static let paddingHorizontal = Spacing.M
18
+ static let itemGap = Spacing.XS
19
+ static let iconSize: CGFloat = 24
20
+ static let indicatorHeight: CGFloat = 32
21
+ // active indicator behind the icon: 24 icon + XS·M padding
22
+ static let indicatorPaddingVertical = Spacing.XS
23
+ static let indicatorPaddingHorizontal = Spacing.M
24
+ static let indicatorRadius = Radius.XL
25
+ // home indicator / gesture bar area under the container
26
+ static let systemIndicatorHeight: CGFloat = 24
27
+ // unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
28
+ // centered; phones and folded outer displays fill the window
29
+ static let foldableMinShortSide: CGFloat = 600
30
+ static let foldableWidthRatio: CGFloat = 0.65
31
+ static let ctaSlotWidth: CGFloat = 92
32
+ static let ctaSize: CGFloat = 48
33
+ // the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
34
+ static let ctaIconSize: CGFloat = 28
35
+ // the button rises 22 above the container top edge
36
+ static let ctaLift: CGFloat = 22
37
+ static let ctaLabelGap = Spacing.M
38
+ static let ctaLabelHeight: CGFloat = 18
39
+ // notch dipped into the container top edge under the center action (Figma "Backgroud" path):
40
+ // starts notchHalfWidth left of the center, then cubic segments of control1, control2, end,
41
+ // each point as (dx from the center, dy below the top edge)
42
+ static let notchHalfWidth: CGFloat = 50.758
43
+ static let notchCurves: [[CGPoint]] = [
44
+ [CGPoint(x: -39.749, y: 0), CGPoint(x: -31.231, y: 9.765), CGPoint(x: -24.563, y: 18.526)],
45
+ [CGPoint(x: -18.928, y: 25.93), CGPoint(x: -10.022, y: 30.709), CGPoint(x: 0, y: 30.709)],
46
+ [CGPoint(x: 10.022, y: 30.709), CGPoint(x: 18.928, y: 25.93), CGPoint(x: 24.563, y: 18.526)],
47
+ [CGPoint(x: 31.231, y: 9.765), CGPoint(x: 39.749, y: 0), CGPoint(x: notchHalfWidth, y: 0)],
48
+ ]
49
+ static let railContainerWidth: CGFloat = 56
50
+ static let railPaddingHorizontal = Spacing.XS
51
+ static let railPaddingBottom = Spacing.S
52
+ static let railItemWidth: CGFloat = 48
53
+ static let railItemHeight: CGFloat = 62
54
+ static let railIndicatorHeight: CGFloat = 40
55
+ static let railIndicatorPaddingVertical = Spacing.S
56
+ static let railIndicatorRadius: CGFloat = 20
57
+ static let railCtaGap = Spacing.L
58
+ static let railCtaSize: CGFloat = 52
59
+ static let railCtaLabelGap = Spacing.XS
60
+ static let railCtaWidth: CGFloat = 68
61
+ static let railCtaHeight: CGFloat = 70
62
+ static let badgeMaxWidth: CGFloat = 58
63
+
64
+ // motion (MoMo Navigation Prototype): one active indicator slides to the selected item overshooting
65
+ // a little, icon and label tint cross-fade, the center action shrinks while held
66
+ static let indicatorMotion = Animation.timingCurve(0.34, 1.4, 0.5, 1, duration: 0.55)
67
+ static let tintMotion = Animation.easeInOut(duration: 0.25)
68
+ static let ctaPressMotion = Animation.easeOut(duration: 0.15)
69
+ static let ctaPressedScale: CGFloat = 0.92
70
+
71
+ /// Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window
72
+ /// minus the side safe areas and margins.
73
+ static func horizontalBarWidth(_ layout: ScreenLayout) -> CGFloat {
74
+ let shortSide = min(layout.width, layout.height)
75
+ if shortSide >= foldableMinShortSide { return shortSide * foldableWidthRatio }
76
+ return layout.width - layout.insets.leading - layout.insets.trailing - 2 * margin
77
+ }
78
+
79
+ /// Gap under the container: the home indicator area.
80
+ static func bottomGap(_ bottomInset: CGFloat) -> CGFloat {
81
+ max(min(bottomInset, systemIndicatorHeight), Spacing.S)
82
+ }
83
+
84
+ /// The center action needs a tab on each side: Special type takes 2 or 4 tabs.
85
+ static func hasCenterAction(_ floatingButton: BottomTabFloatingButton?, tabCount: Int) -> Bool {
86
+ floatingButton != nil && tabCount % 2 == 0
87
+ }
88
+ }
@@ -90,6 +90,27 @@ private let duoGradientExtra: CGFloat = 52
90
90
  // scroll distance over which the extended gradient collapses to the header
91
91
  private let duoExtendedCollapseDistance: CGFloat = 100
92
92
 
93
+ // scroll distance over which the bar fades in
94
+ private let duoBarFadeDistance: CGFloat = 16
95
+
96
+ /// Port of RN `DuoGlassBackground`: translucent surface with a hairline, shown once the content
97
+ /// scrolls `fadeStart` under the header.
98
+ struct DuoHeaderBar: View {
99
+ let scrollOffset: CGFloat
100
+ var fadeStart: CGFloat = 0
101
+
102
+ @Environment(\.appTheme) private var theme
103
+
104
+ var body: some View {
105
+ theme.colors.background.surface.opacity(0.8)
106
+ .overlay(alignment: .bottom) {
107
+ theme.colors.border.default.frame(height: 0.5)
108
+ }
109
+ .opacity(min(max((scrollOffset - fadeStart) / duoBarFadeDistance, 0), 1))
110
+ .allowsHitTesting(false)
111
+ }
112
+ }
113
+
93
114
  /// Port of RN `DuoScrollGradient`: with the glass header the content scrolls under the bar, so the
94
115
  /// header gradient is drawn under it. Compose draws this inside `HeaderBackground`.
95
116
  struct DuoScrollGradient: View {
@@ -114,7 +135,7 @@ struct DuoScrollGradient: View {
114
135
  let progress = min(scroll / duoExtendedCollapseDistance, 1)
115
136
  gradient
116
137
  .frame(height: headerHeight + (extended ? duoGradientExtra * (1 - progress) : 0))
117
- .opacity(1 - min(scroll / duoGradientExtra, 1))
138
+ .opacity(Double(1 - min(scroll / duoGradientExtra, 1)))
118
139
  }
119
140
  }
120
141
  .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
@@ -57,6 +57,7 @@ struct SnackBarView: View {
57
57
  let bottomInset: CGFloat
58
58
 
59
59
  @EnvironmentObject private var navigator: Navigator
60
+ @Environment(\.screenLayout) private var layout
60
61
 
61
62
  @State private var contentHeight: CGFloat = 0
62
63
  @State private var offsetY: CGFloat = 0
@@ -75,6 +76,9 @@ struct SnackBarView: View {
75
76
  )
76
77
  .offset(y: offsetY)
77
78
  .padding(.bottom, bottomInset)
79
+ // iPhone Duo: clear of the side toolbar strip, like the screen content (0 elsewhere)
80
+ .padding(.leading, layout.insetLeft)
81
+ .padding(.trailing, layout.insetRight)
78
82
  }
79
83
  .frame(maxWidth: .infinity, maxHeight: .infinity)
80
84
  .ignoresSafeArea()
@@ -34,11 +34,15 @@ struct ModalScreen<Content: View>: View {
34
34
  }
35
35
 
36
36
  content()
37
+ // iPhone Duo: capped so it stays a dialog on the inner display; nil leaves the size alone
38
+ .frame(
39
+ maxWidth: layout.isDuoDevice ? layout.duoModalMaxWidth : nil,
40
+ maxHeight: layout.isDuoDevice ? layout.duoModalMaxHeight : nil
41
+ )
37
42
  .scaleEffect(contentScale)
38
43
  .opacity(contentOpacity)
39
- // iPhone Duo: center below the side status bar and above the home indicator
40
- .padding(.top, layout.isDuoDevice ? layout.duoTopInset : 0)
41
- .padding(.bottom, layout.isDuoDevice ? layout.insets.bottom : 0)
44
+ // iPhone Duo: center in the safe area, clear of the side toolbar strip and the home indicator
45
+ .padding(layout.isDuoDevice ? layout.insets : EdgeInsets())
42
46
  }
43
47
  // Full screen like RN's Modal, so asymmetric landscape insets don't shift the content sideways.
44
48
  .frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -403,11 +403,8 @@ public struct StackScreen<Content: View>: View {
403
403
  .background(alignment: .top) {
404
404
  Group {
405
405
  if layout.sideBar != nil {
406
- // glass shows once the banner has scrolled under the header
407
- Color.clear.modifier(DuoBarMaterial(
408
- shape: Rectangle(),
409
- visible: scrollOffset > heroGlassStart(animatedHeader)
410
- ))
406
+ // the bar shows once the banner has scrolled under the header
407
+ DuoHeaderBar(scrollOffset: scrollOffset, fadeStart: heroGlassStart(animatedHeader))
411
408
  } else {
412
409
  HeaderBarBackground(opacity: opacity)
413
410
  }
@@ -457,8 +454,7 @@ public struct StackScreen<Content: View>: View {
457
454
 
458
455
  header
459
456
  .background(
460
- Color.clear
461
- .modifier(DuoBarMaterial(shape: Rectangle(), visible: scrollOffset > 0))
457
+ DuoHeaderBar(scrollOffset: scrollOffset)
462
458
  .edgesIgnoringSafeArea([.top, .horizontal])
463
459
  )
464
460
  .offset(y: -headerHide)
@@ -577,7 +573,8 @@ private struct StackScreenContent<Content: View>: View {
577
573
  var animatedSearchInset: CGFloat = 0
578
574
  /// Room for a header the content scrolls under (iPhone Duo glass header).
579
575
  var topInset: CGFloat = 0
580
- /// Room for a bar that overlays the content (iPhone Duo floating tab bar).
576
+ /// Room for the floating tab bar that overlays the content: scrolling content runs under it and
577
+ /// ends clear of it, static content stays above it.
581
578
  var bottomInset: CGFloat = 0
582
579
  /// Compose's animated-search snap: a scroll that comes to rest part way through this distance
583
580
  /// finishes the move, up or back down.
@@ -648,6 +645,7 @@ private struct StackScreenContent<Content: View>: View {
648
645
  }
649
646
  }
650
647
  } else {
648
+ // static tab content stays above the floating tab bar
651
649
  content()
652
650
  .padding(.top, topInset)
653
651
  .padding(.bottom, bottomInset)
@@ -107,7 +107,7 @@ public struct PopupDisplay: View {
107
107
  }
108
108
  .fixedSize(horizontal: false, vertical: true)
109
109
  .background(theme.colors.background.surface)
110
- .clipShape(RoundedRectangle(cornerRadius: Radius.L))
110
+ .clipShape(RoundedRectangle(cornerRadius: layout.popupRadius()))
111
111
 
112
112
  if isShowCloseIcon {
113
113
  PopupCloseButton(action: onClose)
@@ -115,7 +115,7 @@ public struct PopupDisplay: View {
115
115
  }
116
116
  }
117
117
  .frame(maxWidth: layout.popupMaxWidth)
118
- .padding(.horizontal, 12)
118
+ .padding(.horizontal, layout.popupHorizontalPadding(12))
119
119
  .accessibilityElement(children: .contain)
120
120
  .accessibilityIdentifier("popup_notify")
121
121
  }
@@ -59,11 +59,11 @@ public struct PopupInput: View {
59
59
  .offset(x: 11, y: -11)
60
60
  }
61
61
  }
62
- .background(theme.colors.background.surface.cornerRadius(8))
62
+ .background(theme.colors.background.surface.cornerRadius(layout.popupRadius(8)))
63
63
  .shadow(color: .black.opacity(0.08), radius: 2, x: 0, y: 0)
64
64
  .shadow(color: .black.opacity(0.16), radius: 24, x: 0, y: 0)
65
65
  .frame(maxWidth: layout.popupMaxWidth)
66
- .padding(.horizontal, 40)
66
+ .padding(.horizontal, layout.popupHorizontalPadding(40))
67
67
  }
68
68
 
69
69
  // MARK: Internal
@@ -1,21 +1,26 @@
1
1
  import SDWebImageSwiftUI
2
2
  import SwiftUI
3
3
 
4
- // Width of a system alert on the iPhone Duo inner display, in both orientations (RN Popup/utils.ts).
5
- private let duoPopupMaxWidth: CGFloat = 440
6
-
7
4
  extension ScreenLayout {
8
- var isDuoDevice: Bool { isIPhoneDuoDevice(windowSize: CGSize(width: width, height: height)) }
9
-
10
- /// Card width cap (Compose `popupMaxWidth`); unbounded off iPhone Duo, where the popup's own padding sets the width.
5
+ /// Card width cap on iPhone Duo (the modal bounds, Compose `popupMaxWidth`); unbounded elsewhere,
6
+ /// where the popup's own padding sets the width.
11
7
  var popupMaxWidth: CGFloat {
12
- isDuoDevice ? duoPopupMaxWidth : .infinity
8
+ isDuoDevice ? duoModalMaxWidth : .infinity
9
+ }
10
+
11
+ /// The modal bounds already keep iPhone Duo popups off the edges, so their own side padding goes.
12
+ func popupHorizontalPadding(_ padding: CGFloat) -> CGFloat {
13
+ isDuoDevice ? 0 : padding
13
14
  }
14
15
 
15
- /// Room left for a popup on iPhone Duo, where landscape is too short for it; nil elsewhere.
16
+ /// Tallest a popup gets on iPhone Duo, landscape and the inner display included; nil elsewhere.
16
17
  var popupMaxHeight: CGFloat? {
17
- guard isDuoDevice else { return nil }
18
- return height - duoTopInset - insets.bottom - Spacing.XL * 2
18
+ isDuoDevice ? duoModalMaxHeight : nil
19
+ }
20
+
21
+ /// Rounder on iPhone Duo, closer to its system alerts.
22
+ func popupRadius(_ regular: CGFloat = Radius.L) -> CGFloat {
23
+ isDuoDevice ? Radius.XL : regular
19
24
  }
20
25
  }
21
26
 
@@ -105,7 +105,7 @@ public struct PopupNotify: View {
105
105
  .popupReadHeight($actionsHeight)
106
106
  }
107
107
  .background(theme.colors.background.surface)
108
- .clipShape(RoundedRectangle(cornerRadius: Radius.L))
108
+ .clipShape(RoundedRectangle(cornerRadius: layout.popupRadius()))
109
109
 
110
110
  if props.isShowCloseIcon {
111
111
  PopupCloseButton(action: props.onIconClose)
@@ -113,7 +113,7 @@ public struct PopupNotify: View {
113
113
  }
114
114
  }
115
115
  .frame(maxWidth: layout.popupMaxWidth)
116
- .padding(.horizontal, Spacing.M)
116
+ .padding(.horizontal, layout.popupHorizontalPadding(Spacing.M))
117
117
  .accessibilityElement(children: .contain)
118
118
  .accessibilityIdentifier("popup_notify")
119
119
  }
@@ -84,7 +84,6 @@ private struct StepperButton: View {
84
84
 
85
85
  private struct StepperNumberView: View {
86
86
  @Environment(\.appTheme) private var theme
87
- @Environment(\.momoFontScale) private var fontScale
88
87
 
89
88
  @Binding var text: String
90
89
  var size: StepperSize
@@ -106,7 +105,7 @@ private struct StepperNumberView: View {
106
105
  MomoText(text, typography: .descriptionDefaultRegular, color: textColor)
107
106
  }
108
107
  }
109
- .font(.system(size: fontScale(12)))
108
+ .kitFont(size: 12)
110
109
  .ignoreBoldTextSetting()
111
110
  .foregroundColor(textColor)
112
111
  // Compose's min width includes the horizontal padding.