@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
|
@@ -15,16 +15,25 @@ import SwiftUI
|
|
|
15
15
|
|
|
16
16
|
/// Mirrors Compose's `sealed class BottomHeader` (Title / Custom).
|
|
17
17
|
public struct BottomSheetHeader {
|
|
18
|
+
struct Back {
|
|
19
|
+
let icon: String
|
|
20
|
+
let action: () -> Void
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
enum Style {
|
|
19
|
-
case title(String)
|
|
24
|
+
case title(String, back: Back?)
|
|
20
25
|
case custom(() -> AnyView)
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
let style: Style
|
|
24
29
|
|
|
25
|
-
/// Mirrors `BottomHeader.Title`.
|
|
26
|
-
public static func title(
|
|
27
|
-
|
|
30
|
+
/// Mirrors `BottomHeader.Title`. `onBack` shows a back button; the sheet closes, then it runs.
|
|
31
|
+
public static func title(
|
|
32
|
+
_ text: String = "Bottom Sheet Title",
|
|
33
|
+
backIcon: String = "arrow-back",
|
|
34
|
+
onBack: (() -> Void)? = nil
|
|
35
|
+
) -> BottomSheetHeader {
|
|
36
|
+
BottomSheetHeader(style: .title(text, back: onBack.map { Back(icon: backIcon, action: $0) }))
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
/// Mirrors `BottomHeader.Custom`.
|
|
@@ -68,6 +77,9 @@ struct BottomSheetView<Content: View>: View {
|
|
|
68
77
|
/// Mirrors Compose's `sheetCloseOffset` (100dp drag threshold to dismiss).
|
|
69
78
|
private let closeThreshold: CGFloat = 100
|
|
70
79
|
|
|
80
|
+
private let indicatorHeight: CGFloat = 16
|
|
81
|
+
private let headerRowHeight: CGFloat = 56
|
|
82
|
+
|
|
71
83
|
/// Mirrors Compose's per-term peak (0.3f). Combined with `backgroundAlpha` the
|
|
72
84
|
/// steady-state (fully open) scrim peaks at 0.6, matching ModalScreen's peak.
|
|
73
85
|
private let maxDynamicAlpha: CGFloat = 0.3
|
|
@@ -77,7 +89,23 @@ struct BottomSheetView<Content: View>: View {
|
|
|
77
89
|
|
|
78
90
|
private var isDuo: Bool { layout.isDuoDevice }
|
|
79
91
|
// iPhone Duo inner display: center the sheet instead of spanning the width
|
|
80
|
-
|
|
92
|
+
// short side, as RN: the outer display stays floating in landscape (678pt wide) too
|
|
93
|
+
private var isDuoCentered: Bool { isDuo && min(layout.width, layout.height) >= 600 }
|
|
94
|
+
/// Outer display: the sheet floats Spacing.M off the side edges like system sheets, its content
|
|
95
|
+
/// stays in the safe area and its buttons move to the side bar column (HIG).
|
|
96
|
+
private var isDuoFloating: Bool { isDuo && !isDuoCentered }
|
|
97
|
+
|
|
98
|
+
private var titleBack: BottomSheetHeader.Back? {
|
|
99
|
+
if case .title(_, let back) = header.style { return back }
|
|
100
|
+
return nil
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private var sideColumn: SideBarLayout? {
|
|
104
|
+
guard isDuoFloating, case .title = header.style, let sideBar = layout.sideBar,
|
|
105
|
+
sideBar.width - Spacing.M >= DuoMetrics.controlSize + Spacing.M
|
|
106
|
+
else { return nil }
|
|
107
|
+
return sideBar
|
|
108
|
+
}
|
|
81
109
|
|
|
82
110
|
/// Keeps the portrait width in landscape, like system sheets.
|
|
83
111
|
private var duoCenteredWidth: CGFloat {
|
|
@@ -87,18 +115,20 @@ struct BottomSheetView<Content: View>: View {
|
|
|
87
115
|
)
|
|
88
116
|
}
|
|
89
117
|
|
|
90
|
-
///
|
|
91
|
-
/// side status bar only covers the top corner.
|
|
118
|
+
/// The floating sheet spans the side safe area, its content stays clear of it.
|
|
92
119
|
private var sideInsetLeading: CGFloat {
|
|
93
|
-
|
|
120
|
+
isDuoFloating ? max(layout.insets.leading - Spacing.M, 0) : 0
|
|
94
121
|
}
|
|
95
122
|
|
|
96
123
|
private var sideInsetTrailing: CGFloat {
|
|
97
|
-
|
|
124
|
+
isDuoFloating ? max(layout.insets.trailing - Spacing.M, 0) : 0
|
|
98
125
|
}
|
|
99
126
|
|
|
100
127
|
private var maxHeight: CGFloat {
|
|
101
|
-
isDuo
|
|
128
|
+
guard isDuo else { return screenHeight - 90 }
|
|
129
|
+
// stays below the side status bar: unlike RN (StatusBar.pushStackEntry) nothing restyles it, so a light
|
|
130
|
+
// clock over the sheet would vanish
|
|
131
|
+
return layout.height - max(layout.duoTopInset, Spacing.XL)
|
|
102
132
|
}
|
|
103
133
|
private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
|
|
104
134
|
/// While the keyboard is up, it already covers the home-indicator area, so it
|
|
@@ -169,20 +199,23 @@ struct BottomSheetView<Content: View>: View {
|
|
|
169
199
|
.fill(Colors.black06)
|
|
170
200
|
.frame(width: 40, height: 4)
|
|
171
201
|
Spacer().frame(height: 4)
|
|
202
|
+
// the handle centers on the whole sheet, only the header row keeps clear of the strip
|
|
172
203
|
headerView
|
|
173
|
-
.frame(height:
|
|
204
|
+
.frame(height: headerRowHeight)
|
|
174
205
|
.padding(.horizontal, Spacing.M)
|
|
175
206
|
.padding(.leading, sideInsetLeading)
|
|
176
207
|
.padding(.trailing, sideInsetTrailing)
|
|
177
208
|
}
|
|
178
209
|
.frame(maxWidth: .infinity)
|
|
179
|
-
.frame(height:
|
|
210
|
+
.frame(height: indicatorHeight + headerRowHeight)
|
|
180
211
|
.contentShape(Rectangle())
|
|
181
212
|
.gesture(dragGesture, including: draggable ? .all : .subviews)
|
|
182
213
|
|
|
183
214
|
Rectangle()
|
|
184
215
|
.fill(theme.colors.border.default)
|
|
185
216
|
.frame(height: 1)
|
|
217
|
+
.padding(.leading, sideInsetLeading)
|
|
218
|
+
.padding(.trailing, sideInsetTrailing)
|
|
186
219
|
|
|
187
220
|
content()
|
|
188
221
|
.padding(.leading, sideInsetLeading)
|
|
@@ -191,7 +224,7 @@ struct BottomSheetView<Content: View>: View {
|
|
|
191
224
|
.layoutPriority(-1)
|
|
192
225
|
|
|
193
226
|
if let footer {
|
|
194
|
-
BottomSheetFooter(content: footer)
|
|
227
|
+
BottomSheetFooter(content: footer, leadingInset: sideInsetLeading, trailingInset: sideInsetTrailing)
|
|
195
228
|
}
|
|
196
229
|
}
|
|
197
230
|
// The filler stays outside the cap, which shrinks by it instead: the sheet still ends at
|
|
@@ -209,27 +242,61 @@ struct BottomSheetView<Content: View>: View {
|
|
|
209
242
|
}
|
|
210
243
|
)
|
|
211
244
|
.background(backgroundColor)
|
|
212
|
-
.
|
|
245
|
+
.overlay {
|
|
246
|
+
if let sideColumn {
|
|
247
|
+
BottomSheetSideColumn(
|
|
248
|
+
sideBar: sideColumn,
|
|
249
|
+
windowHeight: layout.height,
|
|
250
|
+
topOffset: indicatorHeight + (headerRowHeight - DuoMetrics.controlSize) / 2,
|
|
251
|
+
back: titleBack,
|
|
252
|
+
onBack: goBack,
|
|
253
|
+
onClose: { close() }
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
.clipShape(RoundedCorner(radius: isDuo ? Radius.XL : Radius.M, corners: [.topLeft, .topRight]))
|
|
258
|
+
.padding(.horizontal, isDuoFloating ? Spacing.M : 0)
|
|
213
259
|
}
|
|
214
260
|
|
|
215
261
|
@ViewBuilder
|
|
216
262
|
private var headerView: some View {
|
|
217
263
|
switch header.style {
|
|
218
|
-
case .title(let text):
|
|
264
|
+
case .title(let text, let back):
|
|
265
|
+
// the side column holds back and close, the row keeps only the title
|
|
266
|
+
let showsButtons = sideColumn == nil
|
|
219
267
|
HStack(spacing: 0) {
|
|
220
|
-
|
|
268
|
+
if showsButtons {
|
|
269
|
+
if let back {
|
|
270
|
+
headerButton(icon: back.icon, accessibilityId: "btn_bottom_sheet_back") { goBack(back) }
|
|
271
|
+
} else {
|
|
272
|
+
Color.clear.frame(width: 24, height: 24)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
221
275
|
MomoText(text, typography: .headerDefaultBold, color: Colors.black17)
|
|
222
276
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
277
|
+
.padding(.horizontal, showsButtons ? 0 : Spacing.M)
|
|
278
|
+
if showsButtons {
|
|
279
|
+
headerButton(icon: "navigation_close", accessibilityId: "btn_bottom_sheet_close") { close() }
|
|
280
|
+
}
|
|
227
281
|
}
|
|
228
282
|
case .custom(let builder):
|
|
229
283
|
builder()
|
|
230
284
|
}
|
|
231
285
|
}
|
|
232
286
|
|
|
287
|
+
private func headerButton(icon: String, accessibilityId: String, action: @escaping () -> Void) -> some View {
|
|
288
|
+
Icon(source: icon, size: 24, color: Colors.black17)
|
|
289
|
+
.frame(width: 24, height: 24)
|
|
290
|
+
.contentShape(Rectangle())
|
|
291
|
+
.onTapGesture(perform: action)
|
|
292
|
+
.accessibilityIdentifier(accessibilityId)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs.
|
|
296
|
+
private func goBack(_ back: BottomSheetHeader.Back) {
|
|
297
|
+
close(then: back.action)
|
|
298
|
+
}
|
|
299
|
+
|
|
233
300
|
// MARK: - Drag handling (mirrors Compose's detectDragGestures)
|
|
234
301
|
|
|
235
302
|
private var dragGesture: some Gesture {
|
|
@@ -282,7 +349,7 @@ struct BottomSheetView<Content: View>: View {
|
|
|
282
349
|
|
|
283
350
|
/// Mirrors Compose's `closeEvent`: slide out over 200ms, then fade the scrim
|
|
284
351
|
/// out over 100ms only after the slide finishes, then dismiss.
|
|
285
|
-
private func close() {
|
|
352
|
+
private func close(then onClosed: (() -> Void)? = nil) {
|
|
286
353
|
guard !isClosing else { return }
|
|
287
354
|
isClosing = true
|
|
288
355
|
withAnimation(.timingCurve(0.3, 0, 0.8, 0.15, duration: 0.2)) {
|
|
@@ -294,7 +361,67 @@ struct BottomSheetView<Content: View>: View {
|
|
|
294
361
|
}
|
|
295
362
|
}
|
|
296
363
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
364
|
+
// a newer overlay replaced this one: it stays, and this sheet's back is dropped
|
|
365
|
+
guard navigator.overplay?.id == overplayId else { return }
|
|
297
366
|
navigator.finishOverplayDismiss(id: overplayId)
|
|
367
|
+
onClosed?()
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/// iPhone Duo outer display: back and close sit on the part of the sheet under the side safe area,
|
|
373
|
+
/// 12pt from the strip's inner edge like the screen side bar. They follow the header row while the
|
|
374
|
+
/// sheet is short and stay below the status bar cluster while it is tall.
|
|
375
|
+
private struct BottomSheetSideColumn: View {
|
|
376
|
+
let sideBar: SideBarLayout
|
|
377
|
+
let windowHeight: CGFloat
|
|
378
|
+
/// Lines the controls up with the header row.
|
|
379
|
+
let topOffset: CGFloat
|
|
380
|
+
let back: BottomSheetHeader.Back?
|
|
381
|
+
let onBack: (BottomSheetHeader.Back) -> Void
|
|
382
|
+
let onClose: () -> Void
|
|
383
|
+
|
|
384
|
+
@Environment(\.appTheme) private var theme
|
|
385
|
+
|
|
386
|
+
private var isRight: Bool { sideBar.edge == .right }
|
|
387
|
+
|
|
388
|
+
private var columnHeight: CGFloat {
|
|
389
|
+
let count: CGFloat = back != nil ? 2 : 1
|
|
390
|
+
return count * DuoMetrics.controlSize + (count - 1) * Spacing.M
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
private var headerColor: HeaderColor {
|
|
394
|
+
getHeaderColor(isAnimated: false, isSurface: true, opacity: 1, tintColor: nil, defaultColor: theme.colors.text.default)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
var body: some View {
|
|
398
|
+
GeometryReader { proxy in
|
|
399
|
+
let sheetHeight = proxy.size.height
|
|
400
|
+
// the sheet rests on the window bottom; its slide is an offset outside this layout
|
|
401
|
+
let sheetTop = windowHeight - sheetHeight
|
|
402
|
+
// clear of a camera at the bottom end of the strip when it can
|
|
403
|
+
let lowest = sheetHeight - sideBar.bottom - columnHeight
|
|
404
|
+
let top = max(min(max(sideBar.top - sheetTop, topOffset), lowest), 0)
|
|
405
|
+
VStack(alignment: isRight ? .leading : .trailing, spacing: Spacing.M) {
|
|
406
|
+
if let back {
|
|
407
|
+
SideBarButton(
|
|
408
|
+
icon: back.icon,
|
|
409
|
+
headerColor: headerColor,
|
|
410
|
+
accessibilityId: "btn_bottom_sheet_back",
|
|
411
|
+
action: { onBack(back) }
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
SideBarButton(
|
|
415
|
+
icon: "navigation_close",
|
|
416
|
+
headerColor: headerColor,
|
|
417
|
+
accessibilityId: "btn_bottom_sheet_close",
|
|
418
|
+
action: onClose
|
|
419
|
+
)
|
|
420
|
+
}
|
|
421
|
+
.padding(isRight ? .leading : .trailing, Spacing.M)
|
|
422
|
+
.frame(width: sideBar.width - Spacing.M, alignment: isRight ? .leading : .trailing)
|
|
423
|
+
.padding(.top, top)
|
|
424
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: isRight ? .topTrailing : .topLeading)
|
|
298
425
|
}
|
|
299
426
|
}
|
|
300
427
|
}
|
|
@@ -371,12 +498,16 @@ private struct CapHeightLayout: Layout {
|
|
|
371
498
|
/// Mirrors Compose's `BottomSheetFooter`: a surface band with a soft shadow cast on the content.
|
|
372
499
|
private struct BottomSheetFooter: View {
|
|
373
500
|
let content: () -> AnyView
|
|
501
|
+
var leadingInset: CGFloat = 0
|
|
502
|
+
var trailingInset: CGFloat = 0
|
|
374
503
|
|
|
375
504
|
@Environment(\.appTheme) private var theme
|
|
376
505
|
|
|
377
506
|
var body: some View {
|
|
378
507
|
content()
|
|
379
508
|
.frame(maxWidth: .infinity)
|
|
509
|
+
.padding(.leading, leadingInset)
|
|
510
|
+
.padding(.trailing, trailingInset)
|
|
380
511
|
.padding(.vertical, Spacing.S)
|
|
381
512
|
.background(theme.colors.background.surface)
|
|
382
513
|
.overlay(alignment: .top) {
|
|
@@ -53,10 +53,9 @@ public struct BottomTab: View {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
private var bottomInset: CGFloat { safeAreaBottomInset() }
|
|
56
|
-
// the
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
56
|
+
// the bars float over the content (tab screens keep clear of them through duoTabBarInsets) or sit
|
|
57
|
+
// in the side strip, so only the home indicator is kept clear
|
|
58
|
+
private var reservedBottom: CGFloat { layout.insets.bottom }
|
|
60
59
|
|
|
61
60
|
private var compression: DuoBarCompression {
|
|
62
61
|
DuoBarCompression.resolve(
|
|
@@ -104,18 +103,13 @@ public struct BottomTab: View {
|
|
|
104
103
|
compression: compression
|
|
105
104
|
)
|
|
106
105
|
} else {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
theme.colors.background.surface
|
|
116
|
-
.frame(height: bottomInset + Spacing.S)
|
|
117
|
-
.ignoresSafeArea(edges: .horizontal)
|
|
118
|
-
}
|
|
106
|
+
BottomTabBar(
|
|
107
|
+
items: items,
|
|
108
|
+
floatingButton: floatingButton,
|
|
109
|
+
selectedIndex: selectedIndex,
|
|
110
|
+
onTabSelected: selectTab,
|
|
111
|
+
bottomInset: bottomInset
|
|
112
|
+
)
|
|
119
113
|
}
|
|
120
114
|
}
|
|
121
115
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
@@ -137,6 +131,7 @@ public struct BottomTab: View {
|
|
|
137
131
|
}
|
|
138
132
|
|
|
139
133
|
private func selectTab(_ index: Int) {
|
|
134
|
+
navigator.maxApi?.triggerEventVibration("light")
|
|
140
135
|
let switchTab = { if index != selectedIndex { selectedIndex = index } }
|
|
141
136
|
if let onTabPress { onTabPress(index, switchTab) } else { switchTab() }
|
|
142
137
|
}
|
|
@@ -325,8 +320,7 @@ private struct TabCard: View {
|
|
|
325
320
|
|
|
326
321
|
/// Bottom safe-area inset (home indicator).
|
|
327
322
|
private func safeAreaBottomInset() -> CGFloat {
|
|
328
|
-
|
|
323
|
+
UIApplication.shared.connectedScenes
|
|
329
324
|
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
330
325
|
.first ?? 0
|
|
331
|
-
return min(bottomInset, 21)
|
|
332
326
|
}
|