@momo-kits/native-kits 0.168.1-sizescale.1-debug → 0.169.1-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 (64) hide show
  1. package/CLAUDE.md +4 -3
  2. package/PUBLISH_GUIDE.md +29 -658
  3. package/compose/build.gradle.kts +2 -2
  4. package/compose/compose.podspec +1 -1
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +4 -5
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +2 -2
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +21 -15
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +76 -83
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +3 -3
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +1 -1
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +11 -14
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +3 -4
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +8 -13
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +57 -163
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +17 -12
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +5 -7
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +34 -23
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +321 -149
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +87 -261
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +2 -0
  30. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +1 -2
  31. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +3 -2
  32. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  33. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +9 -3
  34. package/gradle.properties +1 -3
  35. package/ios/Input/Input.swift +3 -1
  36. package/ios/Input/InputTextArea.swift +3 -1
  37. package/ios/Layout/ModalLayout.swift +152 -0
  38. package/ios/Layout/ScreenLayout.swift +28 -24
  39. package/ios/Navigation/BottomSheet.swift +29 -156
  40. package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
  41. package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
  42. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  43. package/ios/Navigation/BottomTab/DuoTabBar.swift +62 -195
  44. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  45. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  46. package/ios/Navigation/ModalScreen.swift +18 -7
  47. package/ios/Navigation/StackScreen.swift +3 -1
  48. package/ios/Popup/PopupDisplay.swift +4 -2
  49. package/ios/Popup/PopupInput.swift +4 -2
  50. package/ios/Popup/PopupLayout.swift +10 -9
  51. package/ios/Popup/PopupNotify.swift +32 -25
  52. package/ios/Typography/Text.swift +2 -2
  53. package/ios/native-kits.podspec +1 -1
  54. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  55. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  56. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  57. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  58. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
  59. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  60. package/local.properties +8 -0
  61. package/package.json +1 -1
  62. package/publish.sh +170 -513
  63. package/compose/build.gradle.kts.backup +0 -198
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitSizeScale.kt +0 -45
@@ -2,30 +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 rail in the side bar, or a floating 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
- private let floatingHeight = DuoMetrics.floatingTabBarHeight
20
- private let floatingPadding = Spacing.XS
21
- // the system bar sizes its pill to the tabs instead of stretching it across the display
22
- private let floatingItemWidth: CGFloat = 80
23
- // while pressed the selection bubble grows into a lens past the pill's edges
24
- private let lensScaleX: CGFloat = 1.2
25
- private let lensScaleY: CGFloat = 1.3
26
- // Figma Home-2026 tab bar "Selection": brand pink at 8%
27
- private let selectionTintOpacity: Double = 0x14 / 255
28
- private let tabSpring = Animation.interpolatingSpring(mass: 0.8, stiffness: 220, damping: 18)
11
+ private let compactSize = DuoMetrics.controlSize
29
12
 
30
13
  /// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
31
14
  struct DuoTabBarInsets: Equatable {
@@ -46,45 +29,33 @@ extension EnvironmentValues {
46
29
  }
47
30
  }
48
31
 
49
- /// 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.
50
33
  func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
51
- let count = CGFloat(itemCount)
52
- let rail = compressed ? itemSize : railPadding * 2 + count * itemSize + max(count - 1, 0) * railGap
53
- 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)
54
38
  }
55
39
 
56
40
  extension ScreenLayout {
57
- /// Overlaps the home indicator inset like the system tab bar (21pt above the bottom with a 34pt inset).
41
+ /// The horizontal bar sits above the home indicator area.
58
42
  var duoFloatingTabBarBottom: CGFloat {
59
- max(insets.bottom - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S)
43
+ TabBarMetrics.bottomGap(insets.bottom)
60
44
  }
61
45
 
62
46
  func duoTabBarInsets(itemCount: Int, hasFloatingButton: Bool, tabBarCompressed: Bool = false) -> DuoTabBarInsets {
63
- guard isIPhoneDuo else { return DuoTabBarInsets() }
64
- guard let sideBar else {
65
- // overlay is measured from the bottom safe area, the bar reaches into it
66
- return DuoTabBarInsets(overlay: floatingHeight + duoFloatingTabBarBottom - insets.bottom)
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)
67
53
  }
68
54
  let rail = duoRailHeight(itemCount: itemCount, hasQr: hasFloatingButton, compressed: tabBarCompressed)
69
55
  return DuoTabBarInsets(sideBarReserve: sideBar.bottom + rail + DuoBarCompression.groupGap)
70
56
  }
