@momo-kits/native-kits 0.168.1-beta.30-debug → 0.168.1-beta.31
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 +2 -1
- package/ios/Input/Input.swift +3 -1
- package/ios/Input/InputTextArea.swift +3 -1
- package/ios/Navigation/BottomTab/BottomTab.swift +33 -14
- package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -254
- package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
- package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
- package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -71
- package/ios/Navigation/StackScreen.swift +1 -3
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -224
- package/package.json +1 -1
- package/build.gradle.kts +0 -11
- package/compose/build.gradle.kts +0 -198
- package/compose/build.gradle.kts.backup +0 -198
- package/compose/compose.podspec +0 -47
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -224
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -383
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -94
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -203
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
- package/gradle/libs.versions.toml +0 -69
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -8
- package/gradle.properties +0 -26
- package/gradlew +0 -252
- package/gradlew.bat +0 -94
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +0 -88
- package/ios-demo/README.md +0 -120
- package/local.properties +0 -9
- package/settings.gradle.kts +0 -64
|
@@ -2,13 +2,29 @@
|
|
|
2
2
|
// DuoTabBar.swift
|
|
3
3
|
// MoMoUIKits
|
|
4
4
|
//
|
|
5
|
-
// iPhone Duo tab bar, port of RN `BottomTab/DuoTabBar.tsx` (Figma
|
|
6
|
-
// a rail in the side bar, or
|
|
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
7
|
//
|
|
8
8
|
|
|
9
9
|
import SwiftUI
|
|
10
10
|
|
|
11
|
-
private let
|
|
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
|
+
// the rail's badge stays inside the capsule: its end sits XXS off the cell's end edge
|
|
24
|
+
private let railBadgeMaxWidth = itemSize - Spacing.XXS * 2
|
|
25
|
+
private let railBadgeEndOffset = (itemSize - iconSize) / 2 - Spacing.XXS
|
|
26
|
+
// Figma Home-2026 tab bar "Selection": brand pink at 8%
|
|
27
|
+
private let selectionTintOpacity: Double = 0x14 / 255
|
|
12
28
|
|
|
13
29
|
/// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
|
|
14
30
|
struct DuoTabBarInsets: Equatable {
|
|
@@ -29,54 +45,70 @@ extension EnvironmentValues {
|
|
|
29
45
|
}
|
|
30
46
|
}
|
|
31
47
|
|
|
32
|
-
/// Rail
|
|
48
|
+
/// Rail plus the QR button under it; compressed, the rail is a single button.
|
|
33
49
|
func duoRailHeight(itemCount: Int, hasQr: Bool, compressed: Bool = false) -> CGFloat {
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return rail + (hasQr ? TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight : 0)
|
|
50
|
+
let count = CGFloat(itemCount)
|
|
51
|
+
let rail = compressed ? itemSize : railPadding * 2 + count * itemSize + max(count - 1, 0) * railGap
|
|
52
|
+
return rail + (hasQr ? Spacing.M + itemSize : 0)
|
|
38
53
|
}
|
|
39
54
|
|
|
40
55
|
extension ScreenLayout {
|
|
41
|
-
///
|
|
56
|
+
/// Overlaps the home indicator inset like the system tab bar (21pt above the bottom with a 34pt inset).
|
|
42
57
|
var duoFloatingTabBarBottom: CGFloat {
|
|
43
|
-
|
|
58
|
+
max(insets.bottom - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S)
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
func duoTabBarInsets(itemCount: Int, hasFloatingButton: Bool, tabBarCompressed: Bool = false) -> DuoTabBarInsets {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let ctaLift = hasFloatingButton && itemCount % 2 == 0 ? TabBarMetrics.ctaLift : 0
|
|
52
|
-
return DuoTabBarInsets(overlay: TabBarMetrics.height + ctaLift + duoFloatingTabBarBottom - insets.bottom)
|
|
62
|
+
guard isIPhoneDuo else { return DuoTabBarInsets() }
|
|
63
|
+
guard let sideBar else {
|
|
64
|
+
// overlay is measured from the bottom safe area, the bar reaches into it
|
|
65
|
+
return DuoTabBarInsets(overlay: floatingHeight + duoFloatingTabBarBottom - insets.bottom)
|
|
53
66
|
}
|
|
54
67
|
let rail = duoRailHeight(itemCount: itemCount, hasQr: hasFloatingButton, compressed: tabBarCompressed)
|
|
55
68
|
return DuoTabBarInsets(sideBarReserve: sideBar.bottom + rail + DuoBarCompression.groupGap)
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
|
|
72
|
+
/// RN `BarMaterial`: surface with a 1pt border.
|
|
73
|
+
struct DuoBarMaterial<S: InsettableShape>: ViewModifier {
|
|
74
|
+
let shape: S
|
|
75
|
+
|
|
76
|
+
@Environment(\.appTheme) private var theme
|
|
77
|
+
|
|
78
|
+
func body(content: Content) -> some View {
|
|
79
|
+
content.background(
|
|
80
|
+
shape.fill(theme.colors.background.surface)
|
|
81
|
+
.overlay(shape.strokeBorder(theme.colors.border.default, lineWidth: 1))
|
|
82
|
+
.allowsHitTesting(false)
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
59
87
|
struct DuoTabBar: View {
|
|
60
88
|
let items: [BottomTabItem]
|
|
61
89
|
let floatingButton: BottomTabFloatingButton?
|
|
62
90
|
let selectedIndex: Int
|
|
63
91
|
let onTabSelected: (Int) -> Void
|
|
64
92
|
var compression = DuoBarCompression()
|
|
93
|
+
var onTabLongPress: ((Int) -> Void)?
|
|
94
|
+
/// A tick per tab the lens enters while dragged.
|
|
95
|
+
var onTick: () -> Void = {}
|
|
65
96
|
|
|
66
97
|
@Environment(\.screenLayout) private var layout
|
|
67
98
|
|
|
68
99
|
var body: some View {
|
|
69
100
|
if let sideBar = layout.sideBar {
|
|
70
101
|
DuoRailTabBar(sideBar: sideBar, items: items, floatingButton: floatingButton,
|
|
71
|
-
selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression
|
|
102
|
+
selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression,
|
|
103
|
+
onTabLongPress: onTabLongPress, onTick: onTick)
|
|
72
104
|
} else {
|
|
73
|
-
DuoFloatingTabBar(items: items, floatingButton: floatingButton,
|
|
74
|
-
|
|
105
|
+
DuoFloatingTabBar(items: items, floatingButton: floatingButton, selectedIndex: selectedIndex,
|
|
106
|
+
onTabSelected: onTabSelected, onTabLongPress: onTabLongPress, onTick: onTick)
|
|
75
107
|
}
|
|
76
108
|
}
|
|
77
109
|
}
|
|
78
110
|
|
|
79
|
-
/// Vertical bar anchored to the bottom of the side bar,
|
|
111
|
+
/// Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E).
|
|
80
112
|
/// When the side bar is short it can shrink to one button showing the current tab
|
|
81
113
|
/// (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
|
|
82
114
|
private struct DuoRailTabBar: View {
|
|
@@ -86,21 +118,24 @@ private struct DuoRailTabBar: View {
|
|
|
86
118
|
let selectedIndex: Int
|
|
87
119
|
let onTabSelected: (Int) -> Void
|
|
88
120
|
let compression: DuoBarCompression
|
|
121
|
+
let onTabLongPress: ((Int) -> Void)?
|
|
122
|
+
let onTick: () -> Void
|
|
89
123
|
|
|
90
|
-
@Environment(\.
|
|
124
|
+
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
|
125
|
+
@StateObject private var selection = DuoLiquidSelection()
|
|
91
126
|
|
|
92
127
|
private var isRight: Bool { sideBar.edge == .right }
|
|
93
128
|
|
|
94
129
|
var body: some View {
|
|
95
|
-
VStack(spacing:
|
|
130
|
+
VStack(spacing: Spacing.M) {
|
|
96
131
|
if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
|
|
97
132
|
SwiftUI.Button(action: compression.expandTabBar) {
|
|
98
|
-
|
|
99
|
-
.frame(width:
|
|
133
|
+
DuoTabIcon(item: items[selectedIndex], selected: true, badgeMaxWidth: railBadgeMaxWidth, inRail: true)
|
|
134
|
+
.frame(width: itemSize, height: itemSize)
|
|
100
135
|
.contentShape(Circle())
|
|
101
136
|
}
|
|
102
|
-
.buttonStyle(
|
|
103
|
-
.modifier(
|
|
137
|
+
.buttonStyle(DuoPressLiftStyle())
|
|
138
|
+
.modifier(DuoBarMaterial(shape: Circle()))
|
|
104
139
|
.accessibilityLabel(items[selectedIndex].label)
|
|
105
140
|
.accessibilityIdentifier("bottom_tab_bar")
|
|
106
141
|
} else {
|
|
@@ -108,12 +143,9 @@ private struct DuoRailTabBar: View {
|
|
|
108
143
|
}
|
|
109
144
|
|
|
110
145
|
if let floatingButton {
|
|
111
|
-
|
|
146
|
+
DuoQrButton(data: floatingButton, size: itemSize)
|
|
112
147
|
}
|
|
113
148
|
}
|
|
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)
|
|
117
149
|
.padding(isRight ? .leading : .trailing, Spacing.M)
|
|
118
150
|
.frame(width: sideBar.width, alignment: isRight ? .leading : .trailing)
|
|
119
151
|
.padding(.bottom, sideBar.bottom)
|
|
@@ -121,75 +153,264 @@ private struct DuoRailTabBar: View {
|
|
|
121
153
|
.ignoresSafeArea()
|
|
122
154
|
}
|
|
123
155
|
|
|
124
|
-
|
|
156
|
+
private func select(_ index: Int) {
|
|
157
|
+
onTabSelected(index)
|
|
158
|
+
compression.onTabSelected()
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/// Column of icon-only tab items with the sliding selection lens.
|
|
125
162
|
private var rail: some View {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
.
|
|
163
|
+
let selection = configured()
|
|
164
|
+
let lens = selection.lensScale
|
|
165
|
+
return ZStack(alignment: .top) {
|
|
166
|
+
DuoSelectionMaterial()
|
|
167
|
+
.frame(width: railBubbleWidth, height: railBubbleHeight)
|
|
168
|
+
.scaleEffect(x: lens.x * lens.across, y: lens.y * lens.along)
|
|
169
|
+
.offset(y: railPadding - (railBubbleHeight - itemSize) / 2 + selection.offset)
|
|
131
170
|
|
|
132
|
-
VStack(spacing:
|
|
171
|
+
VStack(spacing: railGap) {
|
|
133
172
|
ForEach(items.indices, id: \.self) { index in
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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())
|
|
173
|
+
DuoLiquidTab(selection: selection, index: index, label: items[index].label,
|
|
174
|
+
selected: index == selectedIndex, onSelect: { select(index) }) { active in
|
|
175
|
+
DuoTabIcon(item: items[index], selected: active, badgeMaxWidth: railBadgeMaxWidth, inRail: true)
|
|
176
|
+
.frame(width: itemSize, height: itemSize)
|
|
143
177
|
}
|
|
144
|
-
.buttonStyle(.plain)
|
|
145
|
-
.accessibilityLabel(items[index].label)
|
|
146
|
-
.accessibilityAddTraits(index == selectedIndex ? .isSelected : [])
|
|
147
178
|
}
|
|
148
179
|
}
|
|
180
|
+
.padding(.vertical, railPadding)
|
|
149
181
|
}
|
|
150
|
-
.
|
|
151
|
-
.
|
|
152
|
-
.
|
|
153
|
-
.
|
|
154
|
-
.accessibilityElement(children: .contain)
|
|
182
|
+
.frame(width: itemSize)
|
|
183
|
+
.modifier(DuoLiquidInput(selection: selection, space: "DuoRail"))
|
|
184
|
+
.modifier(DuoBarMaterial(shape: Capsule()))
|
|
185
|
+
.scaleEffect(selection.barScale)
|
|
155
186
|
.accessibilityIdentifier("bottom_tab_bar")
|
|
187
|
+
.onAppear { selection.sync(index: selectedIndex) }
|
|
188
|
+
.onChange(of: selectedIndex) { selection.sync(index: $0) }
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private func configured() -> DuoLiquidSelection {
|
|
192
|
+
selection.axis = .y
|
|
193
|
+
selection.count = items.count
|
|
194
|
+
selection.pitch = itemSize + railGap
|
|
195
|
+
selection.firstCenter = railPadding + itemSize / 2
|
|
196
|
+
selection.reduceMotion = reduceMotion
|
|
197
|
+
selection.onSelect = select
|
|
198
|
+
selection.onLongPress = onTabLongPress
|
|
199
|
+
selection.onTick = onTick
|
|
200
|
+
return selection
|
|
156
201
|
}
|
|
157
202
|
}
|
|
158
203
|
|
|
159
|
-
///
|
|
204
|
+
/// Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
|
|
160
205
|
private struct DuoFloatingTabBar: View {
|
|
161
206
|
let items: [BottomTabItem]
|
|
162
207
|
let floatingButton: BottomTabFloatingButton?
|
|
163
208
|
let selectedIndex: Int
|
|
164
209
|
let onTabSelected: (Int) -> Void
|
|
210
|
+
let onTabLongPress: ((Int) -> Void)?
|
|
211
|
+
let onTick: () -> Void
|
|
165
212
|
|
|
166
213
|
@Environment(\.screenLayout) private var layout
|
|
214
|
+
@Environment(\.appTheme) private var theme
|
|
215
|
+
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
|
216
|
+
@StateObject private var selection = DuoLiquidSelection()
|
|
217
|
+
|
|
218
|
+
private var barWidth: CGFloat {
|
|
219
|
+
let margins = layout.insets.leading + layout.insets.trailing + 2 * DuoMetrics.floatingTabBarMargin
|
|
220
|
+
let qr = floatingButton == nil ? 0 : floatingHeight + Spacing.S
|
|
221
|
+
let preferred = CGFloat(items.count) * floatingItemWidth + 2 * floatingPadding
|
|
222
|
+
return max(min(preferred, layout.width - margins - qr), 0)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private var cellWidth: CGFloat { (barWidth - floatingPadding * 2) / CGFloat(max(items.count, 1)) }
|
|
167
226
|
|
|
168
227
|
var body: some View {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
floatingButton
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
228
|
+
HStack(spacing: Spacing.S) {
|
|
229
|
+
bar
|
|
230
|
+
if let floatingButton {
|
|
231
|
+
DuoQrButton(data: floatingButton, size: floatingHeight)
|
|
232
|
+
.shadow(color: Color.black.opacity(0.16), radius: 16, x: 0, y: 6)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
177
235
|
.padding(.bottom, layout.duoFloatingTabBarBottom)
|
|
178
236
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
|
|
179
237
|
.ignoresSafeArea()
|
|
180
238
|
}
|
|
239
|
+
|
|
240
|
+
private var bar: some View {
|
|
241
|
+
let selection = configured()
|
|
242
|
+
let lens = selection.lensScale
|
|
243
|
+
return ZStack(alignment: .leading) {
|
|
244
|
+
DuoSelectionMaterial()
|
|
245
|
+
.frame(width: cellWidth)
|
|
246
|
+
.scaleEffect(x: lens.x * lens.along, y: lens.y * lens.across)
|
|
247
|
+
.offset(x: selection.offset)
|
|
248
|
+
|
|
249
|
+
HStack(spacing: 0) {
|
|
250
|
+
ForEach(items.indices, id: \.self) { index in
|
|
251
|
+
DuoLiquidTab(selection: selection, index: index, label: items[index].label,
|
|
252
|
+
selected: index == selectedIndex, onSelect: { onTabSelected(index) }) { active in
|
|
253
|
+
tabCell(index, active: active)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
.modifier(DuoLiquidInput(selection: selection, space: "DuoFloatingBar"))
|
|
259
|
+
.padding(floatingPadding)
|
|
260
|
+
.frame(width: barWidth, height: floatingHeight)
|
|
261
|
+
.modifier(DuoBarMaterial(shape: Capsule()))
|
|
262
|
+
.scaleEffect(selection.barScale)
|
|
263
|
+
.accessibilityIdentifier("bottom_tab_bar")
|
|
264
|
+
.onAppear { selection.sync(index: selectedIndex) }
|
|
265
|
+
.onChange(of: selectedIndex) { selection.sync(index: $0) }
|
|
266
|
+
.onChange(of: cellWidth) { _ in selection.sync(index: selectedIndex) }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
private func configured() -> DuoLiquidSelection {
|
|
270
|
+
selection.axis = .x
|
|
271
|
+
selection.count = items.count
|
|
272
|
+
selection.pitch = cellWidth
|
|
273
|
+
selection.firstCenter = cellWidth / 2
|
|
274
|
+
selection.reduceMotion = reduceMotion
|
|
275
|
+
selection.onSelect = onTabSelected
|
|
276
|
+
selection.onLongPress = onTabLongPress
|
|
277
|
+
selection.onTick = onTick
|
|
278
|
+
return selection
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private func tabCell(_ index: Int, active: Bool) -> some View {
|
|
282
|
+
VStack(spacing: Spacing.XXS) {
|
|
283
|
+
DuoTabIcon(item: items[index], selected: active, badgeMaxWidth: cellWidth / 2 - Spacing.XXS)
|
|
284
|
+
MomoText(
|
|
285
|
+
items[index].label,
|
|
286
|
+
typography: .labelXsMedium,
|
|
287
|
+
color: active ? theme.colors.primary : theme.colors.text.hint,
|
|
288
|
+
textAlign: .center,
|
|
289
|
+
maxLines: 1
|
|
290
|
+
)
|
|
291
|
+
// like the system tab bar the label keeps its design size; a constant snapshot, nothing to observe
|
|
292
|
+
.environment(\.momoFontScale, FontScale(userScaleRate: 1, useOSScaleRate: false))
|
|
293
|
+
}
|
|
294
|
+
.frame(width: cellWidth)
|
|
295
|
+
.frame(maxHeight: .infinity)
|
|
296
|
+
}
|
|
181
297
|
}
|
|
182
298
|
|
|
183
|
-
///
|
|
184
|
-
|
|
299
|
+
/// One gesture over the whole bar drives the selection; SwiftUI drops `onEnded` when the system
|
|
300
|
+
/// cancels a touch, so the reset of the gesture state ends it instead.
|
|
301
|
+
private struct DuoLiquidInput: ViewModifier {
|
|
302
|
+
let selection: DuoLiquidSelection
|
|
303
|
+
let space: String
|
|
304
|
+
|
|
305
|
+
@GestureState private var touching = false
|
|
306
|
+
|
|
307
|
+
func body(content: Content) -> some View {
|
|
308
|
+
content
|
|
309
|
+
.coordinateSpace(name: space)
|
|
310
|
+
.contentShape(Rectangle())
|
|
311
|
+
.gesture(
|
|
312
|
+
DragGesture(minimumDistance: 0, coordinateSpace: .named(space))
|
|
313
|
+
.updating($touching) { _, state, _ in state = true }
|
|
314
|
+
.onChanged { selection.touchChanged(location: $0.location, translation: $0.translation, time: $0.time) }
|
|
315
|
+
.onEnded { selection.touchEnded(location: $0.location) }
|
|
316
|
+
)
|
|
317
|
+
.onChange(of: touching) { if !$0 { selection.touchCancelled() } }
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/// A tab drawn twice, inactive with the active layer over it fading in as the lens passes;
|
|
322
|
+
/// the tab the lens lands on pops.
|
|
323
|
+
private struct DuoLiquidTab<Content: View>: View {
|
|
324
|
+
@ObservedObject var selection: DuoLiquidSelection
|
|
325
|
+
let index: Int
|
|
326
|
+
let label: String
|
|
327
|
+
let selected: Bool
|
|
328
|
+
let onSelect: () -> Void
|
|
329
|
+
@ViewBuilder let content: (_ active: Bool) -> Content
|
|
330
|
+
|
|
331
|
+
var body: some View {
|
|
332
|
+
ZStack {
|
|
333
|
+
content(false)
|
|
334
|
+
content(true).opacity(selection.activeOpacity(index))
|
|
335
|
+
}
|
|
336
|
+
.scaleEffect(selection.popIndex == index ? selection.pop : 1)
|
|
337
|
+
.accessibilityElement(children: .ignore)
|
|
338
|
+
.accessibilityLabel(label)
|
|
339
|
+
.accessibilityAddTraits(selected ? [.isButton, .isSelected] : .isButton)
|
|
340
|
+
.accessibilityAction { onSelect() }
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/// Pink tinted capsule under the selected tab.
|
|
345
|
+
private struct DuoSelectionMaterial: View {
|
|
346
|
+
@Environment(\.appTheme) private var theme
|
|
347
|
+
|
|
348
|
+
var body: some View {
|
|
349
|
+
Capsule()
|
|
350
|
+
.fill(theme.colors.primary.opacity(selectionTintOpacity))
|
|
351
|
+
.allowsHitTesting(false)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/// Lift of a single button, e.g. the compressed rail (RN `usePressLift`).
|
|
356
|
+
private struct DuoPressLiftStyle: ButtonStyle {
|
|
357
|
+
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
|
358
|
+
|
|
359
|
+
func makeBody(configuration: Configuration) -> some View {
|
|
360
|
+
configuration.label
|
|
361
|
+
.scaleEffect(configuration.isPressed && !reduceMotion ? 1 + (liquidLensScaleX - 1) * 0.5 : 1)
|
|
362
|
+
.animation(liquidSpring, value: configuration.isPressed)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/// Floating bar: the badge starts at the icon's center and grows toward the cell's end edge.
|
|
367
|
+
/// Rail: it ends just inside the capsule and grows back over the icon (RN TabBarIcon `end: -3`).
|
|
368
|
+
/// Capped at `badgeMaxWidth` (an overlay alone would only offer it the icon's 28pt).
|
|
369
|
+
private struct DuoTabIcon: View {
|
|
370
|
+
let item: BottomTabItem
|
|
371
|
+
let selected: Bool
|
|
372
|
+
let badgeMaxWidth: CGFloat
|
|
373
|
+
var inRail = false
|
|
374
|
+
|
|
375
|
+
@Environment(\.appTheme) private var theme
|
|
376
|
+
|
|
377
|
+
private var badgeLabel: String? {
|
|
378
|
+
guard let label = item.badgeLabel else { return nil }
|
|
379
|
+
if let n = Int(label), n == 0 { return nil }
|
|
380
|
+
return label
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
var body: some View {
|
|
384
|
+
Icon(source: item.icon, size: iconSize, color: selected ? theme.colors.primary : theme.colors.text.hint)
|
|
385
|
+
.overlay(alignment: inRail ? .topTrailing : .topLeading) {
|
|
386
|
+
if let badgeLabel, !badgeLabel.isEmpty {
|
|
387
|
+
Badge(label: badgeLabel)
|
|
388
|
+
.frame(width: max(badgeMaxWidth, 0), alignment: inRail ? .trailing : .leading)
|
|
389
|
+
.offset(x: inRail ? railBadgeEndOffset : iconSize / 2, y: -Spacing.XS)
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
.overlay(alignment: .topTrailing) {
|
|
393
|
+
if badgeLabel?.isEmpty == true || (badgeLabel == nil && item.showDot) {
|
|
394
|
+
BadgeDot(size: .small)
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
private struct DuoQrButton: View {
|
|
185
401
|
let data: BottomTabFloatingButton
|
|
402
|
+
let size: CGFloat
|
|
403
|
+
|
|
404
|
+
@Environment(\.appTheme) private var theme
|
|
186
405
|
|
|
187
406
|
var body: some View {
|
|
188
|
-
SwiftUI.Button(action: data.onPress) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
407
|
+
SwiftUI.Button(action: data.onPress) {
|
|
408
|
+
Circle()
|
|
409
|
+
.fill(theme.colors.primary)
|
|
410
|
+
.frame(width: size, height: size)
|
|
411
|
+
.overlay(Icon(source: data.icon, size: qrIconSize, color: Colors.black01))
|
|
412
|
+
}
|
|
413
|
+
.buttonStyle(.plain)
|
|
414
|
+
.accessibilityLabel(data.label)
|
|
194
415
|
}
|
|
195
416
|
}
|
|
@@ -573,8 +573,7 @@ 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
|
|
577
|
-
/// ends clear of it, static content stays above it.
|
|
576
|
+
/// Room for a bar that overlays the content (iPhone Duo floating tab bar).
|
|
578
577
|
var bottomInset: CGFloat = 0
|
|
579
578
|
/// Compose's animated-search snap: a scroll that comes to rest part way through this distance
|
|
580
579
|
/// finishes the move, up or back down.
|
|
@@ -645,7 +644,6 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
645
644
|
}
|
|
646
645
|
}
|
|
647
646
|
} else {
|
|
648
|
-
// static tab content stays above the floating tab bar
|
|
649
647
|
content()
|
|
650
648
|
.padding(.top, topInset)
|
|
651
649
|
.padding(.bottom, bottomInset)
|
package/ios/native-kits.podspec
CHANGED