@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/compose/build.gradle.kts +2 -4
- package/compose/build.gradle.kts.backup +1 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
- package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
- package/gradle/libs.versions.toml +1 -3
- package/gradle.properties +1 -3
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
- package/scripts/ci/build-swiftui.sh +22 -0
- package/scripts/ci/resolve-version.mjs +144 -0
- package/settings.gradle.kts +0 -1
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/Header.kt`: the header bar (back button,
|
|
6
|
-
// title, header right), its colors, opacity and the header models.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/Header.kt`: the header bar (back button,
|
|
2
|
+
// title, header right), its colors, opacity and the header models.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
11
6
|
/// Header bar height, mirrors Compose's `HEADER_HEIGHT`.
|
|
12
7
|
public let HEADER_HEIGHT: CGFloat = 52
|
|
13
8
|
|
|
14
|
-
/// Room the back button and
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
private let statusBarRowActionsExtra: CGFloat = 55
|
|
9
|
+
/// Room the back button, the gaps around the title and the right cluster take from the header row
|
|
10
|
+
/// (Compose `HEADER_ACTIONS_WIDTH`).
|
|
11
|
+
let headerActionsWidth: CGFloat = HeaderLayoutMetrics.buttonSize + HeaderLayoutMetrics.titleGap * 2 + HeaderLayoutMetrics.clusterWidth
|
|
18
12
|
|
|
19
13
|
public enum TitlePosition {
|
|
20
14
|
case left, center
|
|
@@ -29,15 +23,19 @@ public struct AnimatedHeader {
|
|
|
29
23
|
public var aspectRatio: AnimatedHeaderRatio = .ratio16_9
|
|
30
24
|
public var isSurface: Bool = true
|
|
31
25
|
public var composable: (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
|
|
26
|
+
/// Wide windows: fills the sides of the phone-sized banner, fading out downward.
|
|
27
|
+
public var bannerBackgroundColor: Color?
|
|
32
28
|
|
|
33
29
|
public init(
|
|
34
30
|
aspectRatio: AnimatedHeaderRatio = .ratio16_9,
|
|
35
31
|
isSurface: Bool = true,
|
|
36
|
-
composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
|
|
32
|
+
composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) },
|
|
33
|
+
bannerBackgroundColor: Color? = nil
|
|
37
34
|
) {
|
|
38
35
|
self.aspectRatio = aspectRatio
|
|
39
36
|
self.isSurface = isSurface
|
|
40
37
|
self.composable = composable
|
|
38
|
+
self.bannerBackgroundColor = bannerBackgroundColor
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
|
|
@@ -291,10 +289,10 @@ func headerSearchProps(
|
|
|
291
289
|
}
|
|
292
290
|
|
|
293
291
|
/// Max title width: back button and toolkit share the bar unless the iPhone Duo side bar holds them.
|
|
294
|
-
func headerTitleMaxWidth(_ layout: ScreenLayout) -> CGFloat {
|
|
292
|
+
func headerTitleMaxWidth(_ layout: ScreenLayout, _ contentLayout: ContentLayout) -> CGFloat {
|
|
295
293
|
let clearance = layout.statusBarClearance.map { $0.left + $0.right } ?? 0
|
|
296
294
|
if layout.sideBar != nil { return layout.contentWidth - Spacing.M * 2 - clearance }
|
|
297
|
-
return layout.
|
|
295
|
+
return layout.headerLayout(contentLayout).frameWidth - headerActionsWidth - clearance
|
|
298
296
|
}
|
|
299
297
|
|
|
300
298
|
// MARK: - Header
|
|
@@ -344,20 +342,21 @@ public struct NavigationHeader: View {
|
|
|
344
342
|
}
|
|
345
343
|
|
|
346
344
|
@Environment(\.screenLayout) private var layout
|
|
345
|
+
@Environment(\.contentLayout) private var contentLayout
|
|
347
346
|
@Environment(\.appTheme) private var theme
|
|
348
347
|
@OptionalEnvironmentObject private var navigator: Navigator?
|
|
349
348
|
@State private var headerRightWidth: CGFloat = 0
|
|
350
349
|
|
|
350
|
+
private var headerLayout: HeaderLayout { layout.headerLayout(contentLayout) }
|
|
351
|
+
|
|
351
352
|
/// iPhone Duo side bar holds back and the toolkit; a custom header right stays in the bar.
|
|
352
353
|
private var useSideBar: Bool { layout.sideBar != nil }
|
|
353
354
|
|
|
354
|
-
///
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
/// Max centered title width; on the status bar row the clusters are lopsided, so both sides keep the wider one's room.
|
|
355
|
+
/// Max centered title width; on the status bar row the clusters are lopsided, so both sides
|
|
356
|
+
/// keep the wider one's room.
|
|
358
357
|
private var centerTitleMaxWidth: CGFloat {
|
|
359
|
-
guard let clearance = layout.statusBarClearance else { return
|
|
360
|
-
let back = goBack == nil || useSideBar ? 0 :
|
|
358
|
+
guard let clearance = layout.statusBarClearance else { return headerLayout.frameWidth / 2 }
|
|
359
|
+
let back = goBack == nil || useSideBar ? 0 : HeaderLayoutMetrics.buttonSize + HeaderLayoutMetrics.titleGap
|
|
361
360
|
let inset = max(clearance.left + back, clearance.right + headerRightWidth) + Spacing.S
|
|
362
361
|
return max(layout.contentWidth - (Spacing.M + inset) * 2, 0)
|
|
363
362
|
}
|
|
@@ -382,17 +381,8 @@ public struct NavigationHeader: View {
|
|
|
382
381
|
ZStack {
|
|
383
382
|
HStack(spacing: 0) {
|
|
384
383
|
if let goBack, !useSideBar {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
icon: "arrow-back",
|
|
388
|
-
headerColor: headerColor,
|
|
389
|
-
accessibilityId: "btn_navigation_back",
|
|
390
|
-
action: goBack
|
|
391
|
-
)
|
|
392
|
-
} else {
|
|
393
|
-
BackButton(color: headerColor, onBack: goBack)
|
|
394
|
-
}
|
|
395
|
-
Spacer().frame(width: Spacing.S)
|
|
384
|
+
BackButton(color: headerColor, onBack: goBack)
|
|
385
|
+
Spacer().frame(width: HeaderLayoutMetrics.titleGap)
|
|
396
386
|
}
|
|
397
387
|
|
|
398
388
|
if centerTitle {
|
|
@@ -403,33 +393,23 @@ public struct NavigationHeader: View {
|
|
|
403
393
|
}
|
|
404
394
|
|
|
405
395
|
if let headerRight, !(useSideBar && toolkitHeaderRight(headerRight) != nil) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
} else {
|
|
414
|
-
AnyView(headerRight())
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
.environment(\.headerColor, headerColor)
|
|
418
|
-
.background(
|
|
419
|
-
GeometryReader { geo in
|
|
420
|
-
Color.clear.preference(key: HeaderRightWidthKey.self, value: geo.size.width)
|
|
421
|
-
}
|
|
422
|
-
)
|
|
396
|
+
AnyView(headerRight())
|
|
397
|
+
.environment(\.headerColor, headerColor)
|
|
398
|
+
.background(
|
|
399
|
+
GeometryReader { geo in
|
|
400
|
+
Color.clear.preference(key: HeaderRightWidthKey.self, value: geo.size.width)
|
|
401
|
+
}
|
|
402
|
+
)
|
|
423
403
|
}
|
|
424
404
|
}
|
|
425
|
-
.padding(.leading,
|
|
426
|
-
.padding(.trailing,
|
|
405
|
+
.padding(.leading, headerLayout.frameInset + (layout.statusBarClearance?.left ?? 0))
|
|
406
|
+
.padding(.trailing, headerLayout.frameInset + (layout.statusBarClearance?.right ?? 0))
|
|
427
407
|
|
|
428
408
|
if centerTitle {
|
|
429
409
|
titleArea(centered: true)
|
|
430
410
|
// Compose caps a centered title at half the bar
|
|
431
411
|
.frame(maxWidth: centerTitleMaxWidth)
|
|
432
|
-
.padding(.horizontal,
|
|
412
|
+
.padding(.horizontal, headerLayout.frameInset)
|
|
433
413
|
}
|
|
434
414
|
}
|
|
435
415
|
.onPreferenceChange(HeaderRightWidthKey.self) { headerRightWidth = $0 }
|
|
@@ -452,6 +432,7 @@ public struct NavigationHeader: View {
|
|
|
452
432
|
theme: theme,
|
|
453
433
|
pop: navigator.map { navigator in { navigator.pop() } }
|
|
454
434
|
))
|
|
435
|
+
.headerSize()
|
|
455
436
|
} else {
|
|
456
437
|
switch headerTitle {
|
|
457
438
|
case let .user(data)?:
|
|
@@ -505,7 +486,7 @@ struct HeaderBarBackground: View {
|
|
|
505
486
|
|
|
506
487
|
// MARK: - Back button
|
|
507
488
|
|
|
508
|
-
/// Mirrors Compose's `BackButton`: a
|
|
489
|
+
/// Mirrors Compose's `BackButton`: a 32pt circle with the back arrow.
|
|
509
490
|
private struct BackButton: View {
|
|
510
491
|
let color: HeaderColor
|
|
511
492
|
let onBack: () -> Void
|
|
@@ -515,8 +496,8 @@ private struct BackButton: View {
|
|
|
515
496
|
Circle()
|
|
516
497
|
.fill(color.backgroundButton)
|
|
517
498
|
.overlay(Circle().stroke(color.borderColor, lineWidth: 0.2))
|
|
518
|
-
.frame(width:
|
|
519
|
-
.overlay(Icon(source: "arrow-back", size:
|
|
499
|
+
.frame(width: HeaderLayoutMetrics.buttonSize, height: HeaderLayoutMetrics.buttonSize)
|
|
500
|
+
.overlay(Icon(source: "arrow-back", size: HeaderLayoutMetrics.iconSize, color: color.tintIconColor))
|
|
520
501
|
}
|
|
521
502
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
522
503
|
.accessibilityIdentifier("btn_navigation_back")
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/HeaderBackground.kt`: the band behind the
|
|
6
|
-
// header — the pink gradient (or the theme's header image) fading into the screen background.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/HeaderBackground.kt`: the band behind the
|
|
2
|
+
// header — the pink gradient (or the theme's header image) fading into the screen background.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
@@ -143,7 +138,6 @@ struct DuoScrollGradient: View {
|
|
|
143
138
|
.allowsHitTesting(false)
|
|
144
139
|
}
|
|
145
140
|
|
|
146
|
-
/// The fade spans the gradient box.
|
|
147
141
|
private var gradient: LinearGradient {
|
|
148
142
|
LinearGradient(
|
|
149
143
|
colors: [theme.colors.gradient, theme.colors.gradient.opacity(0)],
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/HeaderJourney.kt`: a "start → end" title
|
|
6
|
-
// with an optional description below.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/HeaderJourney.kt`: a "start → end" title
|
|
2
|
+
// with an optional description below.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
@@ -18,6 +13,7 @@ public struct HeaderJourneyView: View {
|
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
@Environment(\.screenLayout) private var layout
|
|
16
|
+
@Environment(\.contentLayout) private var contentLayout
|
|
21
17
|
|
|
22
18
|
public var body: some View {
|
|
23
19
|
if data.isLoading {
|
|
@@ -50,7 +46,7 @@ public struct HeaderJourneyView: View {
|
|
|
50
46
|
MomoText(description, typography: .descriptionXsRegular, color: tint, maxLines: 1)
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
|
-
.frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
|
|
49
|
+
.frame(maxWidth: headerTitleMaxWidth(layout, contentLayout), alignment: .leading)
|
|
54
50
|
}
|
|
55
51
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
56
52
|
.disabled(data.onPress == nil)
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/HeaderLocation.kt`: a description above a
|
|
6
|
-
// tappable location with a chevron.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/HeaderLocation.kt`: a description above a
|
|
2
|
+
// tappable location with a chevron.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
@@ -18,6 +13,7 @@ public struct HeaderLocationView: View {
|
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
@Environment(\.screenLayout) private var layout
|
|
16
|
+
@Environment(\.contentLayout) private var contentLayout
|
|
21
17
|
|
|
22
18
|
public var body: some View {
|
|
23
19
|
if data.isLoading {
|
|
@@ -39,7 +35,7 @@ public struct HeaderLocationView: View {
|
|
|
39
35
|
Icon(source: "16_arrow_chevron_down_small", size: 16, color: tint)
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
|
-
.frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
|
|
38
|
+
.frame(maxWidth: headerTitleMaxWidth(layout, contentLayout), alignment: .leading)
|
|
43
39
|
}
|
|
44
40
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
45
41
|
.disabled(data.onPress == nil)
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/HeaderRight.kt`: the mini-app toolkit
|
|
6
|
-
// (shortcut / more / single tool, help center and close) in the bar or the iPhone Duo side bar.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/HeaderRight.kt`: the mini-app toolkit
|
|
2
|
+
// (shortcut / more / single tool, help center and close) in the bar or the iPhone Duo side bar.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
@@ -143,9 +138,9 @@ private struct NavigationButtonConfig {
|
|
|
143
138
|
let onPress: () -> Void
|
|
144
139
|
}
|
|
145
140
|
|
|
146
|
-
/// `sideBarColumn`: the iPhone Duo side bar; `
|
|
141
|
+
/// `sideBarColumn`: the iPhone Duo side bar, 48pt controls; `bar`: every header row, iPhone Duo status bar row included.
|
|
147
142
|
enum ToolkitLayout {
|
|
148
|
-
case bar, sideBarColumn
|
|
143
|
+
case bar, sideBarColumn
|
|
149
144
|
}
|
|
150
145
|
|
|
151
146
|
struct Toolkit: View {
|
|
@@ -298,16 +293,14 @@ struct Toolkit: View {
|
|
|
298
293
|
case .bar:
|
|
299
294
|
horizontalBody
|
|
300
295
|
case .sideBarColumn:
|
|
301
|
-
VStack(spacing: Spacing.M) { sideBarControls
|
|
302
|
-
case .sideBarRow:
|
|
303
|
-
HStack(spacing: Spacing.M) { sideBarControls(horizontal: true) }
|
|
296
|
+
VStack(spacing: Spacing.M) { sideBarControls }
|
|
304
297
|
}
|
|
305
298
|
}
|
|
306
299
|
.onAppear(perform: loadFavoriteState)
|
|
307
300
|
}
|
|
308
301
|
|
|
309
302
|
@ViewBuilder
|
|
310
|
-
private
|
|
303
|
+
private var sideBarControls: some View {
|
|
311
304
|
let config = navigationButtonConfig
|
|
312
305
|
let useHelpCenter = usesHelpCenter(context)
|
|
313
306
|
if showsShortcut(headerRight, context) {
|
|
@@ -319,7 +312,7 @@ struct Toolkit: View {
|
|
|
319
312
|
action: config.onPress
|
|
320
313
|
)
|
|
321
314
|
}
|
|
322
|
-
SideBarGroup(headerColor: headerColor, itemCount: useHelpCenter ? 2 : 1
|
|
315
|
+
SideBarGroup(headerColor: headerColor, itemCount: useHelpCenter ? 2 : 1) {
|
|
323
316
|
if useHelpCenter {
|
|
324
317
|
SideBarGroupItem(
|
|
325
318
|
icon: "help_center",
|
|
@@ -359,25 +352,30 @@ struct Toolkit: View {
|
|
|
359
352
|
}
|
|
360
353
|
toolButton(icon: headerRight.closeIcon, accessibilityId: "btn_navigation_close", action: onPressClose)
|
|
361
354
|
}
|
|
362
|
-
.frame(
|
|
355
|
+
.frame(
|
|
356
|
+
width: usesHelpCenter(context) ? HeaderLayoutMetrics.pillWidth : HeaderLayoutMetrics.buttonSize,
|
|
357
|
+
height: HeaderLayoutMetrics.buttonSize
|
|
358
|
+
)
|
|
363
359
|
.background(headerColor.backgroundButton)
|
|
364
|
-
.
|
|
365
|
-
.overlay(
|
|
360
|
+
.clipShape(Capsule())
|
|
361
|
+
.overlay(Capsule().stroke(headerColor.borderColor, lineWidth: 0.2))
|
|
366
362
|
.padding(.leading, Spacing.S)
|
|
367
363
|
}
|
|
368
364
|
}
|
|
369
365
|
|
|
366
|
+
/// One half of the help / home pill; each half takes an equal share of the pill width.
|
|
370
367
|
private func toolButton(icon: String, accessibilityId: String, action: @escaping () -> Void) -> some View {
|
|
371
368
|
SwiftUI.Button(action: action) {
|
|
372
|
-
Icon(source: icon, size:
|
|
373
|
-
.
|
|
369
|
+
Icon(source: icon, size: HeaderLayoutMetrics.iconSize, color: headerColor.tintIconColor)
|
|
370
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
371
|
+
.contentShape(Rectangle())
|
|
374
372
|
}
|
|
375
373
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
376
374
|
.accessibilityIdentifier(accessibilityId)
|
|
377
375
|
}
|
|
378
376
|
}
|
|
379
377
|
|
|
380
|
-
/// Mirrors Compose's `NavigationButton`: the
|
|
378
|
+
/// Mirrors Compose's `NavigationButton`: the 32pt circular shortcut / more button.
|
|
381
379
|
public struct NavigationButton: View {
|
|
382
380
|
var disabled: Bool
|
|
383
381
|
var icon: String
|
|
@@ -410,9 +408,9 @@ public struct NavigationButton: View {
|
|
|
410
408
|
Circle()
|
|
411
409
|
.fill(colors.backgroundButton)
|
|
412
410
|
.overlay(Circle().stroke(colors.borderColor, lineWidth: 0.2))
|
|
413
|
-
Icon(source: icon, size:
|
|
411
|
+
Icon(source: icon, size: HeaderLayoutMetrics.iconSize, color: colors.tintIconColor)
|
|
414
412
|
}
|
|
415
|
-
.frame(width:
|
|
413
|
+
.frame(width: HeaderLayoutMetrics.buttonSize, height: HeaderLayoutMetrics.buttonSize)
|
|
416
414
|
.overlay(alignment: .topTrailing) {
|
|
417
415
|
if showBadge {
|
|
418
416
|
BadgeDot(size: .small).offset(x: -Spacing.XXS, y: -Spacing.XXS)
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HeaderTitle.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/HeaderTitle.kt`: the plain header title.
|
|
6
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/HeaderTitle.kt`: the plain header title.
|
|
7
2
|
|
|
8
3
|
import SwiftUI
|
|
9
4
|
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/HeaderUser.kt`.
|
|
6
|
-
// Renders a `HeaderTitle.User`: an avatar group (1..n avatars with overflow),
|
|
7
|
-
// a title with optional inline icons, and an optional subtitle. Shows a
|
|
8
|
-
// skeleton shimmer placeholder while `isLoading`.
|
|
9
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/HeaderUser.kt`: avatar group, title with
|
|
2
|
+
// inline icons and an optional subtitle, or a skeleton while `isLoading`.
|
|
10
3
|
|
|
11
4
|
import SwiftUI
|
|
12
5
|
|
|
@@ -20,6 +13,7 @@ public struct HeaderUserView: View {
|
|
|
20
13
|
private let avatarSize: CGFloat = Spacing.XXL // 32
|
|
21
14
|
|
|
22
15
|
@Environment(\.screenLayout) private var layout
|
|
16
|
+
@Environment(\.contentLayout) private var contentLayout
|
|
23
17
|
|
|
24
18
|
public var body: some View {
|
|
25
19
|
if data.isLoading {
|
|
@@ -74,7 +68,7 @@ public struct HeaderUserView: View {
|
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
}
|
|
77
|
-
.frame(maxWidth: headerTitleMaxWidth(layout), alignment: .leading)
|
|
71
|
+
.frame(maxWidth: headerTitleMaxWidth(layout, contentLayout), alignment: .leading)
|
|
78
72
|
|
|
79
73
|
Spacer(minLength: 0)
|
|
80
74
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/SideBar.kt`. iPhone Duo: back and toolkit
|
|
6
|
-
// leave the header bar for a column in the side safe area, as the system bars do.
|
|
7
|
-
// Port of RN `SideBarButton.tsx` + `useSideBarItemStyle`.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/SideBar.kt` (RN `SideBarButton.tsx` + `useSideBarItemStyle`):
|
|
2
|
+
// on iPhone Duo, back and toolkit leave the header for a column in the side safe area, as the system bars do.
|
|
9
3
|
|
|
10
4
|
import SwiftUI
|
|
11
5
|
|
|
@@ -142,26 +136,17 @@ struct SideBarButton: View {
|
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
|
|
145
|
-
/// 48pt glass capsule grouping related controls, one item per 50pt
|
|
146
|
-
/// horizontal on a header row.
|
|
139
|
+
/// 48pt vertical glass capsule grouping related side bar controls, one item per 50pt.
|
|
147
140
|
struct SideBarGroup<Content: View>: View {
|
|
148
141
|
let headerColor: HeaderColor
|
|
149
142
|
let itemCount: Int
|
|
150
|
-
var horizontal: Bool = false
|
|
151
143
|
@ViewBuilder let content: () -> Content
|
|
152
144
|
|
|
153
145
|
var body: some View {
|
|
154
146
|
let length = itemCount > 1 ? DuoMetrics.itemPitch * CGFloat(itemCount) : DuoMetrics.controlSize
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
.frame(width: length, height: DuoMetrics.controlSize)
|
|
159
|
-
} else {
|
|
160
|
-
VStack(spacing: 0) { content() }
|
|
161
|
-
.frame(width: DuoMetrics.controlSize, height: length)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
.modifier(SideBarGlass(headerColor: headerColor, shape: RoundedRectangle(cornerRadius: Radius.XL)))
|
|
147
|
+
VStack(spacing: 0) { content() }
|
|
148
|
+
.frame(width: DuoMetrics.controlSize, height: length)
|
|
149
|
+
.modifier(SideBarGlass(headerColor: headerColor, shape: RoundedRectangle(cornerRadius: Radius.XL)))
|
|
165
150
|
}
|
|
166
151
|
}
|
|
167
152
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/component/SnackBar.kt`: slides up above the screen's
|
|
6
|
-
// footer (or the home indicator), stays for `duration`, then slides back down.
|
|
7
|
-
// `Navigator.showSnackBar(_:)` drives it through the overplay host.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/component/SnackBar.kt`, driven by
|
|
2
|
+
// `Navigator.showSnackBar(_:)` through the overplay host.
|
|
9
3
|
|
|
10
4
|
import Foundation
|
|
11
5
|
import SwiftUI
|
|
@@ -38,8 +32,7 @@ public struct SnackBar {
|
|
|
38
32
|
SnackBar(style: .custom, duration: duration, content: { AnyView(content()) })
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
/// Mirrors `SnackBar.Toast
|
|
42
|
-
/// Compose where `Toast` currently renders nothing).
|
|
35
|
+
/// Mirrors `SnackBar.Toast`, which renders nothing in Compose either.
|
|
43
36
|
public static func toast(duration: TimeInterval? = 3.0) -> SnackBar {
|
|
44
37
|
SnackBar(style: .toast, duration: duration, content: nil)
|
|
45
38
|
}
|
|
@@ -57,6 +50,7 @@ struct SnackBarView: View {
|
|
|
57
50
|
let bottomInset: CGFloat
|
|
58
51
|
|
|
59
52
|
@EnvironmentObject private var navigator: Navigator
|
|
53
|
+
@Environment(\.screenLayout) private var layout
|
|
60
54
|
|
|
61
55
|
@State private var contentHeight: CGFloat = 0
|
|
62
56
|
@State private var offsetY: CGFloat = 0
|
|
@@ -75,6 +69,9 @@ struct SnackBarView: View {
|
|
|
75
69
|
)
|
|
76
70
|
.offset(y: offsetY)
|
|
77
71
|
.padding(.bottom, bottomInset)
|
|
72
|
+
// iPhone Duo: clear of the side toolbar strip, like the screen content (0 elsewhere)
|
|
73
|
+
.padding(.leading, layout.insetLeft)
|
|
74
|
+
.padding(.trailing, layout.insetRight)
|
|
78
75
|
}
|
|
79
76
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
80
77
|
.ignoresSafeArea()
|
|
@@ -102,7 +99,7 @@ struct SnackBarView: View {
|
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
//
|
|
102
|
+
// Compose's `openEvent`.
|
|
106
103
|
private func open() {
|
|
107
104
|
DispatchQueue.main.async {
|
|
108
105
|
withAnimation(.easeOut(duration: 0.35)) {
|
|
@@ -111,7 +108,7 @@ struct SnackBarView: View {
|
|
|
111
108
|
}
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
//
|
|
111
|
+
// Slides down, then removes the overplay (Compose's `closeEvent` / `hideSnackBar`).
|
|
115
112
|
private func close() {
|
|
116
113
|
guard !isClosing else { return }
|
|
117
114
|
isClosing = true
|
|
@@ -133,7 +130,6 @@ struct SnackBarView: View {
|
|
|
133
130
|
private func scheduleAutoDismiss() {
|
|
134
131
|
guard let duration = snackBar.duration else { return }
|
|
135
132
|
let workItem = DispatchWorkItem {
|
|
136
|
-
// Only auto-dismiss if this snack bar is still the active overplay.
|
|
137
133
|
if navigator.overplay?.id == overplayId {
|
|
138
134
|
navigator.hideSnackBar()
|
|
139
135
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/HostBackGestureBridge.kt`: the host owns the edge-pan
|
|
6
|
-
// recogniser and routes a back into the topmost kit stack. NavigationContainer attaches itself.
|
|
7
|
-
// `started` / `progressed` / `completed` / `cancelled` scrub the pop transition with the finger;
|
|
8
|
-
// a host that only calls `pop` gets the regular animated back.
|
|
9
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/HostBackGestureBridge.kt`: routes the host's edge pan into the topmost
|
|
2
|
+
// kit stack (NavigationContainer attaches itself); `started` ... `cancelled` scrub the pop, `pop` plays a plain back.
|
|
10
3
|
|
|
11
4
|
import UIKit
|
|
12
5
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `ModalScreen` (navigation/ModalScreen.kt).
|
|
6
|
-
// A centered overlay that fades + scales in over a dimmed scrim, and animates
|
|
7
|
-
// back out before the overplay is removed. Driven by `Navigator.showModal`.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/ModalScreen.kt`, driven by `Navigator.showModal`: a
|
|
2
|
+
// centered overlay that fades + scales in over a dimmed scrim and animates out before removal.
|
|
9
3
|
|
|
10
4
|
import SwiftUI
|
|
11
5
|
|
|
@@ -24,9 +18,11 @@ struct ModalScreen<Content: View>: View {
|
|
|
24
18
|
@State private var didAppear = false
|
|
25
19
|
|
|
26
20
|
var body: some View {
|
|
21
|
+
let modal = layout.modalLayout
|
|
22
|
+
let placement = modal.placement
|
|
27
23
|
ZStack {
|
|
28
|
-
//
|
|
29
|
-
|
|
24
|
+
// full screen on foldables too, over the iPhone Duo control column
|
|
25
|
+
Colors.black20.opacity(modal.scrimOpacity * scrimOpacity)
|
|
30
26
|
.ignoresSafeArea()
|
|
31
27
|
.contentShape(Rectangle())
|
|
32
28
|
.onTapGesture {
|
|
@@ -34,11 +30,14 @@ struct ModalScreen<Content: View>: View {
|
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
content()
|
|
33
|
+
// foldables: capped by the spec; nil leaves the size alone
|
|
34
|
+
.frame(
|
|
35
|
+
maxWidth: modal.isFoldable ? modal.popup.maxWidth : nil,
|
|
36
|
+
maxHeight: modal.isFoldable ? (modal.popup.maxHeight ?? placement.height) : nil
|
|
37
|
+
)
|
|
37
38
|
.scaleEffect(contentScale)
|
|
38
39
|
.opacity(contentOpacity)
|
|
39
|
-
|
|
40
|
-
.padding(.top, layout.isDuoDevice ? layout.duoTopInset : 0)
|
|
41
|
-
.padding(.bottom, layout.isDuoDevice ? layout.insets.bottom : 0)
|
|
40
|
+
.padding(contentPadding(modal))
|
|
42
41
|
}
|
|
43
42
|
// Full screen like RN's Modal, so asymmetric landscape insets don't shift the content sideways.
|
|
44
43
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
@@ -56,6 +55,18 @@ struct ModalScreen<Content: View>: View {
|
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
|
|
58
|
+
// Centers the content in the placement: the safe area, or the right half of a half-folded iPhone Duo.
|
|
59
|
+
private func contentPadding(_ modal: ModalLayout) -> EdgeInsets {
|
|
60
|
+
guard modal.isFoldable else { return EdgeInsets() }
|
|
61
|
+
let placement = modal.placement
|
|
62
|
+
return EdgeInsets(
|
|
63
|
+
top: placement.minY,
|
|
64
|
+
leading: placement.minX,
|
|
65
|
+
bottom: layout.height - placement.maxY,
|
|
66
|
+
trailing: layout.width - placement.maxX
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
// Mirrors Compose's `openEvent`: 250ms fade + scale to 1.
|
|
60
71
|
private func open() {
|
|
61
72
|
DispatchQueue.main.async {
|