71
57
  }
72
58
 
73
- /// RN `BarMaterial`: surface with a 1pt border.
74
- struct DuoBarMaterial<S: InsettableShape>: ViewModifier {
75
- let shape: S
76
-
77
- @Environment(\.appTheme) private var theme
78
-
79
- func body(content: Content) -> some View {
80
- content.background(
81
- shape.fill(theme.colors.background.surface)
82
- .overlay(shape.strokeBorder(theme.colors.border.default, lineWidth: 1))
83
- .allowsHitTesting(false)
84
- )
85
- }
86
- }
87
-
88
59
  struct DuoTabBar: View {
89
60
  let items: [BottomTabItem]
90
61
  let floatingButton: BottomTabFloatingButton?
@@ -105,7 +76,7 @@ struct DuoTabBar: View {
105
76
  }
106
77
  }
107
78
 
108
- /// 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.
109
80
  /// When the side bar is short it can shrink to one button showing the current tab
110
81
  /// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
111
82
  private struct DuoRailTabBar: View {
@@ -116,20 +87,20 @@ private struct DuoRailTabBar: View {
116
87
  let onTabSelected: (Int) -> Void
117
88
  let compression: DuoBarCompression
118
89
 
119
- @State private var pressedIndex: Int?
90
+ @Environment(\.appTheme) private var theme
120
91
 
121
92
  private var isRight: Bool { sideBar.edge == .right }
122
93
 
123
94
  var body: some View {
124
- VStack(spacing: Spacing.M) {
95
+ VStack(spacing: TabBarMetrics.railCtaGap) {
125
96
  if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
126
97
  SwiftUI.Button(action: compression.expandTabBar) {
127
- DuoTabIcon(item: items[selectedIndex], selected: true)
128
- .frame(width: itemSize, height: itemSize)
98
+ TabIcon(item: items[selectedIndex], selected: true, vertical: true)
99
+ .frame(width: compactSize, height: compactSize)
129
100
  .contentShape(Circle())
130
101
  }
131
102
  .buttonStyle(.plain)
132
- .modifier(DuoBarMaterial(shape: Circle()))
103
+ .modifier(TabBarContainer(shape: Circle()))
133
104
  .accessibilityLabel(items[selectedIndex].label)
134
105
  .accessibilityIdentifier("bottom_tab_bar")
135
106
  } else {
@@ -137,9 +108,12 @@ private struct DuoRailTabBar: View {
137
108
  }
138
109
 
139
110
  if let floatingButton {
140
- DuoQrButton(data: floatingButton, size: itemSize)
111
+ RailCenterAction(data: floatingButton)
141
112
  }
142
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)
143
117
  .padding(isRight ? .leading : .trailing, Spacing.M)
144
118
  .frame(width: sideBar.width, alignment: isRight ? .leading : .trailing)
145
119
  .padding(.bottom, sideBar.bottom)
@@ -147,39 +121,42 @@ private struct DuoRailTabBar: View {
147
121
  .ignoresSafeArea()
148
122
  }
149
123
 
150
- /// Column of icon-only tab items with the sliding selection bubble.
124
+ /// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
151
125
  private var rail: some View {
152
126
  ZStack(alignment: .top) {
153
- DuoSelectionMaterial(lens: pressedIndex != nil)
154
- .frame(width: railBubbleWidth, height: railBubbleHeight)
155
- .offset(y: railPadding - (railBubbleHeight - itemSize) / 2
156
- + CGFloat(pressedIndex ?? selectedIndex) * (itemSize + railGap))
157
- .animation(tabSpring, value: selectedIndex)
158
- .animation(tabSpring, value: pressedIndex)
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)
159
131
 
160
- VStack(spacing: railGap) {
132
+ VStack(spacing: 0) {
161
133
  ForEach(items.indices, id: \.self) { index in
162
134
  SwiftUI.Button {
163
135
  onTabSelected(index)
164
136
  compression.onTabSelected()
165
137
  } label: {
166
- DuoTabIcon(item: items[index], selected: index == selectedIndex)
167
- .frame(width: itemSize, height: itemSize)
168
- .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())
169
143
  }
170
- .buttonStyle(DuoLensPressStyle(index: index, pressedIndex: $pressedIndex))
144
+ .buttonStyle(.plain)
171
145
  .accessibilityLabel(items[index].label)
146
+ .accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
172
147
  }
173
148
  }
174
- .padding(.vertical, railPadding)
175
149
  }
176
- .frame(width: itemSize)
177
- .modifier(DuoBarMaterial(shape: Capsule()))
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)
178
155
  .accessibilityIdentifier("bottom_tab_bar")
179
156
  }
180
157
  }
181
158
 
182
- /// Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
159
+ /// Horizontal navigation bar of the unfolded display: 65% of the short side, centered.
183
160
  private struct DuoFloatingTabBar: View {
184
161
  let items: [BottomTabItem]
185
162
  let floatingButton: BottomTabFloatingButton?
@@ -187,143 +164,33 @@ private struct DuoFloatingTabBar: View {
187
164
  let onTabSelected: (Int) -> Void
188
165
 
189
166
  @Environment(\.screenLayout) private var layout
190
- @Environment(\.appTheme) private var theme
191
- @State private var pressedIndex: Int?
192
-
193
- private var barWidth: CGFloat {
194
- let margins = layout.insets.leading + layout.insets.trailing + 2 * DuoMetrics.floatingTabBarMargin
195
- let qr = floatingButton == nil ? 0 : floatingHeight + Spacing.S
196
- let preferred = CGFloat(items.count) * floatingItemWidth + 2 * floatingPadding
197
- return max(min(preferred, layout.width - margins - qr), 0)
198
- }
199
-
200
- private var cellWidth: CGFloat { (barWidth - floatingPadding * 2) / CGFloat(max(items.count, 1)) }
201
167
 
202
168
  var body: some View {
203
- HStack(spacing: Spacing.S) {
204
- bar
205
- if let floatingButton {
206
- DuoQrButton(data: floatingButton, size: floatingHeight)
207
- .shadow(color: Color.black.opacity(0.16), radius: 16, x: 0, y: 6)
208
- }
209
- }
169
+ HorizontalTabBar(
170
+ items: items,
171
+ floatingButton: floatingButton,
172
+ selectedIndex: selectedIndex,
173
+ onTabSelected: onTabSelected,
174
+ width: TabBarMetrics.horizontalBarWidth(layout),
175
+ fixedFontScale: true
176
+ )
210
177
  .padding(.bottom, layout.duoFloatingTabBarBottom)
211
178
  .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
212
179
  .ignoresSafeArea()
213
180
  }
214
-
215
- private var bar: some View {
216
- ZStack(alignment: .leading) {
217
- DuoSelectionMaterial(lens: pressedIndex != nil)
218
- .frame(width: cellWidth)
219
- .offset(x: CGFloat(pressedIndex ?? selectedIndex) * cellWidth)
220
- .animation(tabSpring, value: selectedIndex)
221
- .animation(tabSpring, value: pressedIndex)
222
-
223
- HStack(spacing: 0) {
224
- ForEach(items.indices, id: \.self) { index in
225
- tabCell(index)
226
- }
227
- }
228
- }
229
- .padding(floatingPadding)
230
- .frame(width: barWidth, height: floatingHeight)
231
- .modifier(DuoBarMaterial(shape: Capsule()))
232
- .accessibilityIdentifier("bottom_tab_bar")
233
- }
234
-
235
- private func tabCell(_ index: Int) -> some View {
236
- let selected = index == selectedIndex
237
- return SwiftUI.Button { onTabSelected(index) } label: {
238
- VStack(spacing: Spacing.XXS) {
239
- DuoTabIcon(item: items[index], selected: selected)
240
- MomoText(
241
- items[index].label,
242
- typography: .labelXsMedium,
243
- color: selected ? theme.colors.primary : theme.colors.text.hint,
244
- textAlign: .center,
245
- maxLines: 1
246
- )
247
- // like the system tab bar the label keeps its design size; a constant snapshot, nothing to observe
248
- .environment(\.momoFontScale, FontScale(userScaleRate: 1, useOSScaleRate: false))
249
- }
250
- .frame(width: cellWidth)
251
- .frame(maxHeight: .infinity)
252
- .contentShape(Rectangle())
253
- }
254
- .buttonStyle(DuoLensPressStyle(index: index, pressedIndex: $pressedIndex))
255
- .accessibilityLabel(items[index].label)
256
- }
257
181
  }
258
182
 
259
- /// Pink tinted capsule under the selected tab; while pressed it grows into a lens (80x54 to about 96x70).
260
- private struct DuoSelectionMaterial: View {
261
- let lens: Bool
262
-
263
- @Environment(\.appTheme) private var theme
264
-
265
- var body: some View {
266
- Capsule()
267
- .fill(theme.colors.primary.opacity(selectionTintOpacity))
268
- .scaleEffect(x: lens ? lensScaleX : 1, y: lens ? lensScaleY : 1)
269
- .allowsHitTesting(false)
270
- }
271
- }
272
-
273
- /// Tracks the finger so the selection lens jumps to the pressed tab before it is selected.
274
- private struct DuoLensPressStyle: ButtonStyle {
275
- let index: Int
276
- @Binding var pressedIndex: Int?
277
-
278
- func makeBody(configuration: Configuration) -> some View {
279
- configuration.label.onChange(of: configuration.isPressed) { pressed in
280
- if pressed {
281
- pressedIndex = index
282
- } else if pressedIndex == index {
283
- pressedIndex = nil
284
- }
285
- }
286
- }
287
- }
288
-
289
- private struct DuoTabIcon: View {
290
- let item: BottomTabItem
291
- let selected: Bool
292
-
293
- @Environment(\.appTheme) private var theme
294
-
295
- private var badgeLabel: String? {
296
- guard let label = item.badgeLabel else { return nil }
297
- if let n = Int(label), n == 0 { return nil }
298
- return label
299
- }
300
-
301
- var body: some View {
302
- Icon(source: item.icon, size: iconSize, color: selected ? theme.colors.primary : theme.colors.text.hint)
303
- .overlay(alignment: .topTrailing) {
304
- if let badgeLabel, !badgeLabel.isEmpty {
305
- Badge(label: badgeLabel).offset(x: Spacing.S, y: -Spacing.XS)
306
- } else if badgeLabel != nil || item.showDot {
307
- BadgeDot(size: .small)
308
- }
309
- }
310
- }
311
- }
312
-
313
- private struct DuoQrButton: View {
183
+ /// Center action of the rail: round button with its label, under the container.
184
+ private struct RailCenterAction: View {
314
185
  let data: BottomTabFloatingButton
315
- let size: CGFloat
316
-
317
- @Environment(\.appTheme) private var theme
318
186
 
319
187
  var body: some View {
320
- SwiftUI.Button(action: data.onPress) {
321
- Circle()
322
- .fill(theme.colors.primary)
323
- .frame(width: size, height: size)
324
- .overlay(Icon(source: data.icon, size: qrIconSize, color: Colors.black01))
325
- }
326
- .buttonStyle(.plain)
327
- .accessibilityLabel(data.label)
188
+ SwiftUI.Button(action: data.onPress) { EmptyView() }
189
+ .buttonStyle(CenterActionStyle(size: TabBarMetrics.railCtaSize, vertical: true, icon: data.icon,
190
+ iconContent: data.iconContent, labelContent: data.labelContent,
191
+ label: data.label, fixedFontScale: true))
192
+ .frame(width: TabBarMetrics.railCtaWidth, height: TabBarMetrics.railCtaHeight)
193
+ .accessibilityLabel(data.label)
194
+ .accessibilityIdentifier(data.label)
328
195
  }
329
196
  }
@@ -0,0 +1,84 @@
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
+ static let indicatorRadius = Radius.XL
22
+ // home indicator / gesture bar area under the container
23
+ static let systemIndicatorHeight: CGFloat = 24
24
+ // unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
25
+ // centered; phones and folded outer displays fill the window
26
+ static let foldableMinShortSide: CGFloat = 600
27
+ static let foldableWidthRatio: CGFloat = 0.65
28
+ static let ctaSlotWidth: CGFloat = 92
29
+ static let ctaSize: CGFloat = 48
30
+ // the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
31
+ static let ctaIconSize: CGFloat = 28
32
+ // the button rises 22 above the container top edge
33
+ static let ctaLift: CGFloat = 22
34
+ static let ctaLabelGap = Spacing.M
35
+ static let ctaLabelHeight: CGFloat = 18
36
+ // notch dipped into the container top edge under the center action (Figma "Backgroud" path):
37
+ // starts notchHalfWidth left of the center, then cubic segments of control1, control2, end,
38
+ // each point as (dx from the center, dy below the top edge)
39
+ static let notchHalfWidth: CGFloat = 50.758
40
+ static let notchCurves: [[CGPoint]] = [
41
+ [CGPoint(x: -39.749, y: 0), CGPoint(x: -31.231, y: 9.765), CGPoint(x: -24.563, y: 18.526)],
42
+ [CGPoint(x: -18.928, y: 25.93), CGPoint(x: -10.022, y: 30.709), CGPoint(x: 0, y: 30.709)],
43
+ [CGPoint(x: 10.022, y: 30.709), CGPoint(x: 18.928, y: 25.93), CGPoint(x: 24.563, y: 18.526)],
44
+ [CGPoint(x: 31.231, y: 9.765), CGPoint(x: 39.749, y: 0), CGPoint(x: notchHalfWidth, y: 0)],
45
+ ]
46
+ static let railContainerWidth: CGFloat = 56
47
+ static let railPaddingHorizontal = Spacing.XS
48
+ static let railPaddingBottom = Spacing.S
49
+ static let railItemWidth: CGFloat = 48
50
+ static let railItemHeight: CGFloat = 62
51
+ static let railIndicatorHeight: CGFloat = 40
52
+ static let railIndicatorRadius: CGFloat = 20
53
+ static let railCtaGap = Spacing.L
54
+ static let railCtaSize: CGFloat = 52
55
+ static let railCtaLabelGap = Spacing.XS
56
+ static let railCtaWidth: CGFloat = 68
57
+ static let railCtaHeight: CGFloat = 70
58
+ static let badgeMaxWidth: CGFloat = 58
59
+
60
+ // motion (MoMo Navigation Prototype): one active indicator slides to the selected item overshooting
61
+ // a little, icon and label tint cross-fade, the center action shrinks while held
62
+ static let indicatorMotion = Animation.timingCurve(0.34, 1.4, 0.5, 1, duration: 0.55)
63
+ static let tintMotion = Animation.easeInOut(duration: 0.25)
64
+ static let ctaPressMotion = Animation.easeOut(duration: 0.15)
65
+ static let ctaPressedScale: CGFloat = 0.92
66
+
67
+ /// Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window
68
+ /// minus the side safe areas and margins.
69
+ static func horizontalBarWidth(_ layout: ScreenLayout) -> CGFloat {
70
+ let shortSide = min(layout.width, layout.height)
71
+ if shortSide >= foldableMinShortSide { return shortSide * foldableWidthRatio }
72
+ return layout.width - layout.insets.leading - layout.insets.trailing - 2 * margin
73
+ }
74
+
75
+ /// Gap under the container: the home indicator area.
76
+ static func bottomGap(_ bottomInset: CGFloat) -> CGFloat {
77
+ max(min(bottomInset, systemIndicatorHeight), Spacing.S)
78
+ }
79
+
80
+ /// The center action needs a tab on each side: Special type takes 2 or 4 tabs.
81
+ static func hasCenterAction(_ floatingButton: BottomTabFloatingButton?, tabCount: Int) -> Bool {
82
+ floatingButton != nil && tabCount % 2 == 0
83
+ }
84
+ }
@@ -359,7 +359,7 @@ struct Toolkit: View {
359
359
  }
360
360
  toolButton(icon: headerRight.closeIcon, accessibilityId: "btn_navigation_close", action: onPressClose)
361
361
  }
362
- .frame(width: 65, height: 28)
362
+ .frame(width: usesHelpCenter(context) ? 65 : 28, height: 28)
363
363
  .background(headerColor.backgroundButton)
364
364
  .cornerRadius(14)
365
365
  .overlay(RoundedRectangle(cornerRadius: 14).stroke(headerColor.borderColor, lineWidth: 0.2))
@@ -24,9 +24,11 @@ struct ModalScreen<Content: View>: View {
24
24
  @State private var didAppear = false
25
25
 
26
26
  var body: some View {
27
+ let modal = layout.modalLayout
28
+ let placement = modal.placement
27
29
  ZStack {
28
- // Dimmed scrim (mirrors `Color.Black.copy(alpha = 0.6f * alpha)`).
29
- Color.black.opacity(0.6 * scrimOpacity)
30
+ // full screen on foldables too, over the iPhone Duo control column
31
+ Colors.black20.opacity(modal.scrimOpacity * scrimOpacity)
30
32
  .ignoresSafeArea()
31
33
  .contentShape(Rectangle())
32
34
  .onTapGesture {
@@ -34,15 +36,24 @@ struct ModalScreen<Content: View>: View {
34
36
  }
35
37
 
36
38
  content()
37
- // iPhone Duo: capped so it stays a dialog on the inner display; nil leaves the size alone
39
+ // foldables: capped by the spec; nil leaves the size alone
38
40
  .frame(
39
- maxWidth: layout.isDuoDevice ? layout.duoModalMaxWidth : nil,
40
- maxHeight: layout.isDuoDevice ? layout.duoModalMaxHeight : nil
41
+ maxWidth: modal.isFoldable ? modal.popup.maxWidth : nil,
42
+ maxHeight: modal.isFoldable ? (modal.popup.maxHeight ?? placement.height) : nil
41
43
  )
42
44
  .scaleEffect(contentScale)
43
45
  .opacity(contentOpacity)
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())
46
+ // center in the placement: the safe area, or the right half of a half-folded iPhone Duo
47
+ .padding(
48
+ modal.isFoldable
49
+ ? EdgeInsets(
50
+ top: placement.minY,
51
+ leading: placement.minX,
52
+ bottom: layout.height - placement.maxY,
53
+ trailing: layout.width - placement.maxX
54
+ )
55
+ : EdgeInsets()
56
+ )
46
57
  }
47
58
  // Full screen like RN's Modal, so asymmetric landscape insets don't shift the content sideways.
48
59
  .frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -573,7 +573,8 @@ private struct StackScreenContent<Content: View>: View {
573
573
  var animatedSearchInset: CGFloat = 0
574
574
  /// Room for a header the content scrolls under (iPhone Duo glass header).
575
575
  var topInset: CGFloat = 0
576
- /// 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.
577
578
  var bottomInset: CGFloat = 0
578
579
  /// Compose's animated-search snap: a scroll that comes to rest part way through this distance
579
580
  /// finishes the move, up or back down.
@@ -644,6 +645,7 @@ private struct StackScreenContent<Content: View>: View {
644
645
  }
645
646
  }
646
647
  } else {
648
+ // static tab content stays above the floating tab bar
647
649
  content()
648
650
  .padding(.top, topInset)
649
651
  .padding(.bottom, bottomInset)
@@ -70,6 +70,7 @@ public struct PopupDisplay: View {
70
70
  }
71
71
  VStack(alignment: .leading, spacing: 0) {
72
72
  MomoText(title, typography: .headerDefaultBold, maxLines: 2, accessibilityId: "title_popup_permission")
73
+ .padding(.trailing, isShowCloseIcon && url.isEmpty ? ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL : 0)
73
74
  .padding(.top, 24)
74
75
  .padding(.bottom, 8)
75
76
 
@@ -110,8 +111,9 @@ public struct PopupDisplay: View {
110
111
  .clipShape(RoundedRectangle(cornerRadius: layout.popupRadius()))
111
112
 
112
113
  if isShowCloseIcon {
113
- PopupCloseButton(action: onClose)
114
- .offset(x: 11, y: -11)
114
+ ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onClose)
115
+ .padding(.top, Spacing.M)
116
+ .padding(.trailing, Spacing.M)
115
117
  }
116
118
  }
117
119
  .frame(maxWidth: layout.popupMaxWidth)
@@ -29,6 +29,7 @@ public struct PopupInput: View {
29
29
  VStack {
30
30
  VStack(alignment: .leading) {
31
31
  MomoText(title, typography: .headerDefaultBold)
32
+ .padding(.trailing, ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL)
32
33
  .padding(.top, 12)
33
34
  .padding(.bottom, 24)
34
35
 
@@ -55,8 +56,9 @@ public struct PopupInput: View {
55
56
 
56
57
  }.clipped()
57
58
 
58
- PopupCloseButton(action: onPressClose)
59
- .offset(x: 11, y: -11)
59
+ ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onPressClose)
60
+ .padding(.top, Spacing.M)
61
+ .padding(.trailing, Spacing.M)
60
62
  }
61
63
  }
62
64
  .background(theme.colors.background.surface.cornerRadius(layout.popupRadius(8)))
@@ -2,25 +2,26 @@ import SDWebImageSwiftUI
2
2
  import SwiftUI
3
3
 
4
4
  extension ScreenLayout {
5
- /// Card width cap on iPhone Duo (the modal bounds, Compose `popupMaxWidth`); unbounded elsewhere,
5
+ /// Card width on foldables (`modalLayout`, Compose `popupMaxWidth`); unbounded on phones,
6
6
  /// where the popup's own padding sets the width.
7
7
  var popupMaxWidth: CGFloat {
8
- isDuoDevice ? duoModalMaxWidth : .infinity
8
+ let modal = modalLayout
9
+ return modal.isFoldable ? modal.popup.maxWidth : .infinity
9
10
  }
10
11
 
11
- /// The modal bounds already keep iPhone Duo popups off the edges, so their own side padding goes.
12
+ /// The placement already keeps foldable popups off the edges, so their own side padding goes.
12
13
  func popupHorizontalPadding(_ padding: CGFloat) -> CGFloat {
13
- isDuoDevice ? 0 : padding
14
+ modalLayout.isFoldable ? 0 : padding
14
15
  }
15
16
 
16
- /// Tallest a popup gets on iPhone Duo, landscape and the inner display included; nil elsewhere.
17
+ /// Tallest a popup gets on foldables; nil on phones.
17
18
  var popupMaxHeight: CGFloat? {
18
- isDuoDevice ? duoModalMaxHeight : nil
19
+ modalLayout.popup.maxHeight
19
20
  }
20
21
 
21
- /// Rounder on iPhone Duo, closer to its system alerts.
22
22
  func popupRadius(_ regular: CGFloat = Radius.L) -> CGFloat {
23
- isDuoDevice ? Radius.XL : regular
23
+ let modal = modalLayout
24
+ return modal.isFoldable ? modal.popup.radius : regular
24
25
  }
25
26
  }
26
27
 
@@ -87,7 +88,7 @@ extension View {
87
88
  }
88
89
  }
89
90
 
90
- /// 22pt round close button shared by the popups (Compose `PopupNotify` / `PopupPromotion`).
91
+ /// 22pt round close button under `PopupPromotion`'s image (Compose `PopupPromotion`).
91
92
  struct PopupCloseButton: View {
92
93
  @Environment(\.appTheme) private var theme
93
94
  var tapSize: CGFloat = 22