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