@momo-kits/native-kits 0.300.7 → 0.300.8-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
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.
|
|
7
|
-
//
|
|
1
|
+
// iPhone Duo tab bar, port of RN `BottomTab/DuoTabBar.tsx` (Figma "Specs Navigation", DS-984):
|
|
2
|
+
// a rail in the side bar, or the horizontal bar at 65% of the short side when unfolded portrait.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
11
|
-
private let
|
|
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)
|
|
6
|
+
private let compactSize = DuoMetrics.controlSize
|
|
29
7
|
|
|
30
8
|
/// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
|
|
31
9
|
struct DuoTabBarInsets: Equatable {
|
|
@@ -46,45 +24,34 @@ extension EnvironmentValues {
|
|
|
46
24
|
}
|
|
47
25
|
}
|
|
48
26
|
|
|
49
|
-
/// Rail plus the
|
|
27
|
+
/// Rail container plus the center action under it; compressed, the rail is a single button.
|
|
50
28
|
func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
29
|
+
var rail = CGFloat(itemCount) * TabBarMetrics.railItemHeight + TabBarMetrics.railPaddingBottom
|
|
30
|
+
if compressed {
|
|
31
|
+
rail = compactSize
|
|
32
|
+
}
|
|
33
|
+
return rail + (hasQr ? TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight : 0)
|
|
54
34
|
}
|
|
55
35
|
|
|
56
36
|
extension ScreenLayout {
|
|
57
|
-
///
|
|
37
|
+
/// The horizontal bar sits above the home indicator area.
|
|
58
38
|
var duoFloatingTabBarBottom: CGFloat {
|
|
59
|
-
|
|
39
|
+
TabBarMetrics.bottomGap(insets.bottom)
|
|
60
40
|
}
|
|
61
41
|
|
|
62
42
|
func duoTabBarInsets(itemCount: Int, hasFloatingButton: Bool, tabBarCompressed: Bool = false) -> DuoTabBarInsets {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
43
|
+
// the horizontal bar floats over the content (phone and unfolded Duo); the overlay is measured
|
|
44
|
+
// from the bottom safe area, the bar reaches into it
|
|
45
|
+
guard isIPhoneDuo, let sideBar else {
|
|
46
|
+
// the center action's button rises above the bar, tab content leaves room for it too
|
|
47
|
+
let ctaLift = hasFloatingButton && itemCount % 2 == 0 ? TabBarMetrics.ctaLift : 0
|
|
48
|
+
return DuoTabBarInsets(overlay: TabBarMetrics.height + ctaLift + duoFloatingTabBarBottom - insets.bottom)
|
|
67
49
|
}
|
|
68
50
|
let rail = duoRailHeight(itemCount: itemCount, hasQr: hasFloatingButton, compressed: tabBarCompressed)
|
|
69
51
|
return DuoTabBarInsets(sideBarReserve: sideBar.bottom + rail + DuoBarCompression.groupGap)
|
|
70
52
|
}
|
|
71
53
|
}
|
|
72
54
|
|
|
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
55
|
struct DuoTabBar: View {
|
|
89
56
|
let items: [BottomTabItem]
|
|
90
57
|
let floatingButton: BottomTabFloatingButton?
|
|
@@ -105,9 +72,8 @@ struct DuoTabBar: View {
|
|
|
105
72
|
}
|
|
106
73
|
}
|
|
107
74
|
|
|
108
|
-
/// Vertical bar
|
|
109
|
-
///
|
|
110
|
-
/// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
|
|
75
|
+
/// Vertical bar at the bottom of the side bar, center action below. A short side bar shrinks it to one button showing
|
|
76
|
+
/// the current tab (HIG "Tab bar compressed"); a tap expands the rail and compresses the toolbar.
|
|
111
77
|
private struct DuoRailTabBar: View {
|
|
112
78
|
let sideBar: SideBarLayout
|
|
113
79
|
let items: [BottomTabItem]
|
|
@@ -116,20 +82,20 @@ private struct DuoRailTabBar: View {
|
|
|
116
82
|
let onTabSelected: (Int) -> Void
|
|
117
83
|
let compression: DuoBarCompression
|
|
118
84
|
|
|
119
|
-
@
|
|
85
|
+
@Environment(\.appTheme) private var theme
|
|
120
86
|
|
|
121
87
|
private var isRight: Bool { sideBar.edge == .right }
|
|
122
88
|
|
|
123
89
|
var body: some View {
|
|
124
|
-
VStack(spacing:
|
|
90
|
+
VStack(spacing: TabBarMetrics.railCtaGap) {
|
|
125
91
|
if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
|
|
126
92
|
SwiftUI.Button(action: compression.expandTabBar) {
|
|
127
|
-
|
|
128
|
-
.frame(width:
|
|
93
|
+
TabIcon(item: items[selectedIndex], selected: true, vertical: true)
|
|
94
|
+
.frame(width: compactSize, height: compactSize)
|
|
129
95
|
.contentShape(Circle())
|
|
130
96
|
}
|
|
131
97
|
.buttonStyle(.plain)
|
|
132
|
-
.modifier(
|
|
98
|
+
.modifier(TabBarContainer(shape: Circle()))
|
|
133
99
|
.accessibilityLabel(items[selectedIndex].label)
|
|
134
100
|
.accessibilityIdentifier("bottom_tab_bar")
|
|
135
101
|
} else {
|
|
@@ -137,9 +103,12 @@ private struct DuoRailTabBar: View {
|
|
|
137
103
|
}
|
|
138
104
|
|
|
139
105
|
if let floatingButton {
|
|
140
|
-
|
|
106
|
+
RailCenterAction(data: floatingButton)
|
|
141
107
|
}
|
|
142
108
|
}
|
|
109
|
+
// the rail lines up with the header buttons in the side bar: centered on a 48 lane kept
|
|
110
|
+
// Spacing.M from the strip's inner edge; the wider rail and center action overflow it evenly
|
|
111
|
+
.frame(width: compactSize)
|
|
143
112
|
.padding(isRight ? .leading : .trailing, Spacing.M)
|
|
144
113
|
.frame(width: sideBar.width, alignment: isRight ? .leading : .trailing)
|
|
145
114
|
.padding(.bottom, sideBar.bottom)
|
|
@@ -147,39 +116,42 @@ private struct DuoRailTabBar: View {
|
|
|
147
116
|
.ignoresSafeArea()
|
|
148
117
|
}
|
|
149
118
|
|
|
150
|
-
/// Column of
|
|
119
|
+
/// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
|
|
151
120
|
private var rail: some View {
|
|
152
121
|
ZStack(alignment: .top) {
|
|
153
|
-
|
|
154
|
-
.frame(width:
|
|
155
|
-
.offset(y:
|
|
156
|
-
|
|
157
|
-
.animation(tabSpring, value: selectedIndex)
|
|
158
|
-
.animation(tabSpring, value: pressedIndex)
|
|
122
|
+
ActiveIndicator(radius: TabBarMetrics.railIndicatorRadius)
|
|
123
|
+
.frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railIndicatorHeight)
|
|
124
|
+
.offset(y: Spacing.XS + CGFloat(selectedIndex) * TabBarMetrics.railItemHeight)
|
|
125
|
+
.animation(TabBarMetrics.indicatorMotion, value: selectedIndex)
|
|
159
126
|
|
|
160
|
-
VStack(spacing:
|
|
127
|
+
VStack(spacing: 0) {
|
|
161
128
|
ForEach(items.indices, id: \.self) { index in
|
|
162
129
|
SwiftUI.Button {
|
|
163
130
|
onTabSelected(index)
|
|
164
131
|
compression.onTabSelected()
|
|
165
132
|
} label: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
133
|
+
VStack(spacing: 0) {
|
|
134
|
+
TabItemContent(item: items[index], selected: index == selectedIndex, vertical: true)
|
|
135
|
+
}
|
|
136
|
+
.frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railItemHeight)
|
|
137
|
+
.contentShape(Rectangle())
|
|
169
138
|
}
|
|
170
|
-
.buttonStyle(
|
|
139
|
+
.buttonStyle(.plain)
|
|
171
140
|
.accessibilityLabel(items[index].label)
|
|
141
|
+
.accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
|
|
172
142
|
}
|
|
173
143
|
}
|
|
174
|
-
.padding(.vertical, railPadding)
|
|
175
144
|
}
|
|
176
|
-
.
|
|
177
|
-
.
|
|
145
|
+
.padding(.horizontal, TabBarMetrics.railPaddingHorizontal)
|
|
146
|
+
.padding(.bottom, TabBarMetrics.railPaddingBottom)
|
|
147
|
+
.frame(width: TabBarMetrics.railContainerWidth)
|
|
148
|
+
.modifier(TabBarContainer(shape: RoundedRectangle(cornerRadius: Radius.XL)))
|
|
149
|
+
.accessibilityElement(children: .contain)
|
|
178
150
|
.accessibilityIdentifier("bottom_tab_bar")
|
|
179
151
|
}
|
|
180
152
|
}
|
|
181
153
|
|
|
182
|
-
///
|
|
154
|
+
/// Horizontal navigation bar of the unfolded display: 65% of the short side, centered.
|
|
183
155
|
private struct DuoFloatingTabBar: View {
|
|
184
156
|
let items: [BottomTabItem]
|
|
185
157
|
let floatingButton: BottomTabFloatingButton?
|
|
@@ -187,143 +159,36 @@ private struct DuoFloatingTabBar: View {
|
|
|
187
159
|
let onTabSelected: (Int) -> Void
|
|
188
160
|
|
|
189
161
|
@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
162
|
|
|
202
163
|
var body: some View {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
164
|
+
HorizontalTabBar(
|
|
165
|
+
items: items,
|
|
166
|
+
floatingButton: floatingButton,
|
|
167
|
+
selectedIndex: selectedIndex,
|
|
168
|
+
onTabSelected: onTabSelected,
|
|
169
|
+
width: TabBarMetrics.horizontalBarWidth(
|
|
170
|
+
layout,
|
|
171
|
+
itemCount: items.count,
|
|
172
|
+
hasCta: TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count)
|
|
173
|
+
)
|
|
174
|
+
)
|
|
210
175
|
.padding(.bottom, layout.duoFloatingTabBarBottom)
|
|
211
176
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
|
|
212
177
|
.ignoresSafeArea()
|
|
213
178
|
}
|
|
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
|
-
}
|
|
258
|
-
|
|
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
179
|
}
|
|
288
180
|
|
|
289
|
-
|
|
290
|
-
|
|
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 {
|
|
181
|
+
/// Center action of the rail: round button with its label, under the container.
|
|
182
|
+
private struct RailCenterAction: View {
|
|
314
183
|
let data: BottomTabFloatingButton
|
|
315
|
-
let size: CGFloat
|
|
316
|
-
|
|
317
|
-
@Environment(\.appTheme) private var theme
|
|
318
184
|
|
|
319
185
|
var body: some View {
|
|
320
|
-
SwiftUI.Button(action: data.onPress) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
.accessibilityLabel(data.label)
|
|
186
|
+
SwiftUI.Button(action: data.onPress) { EmptyView() }
|
|
187
|
+
.buttonStyle(CenterActionStyle(size: TabBarMetrics.railCtaSize, vertical: true, icon: data.icon,
|
|
188
|
+
iconContent: data.iconContent, labelContent: data.labelContent,
|
|
189
|
+
label: data.label))
|
|
190
|
+
.frame(width: TabBarMetrics.railCtaWidth, height: TabBarMetrics.railCtaHeight)
|
|
191
|
+
.accessibilityLabel(data.label)
|
|
192
|
+
.accessibilityIdentifier(data.label)
|
|
328
193
|
}
|
|
329
194
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from Compose's `TabBarMetrics.kt` and RN
|
|
2
|
+
// `BottomTab/metrics.ts`. Horizontal: floating, center action in a notch; vertical: iPhone Duo rail, action under it.
|
|
3
|
+
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
enum TabBarMetrics {
|
|
7
|
+
static let height: CGFloat = 60
|
|
8
|
+
static let margin = Spacing.S
|
|
9
|
+
static let paddingVertical = Spacing.XS
|
|
10
|
+
static let paddingHorizontal = Spacing.M
|
|
11
|
+
static let itemGap: CGFloat = 1
|
|
12
|
+
// gap between the icon slot and the label inside a tab (Figma: none)
|
|
13
|
+
static let itemIconLabelGap: CGFloat = 0
|
|
14
|
+
// .Nav/Background: no backdrop blur, so use the Figma Blur=Off spec (opacity 95%, no blur) plus the 1px
|
|
15
|
+
// border below — nearly solid, matching the frosted sample; surface keeps dark-mode support
|
|
16
|
+
static let backgroundOpacity: CGFloat = 0.95
|
|
17
|
+
// white 60% hairline around the center action button (Figma Icon Button border)
|
|
18
|
+
static let ctaBorderOpacity: CGFloat = 0.6
|
|
19
|
+
static let iconSize: CGFloat = 24
|
|
20
|
+
static let indicatorHeight: CGFloat = 32
|
|
21
|
+
// label_s_medium / label_xs_medium line heights: the label slot keeps this height so a scaled
|
|
22
|
+
// label overflows downward instead of pushing the icon up
|
|
23
|
+
static let labelHeight: CGFloat = 18
|
|
24
|
+
static let railLabelHeight: CGFloat = 14
|
|
25
|
+
// font scale cap for the whole bar (RN ScaleSizeProvider around renderTabBar): its text follows the
|
|
26
|
+
// OS/host scale up to 1.2× so the fixed-height container and the notch stay aligned
|
|
27
|
+
static let labelMaxScale: CGFloat = 1.2
|
|
28
|
+
static let indicatorRadius = Radius.XL
|
|
29
|
+
// home indicator / gesture bar area under the container
|
|
30
|
+
static let systemIndicatorHeight: CGFloat = 24
|
|
31
|
+
// unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
|
|
32
|
+
// centered; phones and folded outer displays fill the window
|
|
33
|
+
static let foldableMinShortSide: CGFloat = 600
|
|
34
|
+
static let foldableWidthRatio: CGFloat = 0.65
|
|
35
|
+
// a 2-tab bar doesn't stretch to the full width: each item is this fixed width and the bar is sized
|
|
36
|
+
// to its content, centered (Figma Navigation · 2 Tab: item 100, bar ~225)
|
|
37
|
+
static let twoTabItemWidth: CGFloat = 100
|
|
38
|
+
static let ctaSlotWidth: CGFloat = 92
|
|
39
|
+
static let ctaSize: CGFloat = 48
|
|
40
|
+
// the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
|
|
41
|
+
static let ctaIconSize: CGFloat = 28
|
|
42
|
+
// the button rises 22 above the container top edge
|
|
43
|
+
static let ctaLift: CGFloat = 22
|
|
44
|
+
static let ctaLabelGap = Spacing.M
|
|
45
|
+
static let ctaLabelHeight: CGFloat = 18
|
|
46
|
+
// container-top notch under the center action (Figma "Backgroud" path): from notchHalfWidth left of the center,
|
|
47
|
+
// cubic segments [control1, control2, end], each point (dx from the center, dy below the top edge)
|
|
48
|
+
static let notchHalfWidth: CGFloat = 50.758
|
|
49
|
+
static let notchCurves: [[CGPoint]] = [
|
|
50
|
+
[CGPoint(x: -39.749, y: 0), CGPoint(x: -31.231, y: 9.765), CGPoint(x: -24.563, y: 18.526)],
|
|
51
|
+
[CGPoint(x: -18.928, y: 25.93), CGPoint(x: -10.022, y: 30.709), CGPoint(x: 0, y: 30.709)],
|
|
52
|
+
[CGPoint(x: 10.022, y: 30.709), CGPoint(x: 18.928, y: 25.93), CGPoint(x: 24.563, y: 18.526)],
|
|
53
|
+
[CGPoint(x: 31.231, y: 9.765), CGPoint(x: 39.749, y: 0), CGPoint(x: notchHalfWidth, y: 0)],
|
|
54
|
+
]
|
|
55
|
+
static let railContainerWidth: CGFloat = 56
|
|
56
|
+
static let railPaddingHorizontal = Spacing.XS
|
|
57
|
+
static let railPaddingBottom = Spacing.S
|
|
58
|
+
static let railItemWidth: CGFloat = 48
|
|
59
|
+
static let railItemHeight: CGFloat = 62
|
|
60
|
+
static let railIndicatorHeight: CGFloat = 40
|
|
61
|
+
static let railIndicatorRadius: CGFloat = 20
|
|
62
|
+
static let railCtaGap = Spacing.L
|
|
63
|
+
static let railCtaSize: CGFloat = 52
|
|
64
|
+
static let railCtaLabelGap = Spacing.XS
|
|
65
|
+
static let railCtaWidth: CGFloat = 68
|
|
66
|
+
static let railCtaHeight: CGFloat = 70
|
|
67
|
+
static let badgeMaxWidth: CGFloat = 58
|
|
68
|
+
|
|
69
|
+
// motion (MoMo Navigation Prototype): one active indicator slides to the selected item overshooting
|
|
70
|
+
// a little, icon and label tint cross-fade, the center action shrinks while held
|
|
71
|
+
static let indicatorMotion = Animation.timingCurve(0.34, 1.4, 0.5, 1, duration: 0.55)
|
|
72
|
+
static let tintMotion = Animation.easeInOut(duration: 0.25)
|
|
73
|
+
static let ctaPressMotion = Animation.easeOut(duration: 0.15)
|
|
74
|
+
static let ctaPressedScale: CGFloat = 0.92
|
|
75
|
+
|
|
76
|
+
/// Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window
|
|
77
|
+
/// minus the side safe areas and margins.
|
|
78
|
+
static func horizontalBarWidth(_ layout: ScreenLayout, itemCount: Int, hasCta: Bool) -> CGFloat {
|
|
79
|
+
// 2 tabs (no center action) stay content-sized and centered instead of filling the window
|
|
80
|
+
if itemCount == 2 && !hasCta {
|
|
81
|
+
return twoTabItemWidth * 2 + paddingHorizontal * 2 + itemGap
|
|
82
|
+
}
|
|
83
|
+
let shortSide = min(layout.width, layout.height)
|
|
84
|
+
if shortSide >= foldableMinShortSide { return shortSide * foldableWidthRatio }
|
|
85
|
+
return layout.width - layout.insets.leading - layout.insets.trailing - 2 * margin
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// Gap under the container: the home indicator area.
|
|
89
|
+
static func bottomGap(_ bottomInset: CGFloat) -> CGFloat {
|
|
90
|
+
max(min(bottomInset, systemIndicatorHeight), Spacing.S)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// The center action needs a tab on each side: Special type takes 2 or 4 tabs.
|
|
94
|
+
static func hasCenterAction(_ floatingButton: BottomTabFloatingButton?, tabCount: Int) -> Bool {
|
|
95
|
+
floatingButton != nil && tabCount % 2 == 0
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/FloatingButton.kt`: the screen FAB, whose
|
|
6
|
-
// label collapses while the content scrolls down.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/FloatingButton.kt`: the screen FAB, whose
|
|
2
|
+
// label collapses while the content scrolls down.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
11
6
|
public enum FABSize {
|
|
12
7
|
case small
|
|
13
8
|
case `default`
|
|
14
|
-
///
|
|
15
|
-
/// size `DEFAULT`.
|
|
9
|
+
/// Older iOS name for `default` (Compose `DEFAULT`), kept for existing call sites.
|
|
16
10
|
case large
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
public enum FABPosition {
|
|
20
14
|
case end
|
|
21
|
-
///
|
|
22
|
-
/// position `END`.
|
|
15
|
+
/// Older iOS name for `end` (Compose `END`), kept for existing call sites.
|
|
23
16
|
case right
|
|
24
17
|
case center
|
|
25
18
|
}
|