@momo-kits/native-kits 0.300.7 → 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/build.gradle.kts +13 -0
- package/compose/build.gradle.kts +195 -0
- package/compose/build.gradle.kts.backup +195 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -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 +154 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -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 +61 -0
- 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 +1067 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +55 -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 +354 -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 +130 -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 +482 -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 +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -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 +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -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 +304 -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 +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -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 +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -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 +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -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 +208 -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 +12 -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 +291 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -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 +315 -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 +54 -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 +397 -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 +153 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +212 -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 +750 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -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 +244 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
- 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 +167 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -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 +387 -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/HelpCenterRequest.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +38 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +135 -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 +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -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 +117 -0
- 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 +39 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +53 -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 +31 -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 +65 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
- 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 +143 -0
- package/gradle/libs.versions.toml +66 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +24 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- 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/README.md +120 -0
- 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 +63 -0
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/Navigation.kt`: a screen's `NavigationOptions` and the
|
|
6
|
-
// per-screen `Navigation` that updates them at runtime.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/Navigation.kt`: a screen's `NavigationOptions` and the
|
|
2
|
+
// per-screen `Navigation` that updates them at runtime.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
11
|
-
/// Per-screen handle (Compose `LocalNavigation`)
|
|
12
|
-
///
|
|
13
|
-
/// footer or back handling after the screen is shown.
|
|
6
|
+
/// Per-screen handle (Compose `LocalNavigation`): a screen reads `@EnvironmentObject var navigation: Navigation`
|
|
7
|
+
/// and calls `setOptions` to change the header, footer or back handling after it is shown.
|
|
14
8
|
public final class Navigation: ObservableObject {
|
|
15
9
|
public let id: Int
|
|
16
10
|
public let bottomTabIndex: Int
|
|
@@ -19,6 +13,9 @@ public final class Navigation: ObservableObject {
|
|
|
19
13
|
private weak var registry: DynamicScreenRegistry?
|
|
20
14
|
/// What the footer (or navigation bar) takes from the window bottom; lifts snack bars.
|
|
21
15
|
var bottomObstruction: CGFloat = 0
|
|
16
|
+
/// A tab that pads itself asks (via `floatingTabBarEdgeToEdge()`) to run edge to edge behind the floating
|
|
17
|
+
/// bar and the home indicator; the kit then stops reserving that space. Compose's `bottomTabEdgeToEdge`.
|
|
18
|
+
@Published var bottomTabEdgeToEdge = false
|
|
22
19
|
|
|
23
20
|
init(
|
|
24
21
|
id: Int = -1,
|
|
@@ -66,11 +63,9 @@ public struct NavigationOptions {
|
|
|
66
63
|
public var fullScreenContent: Bool
|
|
67
64
|
public var hiddenBack: Bool
|
|
68
65
|
public var backgroundColor: Color?
|
|
69
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
70
66
|
/// Drawn instead of `backgroundColor` over the whole window: under the header and the status bar,
|
|
71
67
|
/// across the iPhone Duo side strips, and not shrunk by the keyboard. Pair with `headerTransparent`.
|
|
72
68
|
public var background: (() -> AnyView)?
|
|
73
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
74
69
|
public var tintColor: Color?
|
|
75
70
|
public var scrollable: Bool
|
|
76
71
|
/// Compose's `ScrollData.scrollToTopCallback`, fired on a status-bar tap.
|
|
@@ -91,6 +86,8 @@ public struct NavigationOptions {
|
|
|
91
86
|
public var inputSearchProps: InputSearchProps?
|
|
92
87
|
public var fabProps: FabProps?
|
|
93
88
|
public var onBackHandler: (() -> Void)?
|
|
89
|
+
/// Wide windows: `.stretch` puts the header row in the centered 600pt content frame.
|
|
90
|
+
public var contentLayout: ContentLayout
|
|
94
91
|
|
|
95
92
|
public init(
|
|
96
93
|
screenName: String? = nil,
|
|
@@ -103,9 +100,7 @@ public struct NavigationOptions {
|
|
|
103
100
|
fullScreenContent: Bool = false,
|
|
104
101
|
hiddenBack: Bool = false,
|
|
105
102
|
backgroundColor: Color? = nil,
|
|
106
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
107
103
|
background: (() -> AnyView)? = nil,
|
|
108
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
109
104
|
tintColor: Color? = Colors.black17,
|
|
110
105
|
scrollable: Bool = true,
|
|
111
106
|
scrollToTopCallback: (() -> Void)? = nil,
|
|
@@ -121,7 +116,8 @@ public struct NavigationOptions {
|
|
|
121
116
|
layoutOffset: CGFloat = 56,
|
|
122
117
|
inputSearchProps: InputSearchProps? = nil,
|
|
123
118
|
fabProps: FabProps? = nil,
|
|
124
|
-
onBackHandler: (() -> Void)? = nil
|
|
119
|
+
onBackHandler: (() -> Void)? = nil,
|
|
120
|
+
contentLayout: ContentLayout = .grid
|
|
125
121
|
) {
|
|
126
122
|
self.screenName = screenName
|
|
127
123
|
self.title = title
|
|
@@ -133,9 +129,7 @@ public struct NavigationOptions {
|
|
|
133
129
|
self.fullScreenContent = fullScreenContent
|
|
134
130
|
self.hiddenBack = hiddenBack
|
|
135
131
|
self.backgroundColor = backgroundColor
|
|
136
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
137
132
|
self.background = background
|
|
138
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
139
133
|
self.tintColor = tintColor
|
|
140
134
|
self.scrollable = scrollable
|
|
141
135
|
self.scrollToTopCallback = scrollToTopCallback
|
|
@@ -152,6 +146,7 @@ public struct NavigationOptions {
|
|
|
152
146
|
self.inputSearchProps = inputSearchProps
|
|
153
147
|
self.fabProps = fabProps
|
|
154
148
|
self.onBackHandler = onBackHandler
|
|
149
|
+
self.contentLayout = contentLayout
|
|
155
150
|
}
|
|
156
151
|
}
|
|
157
152
|
|
|
@@ -172,9 +167,7 @@ struct OptionsStackScreen: View {
|
|
|
172
167
|
var body: some View {
|
|
173
168
|
StackScreen(
|
|
174
169
|
backgroundColor: options.backgroundColor,
|
|
175
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
176
170
|
background: options.background,
|
|
177
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
178
171
|
headerTransparent: options.headerTransparent,
|
|
179
172
|
fullScreenContent: options.fullScreenContent,
|
|
180
173
|
tintColor: options.tintColor ?? Colors.black17,
|
|
@@ -197,8 +190,31 @@ struct OptionsStackScreen: View {
|
|
|
197
190
|
layoutOffset: options.layoutOffset,
|
|
198
191
|
inputSearchProps: options.inputSearchProps,
|
|
199
192
|
fabProps: options.fabProps,
|
|
193
|
+
contentLayout: options.contentLayout,
|
|
200
194
|
screenName: screenName,
|
|
201
195
|
content: content
|
|
202
196
|
)
|
|
203
197
|
}
|
|
204
198
|
}
|
|
199
|
+
|
|
200
|
+
// MARK: - Edge-to-edge tab content
|
|
201
|
+
|
|
202
|
+
public extension View {
|
|
203
|
+
/// Compose's `floatingTabBarContentPadding()`: the content of a `BottomTab` tab runs edge to edge behind
|
|
204
|
+
/// the floating tab bar and the home indicator, and pads its own bottom (e.g. a full-screen native view
|
|
205
|
+
/// with its own safe area). No effect outside a tab.
|
|
206
|
+
func floatingTabBarEdgeToEdge() -> some View {
|
|
207
|
+
modifier(FloatingTabBarEdgeToEdge())
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private struct FloatingTabBarEdgeToEdge: ViewModifier {
|
|
212
|
+
@OptionalEnvironmentObject private var navigation: Navigation?
|
|
213
|
+
|
|
214
|
+
func body(content: Content) -> some View {
|
|
215
|
+
content.onAppear {
|
|
216
|
+
guard let navigation, navigation.bottomTabIndex != -1, !navigation.bottomTabEdgeToEdge else { return }
|
|
217
|
+
navigation.bottomTabEdgeToEdge = true
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/NavigationContainer.kt`: hosts the kit stack
|
|
6
|
-
// (`StackHost`, the NavHost counterpart), injects Navigator, theme, localize and font scale, and
|
|
7
|
-
// renders every registered screen inside `StackScreen` chrome built from its options.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/NavigationContainer.kt`: hosts the kit stack (`StackHost`, the NavHost
|
|
2
|
+
// counterpart), injects Navigator, theme, localize and font scale, and wraps each screen in `StackScreen` chrome.
|
|
9
3
|
|
|
10
4
|
import SwiftUI
|
|
11
5
|
|
|
@@ -50,9 +44,7 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
50
44
|
maxApi: maxApi
|
|
51
45
|
)
|
|
52
46
|
)
|
|
53
|
-
// AI-GENERATED START: default to the app-language-observing shared Localize
|
|
54
47
|
_localize = StateObject(wrappedValue: localize ?? Localize.shared)
|
|
55
|
-
// AI-GENERATED END: default to the app-language-observing shared Localize
|
|
56
48
|
self.composeApi = composeApi
|
|
57
49
|
self.maxApi = maxApi
|
|
58
50
|
self.initialTheme = initialTheme
|
|
@@ -91,15 +83,12 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
91
83
|
setNavigator?(navigator)
|
|
92
84
|
// Idempotent, so a re-appear won't double-count.
|
|
93
85
|
HostBackGestureBridge.shared.attach(navigator)
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
// directions, so asking maxApi would just race it. `changeLanguage` normalizes the
|
|
97
|
-
// raw response and hops to main itself.
|
|
86
|
+
// Only a seed: a Localize with a language source already tracks the host, so asking maxApi would race
|
|
87
|
+
// it. `changeLanguage` normalizes the raw response and hops to main itself.
|
|
98
88
|
guard !localize.observesAppLanguage else { return }
|
|
99
89
|
maxApi?.getLanguage { data in
|
|
100
90
|
localize.changeLanguage(data?["response"] as? String)
|
|
101
91
|
}
|
|
102
|
-
// AI-GENERATED END: demote the MaxApi language pull to a seed of last resort
|
|
103
92
|
}
|
|
104
93
|
.onDisappear {
|
|
105
94
|
HostBackGestureBridge.shared.detach(navigator)
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/Navigator.kt`: Navigator, DynamicScreenRegistry and
|
|
6
|
-
// the overplay model. Screens are registered by Int id; the stack paths store routes by id and
|
|
7
|
-
// content is looked up from the registry on render.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/Navigator.kt`: Navigator, DynamicScreenRegistry and the overplay model.
|
|
2
|
+
// The stack holds screen ids; content is looked up from the registry on render.
|
|
9
3
|
|
|
10
4
|
import SwiftUI
|
|
11
5
|
import Combine
|
|
@@ -106,9 +100,8 @@ public struct OverplayItem: Identifiable {
|
|
|
106
100
|
|
|
107
101
|
// MARK: - Stack
|
|
108
102
|
|
|
109
|
-
/// One back-stack entry, root first. A presented screen is
|
|
110
|
-
///
|
|
111
|
-
/// stack on top of it.
|
|
103
|
+
/// One back-stack entry, root first. A presented screen is one too (Compose's `DynamicDialogRoute` in the same
|
|
104
|
+
/// NavHost): it rises instead of sliding in, and later pushes stack on top of it.
|
|
112
105
|
struct StackEntry: Hashable, Identifiable {
|
|
113
106
|
let id: Int
|
|
114
107
|
let isDialog: Bool
|
|
@@ -124,15 +117,12 @@ public final class Navigator: ObservableObject {
|
|
|
124
117
|
}
|
|
125
118
|
@Published public var overplay: OverplayItem?
|
|
126
119
|
|
|
127
|
-
///
|
|
128
|
-
///
|
|
129
|
-
/// navigator itself deallocates, instead of accumulating in a process-wide singleton.
|
|
120
|
+
/// Per navigator, as Compose's `remember { DynamicScreenRegistry() }`: its screens go with
|
|
121
|
+
/// the navigator instead of piling up in a process-wide singleton.
|
|
130
122
|
public let registry = DynamicScreenRegistry()
|
|
131
123
|
|
|
132
|
-
///
|
|
133
|
-
///
|
|
134
|
-
/// dismiss request runs the component's exit animation before the item is
|
|
135
|
-
/// actually removed via `finishOverplayDismiss`.
|
|
124
|
+
/// Exit animation of the active overplay (Compose's `OverplayComponentRegistry.bindClose`);
|
|
125
|
+
/// the component calls `finishOverplayDismiss` once it has played.
|
|
136
126
|
private var overplayDismissHandler: (() -> Void)?
|
|
137
127
|
|
|
138
128
|
public var rootRoute: DynamicScreenRoute { DynamicScreenRoute(id: entries[0].id) }
|
|
@@ -140,9 +130,8 @@ public final class Navigator: ObservableObject {
|
|
|
140
130
|
/// Host dismiss fallback when there is no `composeApi` (Compose's `maxApi.dismiss`).
|
|
141
131
|
public var maxApi: MaxApi?
|
|
142
132
|
|
|
143
|
-
/// Set by a bottom tab off its first tab
|
|
144
|
-
///
|
|
145
|
-
/// over the tabs still pops normally.
|
|
133
|
+
/// Set by a bottom tab off its first tab so back returns there (Compose `tabBackHandler`). Keyed by the
|
|
134
|
+
/// hosting screen, so a screen pushed or presented over the tabs still pops normally.
|
|
146
135
|
var tabBackHandler: (screenId: Int, handler: () -> Void)?
|
|
147
136
|
|
|
148
137
|
/// The container's stack view, which plays (and lets the host gesture scrub) the transitions.
|
|
@@ -224,10 +213,8 @@ public final class Navigator: ObservableObject {
|
|
|
224
213
|
popStep(remaining: count, callback: callback)
|
|
225
214
|
}
|
|
226
215
|
|
|
227
|
-
///
|
|
228
|
-
///
|
|
229
|
-
/// a `pop(2)` (prevent-back: close the popup, then leave) would spend both steps on
|
|
230
|
-
/// the overplay that is still animating out and never pop the screen.
|
|
216
|
+
/// Waits out the overplay's exit animation like Compose's coroutine loop, or a `pop(2)` (prevent-back: close
|
|
217
|
+
/// the popup, then leave) would spend both steps on the closing overplay and never pop the screen.
|
|
231
218
|
private func popStep(remaining: Int, callback: (() -> Void)?) {
|
|
232
219
|
guard remaining > 0 else {
|
|
233
220
|
callback?()
|
|
@@ -235,9 +222,8 @@ public final class Navigator: ObservableObject {
|
|
|
235
222
|
}
|
|
236
223
|
|
|
237
224
|
if overplay?.type == .snackBar {
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
// snackbar immediately, without playing its dismiss animation.
|
|
225
|
+
// As in Compose, a snack bar doesn't block back: the screen under it pops and the
|
|
226
|
+
// snack bar clears without its exit animation.
|
|
241
227
|
replaceOverplay(with: nil)
|
|
242
228
|
guard popScreen() else {
|
|
243
229
|
callback?()
|
|
@@ -316,7 +302,7 @@ public final class Navigator: ObservableObject {
|
|
|
316
302
|
return
|
|
317
303
|
}
|
|
318
304
|
if let preventBack = latest?.options?.headerBackProps?.preventBack {
|
|
319
|
-
//
|
|
305
|
+
// Stored in `overplay`, so a strong self would cycle until the popup closes.
|
|
320
306
|
showModal { [weak self] in
|
|
321
307
|
PopupNotify(
|
|
322
308
|
props: PopupNotifyProps(
|
|
@@ -377,9 +363,8 @@ public final class Navigator: ObservableObject {
|
|
|
377
363
|
|
|
378
364
|
// MARK: Host back gesture (Compose's HostBackTarget)
|
|
379
365
|
|
|
380
|
-
/// Only a plain pop is scrubbed.
|
|
381
|
-
///
|
|
382
|
-
/// waits for the release and goes through `onBackSafe`, as RN turns the gesture off there.
|
|
366
|
+
/// Only a plain pop is scrubbed. Tab back, a custom handler, prevent-back, an open overplay or a presented
|
|
367
|
+
/// top wait for the release and go through `onBackSafe`, as RN turns the gesture off there.
|
|
383
368
|
private var canSeekBack: Bool {
|
|
384
369
|
guard canPop(), overplay == nil, let top = entries.last, !top.isDialog else { return false }
|
|
385
370
|
if let tabBackHandler, tabBackHandler.screenId == -1 || tabBackHandler.screenId == top.id {
|
|
@@ -477,9 +462,8 @@ public final class Navigator: ObservableObject {
|
|
|
477
462
|
overplayDismissHandler = handler
|
|
478
463
|
}
|
|
479
464
|
|
|
480
|
-
/// Removes the overplay and fires its `onDismiss` (
|
|
481
|
-
///
|
|
482
|
-
/// has completed.
|
|
465
|
+
/// Removes the overplay and fires its `onDismiss` (Compose's `hardClearAfterDismiss`);
|
|
466
|
+
/// called by the component once its exit animation has played.
|
|
483
467
|
public func finishOverplayDismiss() {
|
|
484
468
|
replaceOverplay(with: nil)
|
|
485
469
|
}
|
|
@@ -502,7 +486,6 @@ public final class Navigator: ObservableObject {
|
|
|
502
486
|
|
|
503
487
|
public func hideOverplay() {
|
|
504
488
|
if let close = overplayDismissHandler {
|
|
505
|
-
// Component runs its exit animation, then calls finishOverplayDismiss.
|
|
506
489
|
overplayDismissHandler = nil
|
|
507
490
|
close()
|
|
508
491
|
} else {
|
|
@@ -537,9 +520,8 @@ public final class Navigator: ObservableObject {
|
|
|
537
520
|
disposeScreens(previous.map(\.id).filter { !kept.contains($0) })
|
|
538
521
|
}
|
|
539
522
|
|
|
540
|
-
///
|
|
541
|
-
///
|
|
542
|
-
/// fires, so an entry back on the stack by then keeps its screen.
|
|
523
|
+
/// Released only after the pop transition, as the outgoing view animates until then. Liveness is re-checked
|
|
524
|
+
/// when the timer fires, so an entry back on the stack by then keeps its screen.
|
|
543
525
|
private func disposeScreens(_ ids: [Int]) {
|
|
544
526
|
guard !ids.isEmpty else { return }
|
|
545
527
|
DispatchQueue.main.asyncAfter(deadline: .now() + Self.screenDisposeDelay) { [weak self] in
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/StackScreen.kt`: header layer, scrollable content
|
|
6
|
-
// (`StackScreenContent`), animated search, floating button, footer (`NavigationFooter`) and the
|
|
7
|
-
// iPhone Duo side bar.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/StackScreen.kt`: header layer, scrollable content (`StackScreenContent`),
|
|
2
|
+
// animated search, floating button, footer (`NavigationFooter`) and the iPhone Duo side bar.
|
|
9
3
|
|
|
10
4
|
import SwiftUI
|
|
11
5
|
|
|
@@ -13,9 +7,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
13
7
|
// MARK: - Properties
|
|
14
8
|
|
|
15
9
|
var backgroundColor: Color?
|
|
16
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
17
10
|
var background: (() -> AnyView)?
|
|
18
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
19
11
|
var headerTransparent: Bool = false
|
|
20
12
|
var fullScreenContent: Bool = false
|
|
21
13
|
var tintColor: Color? = Colors.black17
|
|
@@ -41,14 +33,13 @@ public struct StackScreen<Content: View>: View {
|
|
|
41
33
|
var layoutOffset: CGFloat
|
|
42
34
|
var inputSearchProps: InputSearchProps?
|
|
43
35
|
var fabProps: FabProps?
|
|
36
|
+
var contentLayout: ContentLayout = .grid
|
|
44
37
|
var screenName: String = ""
|
|
45
38
|
var content: () -> Content
|
|
46
39
|
|
|
47
40
|
public init(
|
|
48
41
|
backgroundColor: Color? = nil,
|
|
49
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
50
42
|
background: (() -> AnyView)? = nil,
|
|
51
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
52
43
|
headerTransparent: Bool = false,
|
|
53
44
|
fullScreenContent: Bool = false,
|
|
54
45
|
tintColor: Color = Colors.black17,
|
|
@@ -74,13 +65,12 @@ public struct StackScreen<Content: View>: View {
|
|
|
74
65
|
layoutOffset: CGFloat = 56,
|
|
75
66
|
inputSearchProps: InputSearchProps? = nil,
|
|
76
67
|
fabProps: FabProps? = nil,
|
|
68
|
+
contentLayout: ContentLayout = .grid,
|
|
77
69
|
screenName: String = "",
|
|
78
70
|
@ViewBuilder content: @escaping () -> Content
|
|
79
71
|
) {
|
|
80
72
|
self.backgroundColor = backgroundColor
|
|
81
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
82
73
|
self.background = background
|
|
83
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
84
74
|
self.headerTransparent = headerTransparent
|
|
85
75
|
self.fullScreenContent = fullScreenContent
|
|
86
76
|
self.tintColor = tintColor
|
|
@@ -106,6 +96,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
106
96
|
self.layoutOffset = layoutOffset
|
|
107
97
|
self.inputSearchProps = inputSearchProps
|
|
108
98
|
self.fabProps = fabProps
|
|
99
|
+
self.contentLayout = contentLayout
|
|
109
100
|
self.screenName = screenName
|
|
110
101
|
self.content = content
|
|
111
102
|
}
|
|
@@ -168,8 +159,18 @@ public struct StackScreen<Content: View>: View {
|
|
|
168
159
|
|
|
169
160
|
/// iPhone Duo: content scrolls under a glass header instead of starting below it.
|
|
170
161
|
private var useDuoGlass: Bool {
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
let hasPlainHeader = headerType != .none && animatedHeader == nil && inputSearchProps == nil
|
|
163
|
+
return layout.sideBar != nil && hasPlainHeader && !headerTransparent && !fullScreenContent
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// Bottom room for the tab's content: clear of the floating bar, unless the tab runs edge to edge
|
|
167
|
+
/// (`floatingTabBarEdgeToEdge()`), when it also covers the home indicator that BottomTab keeps clear of
|
|
168
|
+
/// (a negative inset extends the content past the tab's frame).
|
|
169
|
+
private var contentBottomInset: CGFloat {
|
|
170
|
+
guard let navigation, navigation.bottomTabIndex != -1, navigation.bottomTabEdgeToEdge else {
|
|
171
|
+
return duoTabBarInsets.overlay
|
|
172
|
+
}
|
|
173
|
+
return -layout.insets.bottom
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
/// iPhone Duo: the header leaves with the content and slides back in on a reverse scroll
|
|
@@ -245,7 +246,6 @@ public struct StackScreen<Content: View>: View {
|
|
|
245
246
|
public var body: some View {
|
|
246
247
|
GeometryReader { _ in
|
|
247
248
|
ZStack(alignment: .top) {
|
|
248
|
-
// AI-GENERATED START: custom screen background view (Compose backgroundComponent)
|
|
249
249
|
Group {
|
|
250
250
|
if let background {
|
|
251
251
|
background()
|
|
@@ -254,7 +254,6 @@ public struct StackScreen<Content: View>: View {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
.edgesIgnoringSafeArea(.all)
|
|
257
|
-
// AI-GENERATED END: custom screen background view (Compose backgroundComponent)
|
|
258
257
|
|
|
259
258
|
VStack(spacing: 0) {
|
|
260
259
|
ZStack(alignment: fabProps?.position == .center ? .bottom : .bottomTrailing) {
|
|
@@ -310,6 +309,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
.ignoresSafeArea(.keyboard, edges: .bottom)
|
|
312
|
+
.environment(\.contentLayout, contentLayout)
|
|
313
313
|
.onChange(of: scrollOffset) { updateHeaderHide($0) }
|
|
314
314
|
.onAppear { reportEmptySideBar() }
|
|
315
315
|
.onChange(of: showsSideBar) { _ in reportEmptySideBar() }
|
|
@@ -336,9 +336,8 @@ public struct StackScreen<Content: View>: View {
|
|
|
336
336
|
.onDisappear { tracking?.cancel() }
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
/// Compose tracks from a `LaunchedEffect
|
|
340
|
-
///
|
|
341
|
-
/// `@State` and doesn't re-run `.task`, so the run hangs off appear / disappear instead.
|
|
339
|
+
/// Compose tracks from a `LaunchedEffect`, fresh on every visit (first show, pop back, tab switch). A covered
|
|
340
|
+
/// hosting controller keeps its `@State` and doesn't re-run `.task`, so tracking hangs off appear / disappear.
|
|
342
341
|
private func startTracking() {
|
|
343
342
|
tracking?.cancel()
|
|
344
343
|
let state = ScreenTrackingState()
|
|
@@ -392,7 +391,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
392
391
|
scrollOffset: $scrollOffset,
|
|
393
392
|
scrollToTopCallback: scrollToTopCallback,
|
|
394
393
|
animatedSearchInset: animatedSearchInset,
|
|
395
|
-
bottomInset:
|
|
394
|
+
bottomInset: contentBottomInset,
|
|
396
395
|
snapDistance: searchSnapDistance,
|
|
397
396
|
onScrollIdle: settleHeader,
|
|
398
397
|
content: { animatedHeroBody(animatedHeader) }
|
|
@@ -425,7 +424,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
425
424
|
scrollOffset: $scrollOffset,
|
|
426
425
|
scrollToTopCallback: scrollToTopCallback,
|
|
427
426
|
animatedSearchInset: animatedSearchInset,
|
|
428
|
-
bottomInset:
|
|
427
|
+
bottomInset: contentBottomInset,
|
|
429
428
|
snapDistance: searchSnapDistance,
|
|
430
429
|
onScrollIdle: settleHeader,
|
|
431
430
|
content: { duoInsetContent }
|
|
@@ -446,7 +445,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
446
445
|
scrollOffset: $scrollOffset,
|
|
447
446
|
scrollToTopCallback: scrollToTopCallback,
|
|
448
447
|
topInset: layout.headerHeight - layout.insets.top,
|
|
449
|
-
bottomInset:
|
|
448
|
+
bottomInset: contentBottomInset,
|
|
450
449
|
snapDistance: searchSnapDistance,
|
|
451
450
|
onScrollIdle: settleHeader,
|
|
452
451
|
content: content
|
|
@@ -492,7 +491,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
492
491
|
scrollOffset: $scrollOffset,
|
|
493
492
|
scrollToTopCallback: scrollToTopCallback,
|
|
494
493
|
animatedSearchInset: animatedSearchInset,
|
|
495
|
-
bottomInset:
|
|
494
|
+
bottomInset: contentBottomInset,
|
|
496
495
|
snapDistance: searchSnapDistance,
|
|
497
496
|
onScrollIdle: settleHeader,
|
|
498
497
|
content: content
|
|
@@ -509,18 +508,28 @@ public struct StackScreen<Content: View>: View {
|
|
|
509
508
|
}
|
|
510
509
|
|
|
511
510
|
private func heroGlassStart(_ animatedHeader: AnimatedHeader) -> CGFloat {
|
|
512
|
-
max(
|
|
511
|
+
max(bannerWidth / animatedHeader.aspectRatio.value - layout.headerHeight, 0)
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/// Wide windows and the iPhone Duo inner display keep the phone banner size, centered; phones fill the width.
|
|
515
|
+
private var bannerWidth: CGFloat {
|
|
516
|
+
layout.headerLayout(contentLayout).isBannerCentered ? HeaderLayoutMetrics.bannerWidth : layout.width
|
|
513
517
|
}
|
|
514
518
|
|
|
515
519
|
/// The banner fills the width at its aspect ratio; the body starts `layoutOffset` below the
|
|
516
|
-
/// header band so it overlaps the banner's lower part.
|
|
520
|
+
/// header band so it overlaps the banner's lower part. On wide windows and the Duo inner display
|
|
521
|
+
/// `bannerBackgroundColor` fills the sides, fading out downward.
|
|
517
522
|
@ViewBuilder
|
|
518
523
|
private func animatedHeroBody(_ animatedHeader: AnimatedHeader) -> some View {
|
|
519
|
-
let width =
|
|
524
|
+
let width = bannerWidth
|
|
520
525
|
let imageHeight = width / animatedHeader.aspectRatio.value
|
|
521
526
|
let contentTopInset = layout.headerHeight + layoutOffset
|
|
522
527
|
|
|
523
528
|
ZStack(alignment: .top) {
|
|
529
|
+
if width < layout.width, let fill = animatedHeader.bannerBackgroundColor {
|
|
530
|
+
LinearGradient(colors: [fill, fill.opacity(0)], startPoint: .top, endPoint: .bottom)
|
|
531
|
+
.frame(width: layout.width, height: imageHeight)
|
|
532
|
+
}
|
|
524
533
|
animatedHeader.composable(scrollOffset)
|
|
525
534
|
.frame(width: width, height: imageHeight)
|
|
526
535
|
.clipped()
|
|
@@ -573,7 +582,9 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
573
582
|
var animatedSearchInset: CGFloat = 0
|
|
574
583
|
/// Room for a header the content scrolls under (iPhone Duo glass header).
|
|
575
584
|
var topInset: CGFloat = 0
|
|
576
|
-
/// Room for
|
|
585
|
+
/// Room for the floating tab bar that overlays the content: scrolling content runs under it and
|
|
586
|
+
/// ends clear of it, static content stays above it. Negative for an edge-to-edge tab: the content
|
|
587
|
+
/// reaches that far past its frame.
|
|
577
588
|
var bottomInset: CGFloat = 0
|
|
578
589
|
/// Compose's animated-search snap: a scroll that comes to rest part way through this distance
|
|
579
590
|
/// finishes the move, up or back down.
|
|
@@ -634,6 +645,8 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
634
645
|
}
|
|
635
646
|
}
|
|
636
647
|
.coordinateSpace(name: scrollSpace)
|
|
648
|
+
// an edge-to-edge tab's scroll reaches past its frame, under the home indicator
|
|
649
|
+
.padding(.bottom, min(bottomInset, 0))
|
|
637
650
|
.modifier(ScrollRest(offset: scrollOffset, onRest: scrollDidRest))
|
|
638
651
|
// Status-bar tap (MoMoStatusBarTap swizzle) scrolls to top and notifies the consumer.
|
|
639
652
|
.onReceive(NotificationCenter.default.publisher(for: MoMoStatusBarTap.notificationName)) { _ in
|
|
@@ -644,6 +657,7 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
644
657
|
}
|
|
645
658
|
}
|
|
646
659
|
} else {
|
|
660
|
+
// static tab content stays above the floating tab bar
|
|
647
661
|
content()
|
|
648
662
|
.padding(.top, topInset)
|
|
649
663
|
.padding(.bottom, bottomInset)
|
|
@@ -733,9 +747,17 @@ private struct SearchAnimatedHeader: View {
|
|
|
733
747
|
var hasToolkit: Bool = false
|
|
734
748
|
|
|
735
749
|
@Environment(\.screenLayout) private var layout
|
|
750
|
+
@Environment(\.contentLayout) private var contentLayout
|
|
736
751
|
@Environment(\.appTheme) private var theme
|
|
737
752
|
@OptionalEnvironmentObject private var navigator: Navigator?
|
|
738
753
|
|
|
754
|
+
private func maxEndInset(_ side: CGFloat) -> CGFloat {
|
|
755
|
+
if useSideBar && hasToolkit {
|
|
756
|
+
return side
|
|
757
|
+
}
|
|
758
|
+
return headerRightWidth + (hasHeaderRight ? side + Spacing.M : side)
|
|
759
|
+
}
|
|
760
|
+
|
|
739
761
|
var body: some View {
|
|
740
762
|
let scroll = max(scrollOffset, 0)
|
|
741
763
|
|
|
@@ -743,14 +765,13 @@ private struct SearchAnimatedHeader: View {
|
|
|
743
765
|
let rowTop = layout.headerStatusBarHeight - layout.insets.top
|
|
744
766
|
let minTop = rowTop + (layout.headerBarHeight - HEADER_HEIGHT) / 2
|
|
745
767
|
let maxTop = layout.headerHeight - layout.insets.top
|
|
746
|
-
|
|
747
|
-
|
|
768
|
+
// stretch screens on wide windows keep the search in the header's centered frame
|
|
769
|
+
let minSide = layout.headerLayout(contentLayout).frameInset
|
|
770
|
+
// collapsed on the iPhone Duo status bar row, the search stays between its clusters
|
|
748
771
|
let clearance = layout.statusBarClearance
|
|
749
|
-
let
|
|
750
|
-
let maxStart = (clearance?.left ?? 0) + (hiddenBack || useSideBar ?
|
|
751
|
-
let maxEnd = (clearance?.right ?? 0) + (
|
|
752
|
-
? Spacing.M
|
|
753
|
-
: headerRightWidth + (hasHeaderRight ? Spacing.M * 2 : Spacing.M))
|
|
772
|
+
let backInset = HeaderLayoutMetrics.buttonSize + HeaderLayoutMetrics.titleGap
|
|
773
|
+
let maxStart = (clearance?.left ?? 0) + (hiddenBack || useSideBar ? minSide : backInset + minSide)
|
|
774
|
+
let maxEnd = (clearance?.right ?? 0) + maxEndInset(minSide)
|
|
754
775
|
|
|
755
776
|
// one progress for all three, so the field docks with its final insets and never covers the toolkit
|
|
756
777
|
let progress = min(scroll / HEADER_HEIGHT, 1)
|
|
@@ -766,6 +787,7 @@ private struct SearchAnimatedHeader: View {
|
|
|
766
787
|
theme: theme,
|
|
767
788
|
pop: navigator.map { navigator in { navigator.pop() } }
|
|
768
789
|
))
|
|
790
|
+
.headerSize()
|
|
769
791
|
.frame(height: HEADER_HEIGHT)
|
|
770
792
|
.padding(.leading, start)
|
|
771
793
|
.padding(.trailing, end)
|
|
@@ -785,9 +807,8 @@ private struct FloatingContent: View {
|
|
|
785
807
|
let hasFooter: Bool
|
|
786
808
|
let scrollOffset: CGFloat
|
|
787
809
|
|
|
788
|
-
/// Compose keeps the FAB `Spacing.M + AppNavigationBar`
|
|
789
|
-
///
|
|
790
|
-
/// nothing lifts it, so the difference is applied as an offset (see NavigationFooter).
|
|
810
|
+
/// Compose keeps the FAB `Spacing.M + AppNavigationBar` up and lifts it with `imePadding()`; here it sits
|
|
811
|
+
/// `Spacing.M` above the safe area with nothing lifting it, so the difference is an offset (see NavigationFooter).
|
|
791
812
|
private var verticalOffset: CGFloat {
|
|
792
813
|
if hasFooter { return NavigationFooter.verticalOffset(keyboardSize: keyboardSize) }
|
|
793
814
|
return NavigationFooter.safeAreaBottom - NavigationFooter.navigationBarInset - keyboardSize
|
|
@@ -851,15 +872,8 @@ public struct NavigationFooter: View {
|
|
|
851
872
|
max(navigationBarInset + Spacing.S - safeAreaBottom, 0)
|
|
852
873
|
}
|
|
853
874
|
|
|
854
|
-
///
|
|
855
|
-
///
|
|
856
|
-
/// Negative lifts the band over the keyboard; positive shaves the few points by which
|
|
857
|
-
/// the safe area over-reserves compared to Compose. `FloatingContent` rides the same
|
|
858
|
-
/// amount so the FAB keeps its distance above the band.
|
|
859
|
-
///
|
|
860
|
-
/// Natural position is `safeAreaBottom + bottomPadding` above the bottom of the screen;
|
|
861
|
-
/// Compose puts it at `(AppNavigationBar - keyboard).coerceAtLeast(0) + Spacing.S` on
|
|
862
|
-
/// top of the `imePadding()` lift — i.e. `max(navigationBar, keyboard) + Spacing.S`.
|
|
875
|
+
/// An offset, not padding: growing the footer feeds back into keyboard avoidance and never settles. Lands at
|
|
876
|
+
/// Compose's `max(navigationBar, keyboard) + Spacing.S`; `FloatingContent` rides it so the FAB keeps its gap.
|
|
863
877
|
static func verticalOffset(keyboardSize: CGFloat) -> CGFloat {
|
|
864
878
|
(safeAreaBottom + bottomPadding) - (max(navigationBarInset, keyboardSize) + Spacing.S)
|
|
865
879
|
}
|
|
@@ -876,9 +890,8 @@ public struct NavigationFooter: View {
|
|
|
876
890
|
// without the margin the Spacing.S under the content goes too: negative, so the
|
|
877
891
|
// content sinks into the reserve while the frame keeps its bottom edge
|
|
878
892
|
.padding(.bottom, Self.bottomPadding - (Spacing.S - margin))
|
|
879
|
-
// Compose paints the surface
|
|
880
|
-
//
|
|
881
|
-
// With side insets (iPhone Duo) it stays inside them, off the side bar.
|
|
893
|
+
// Compose paints the surface down to the screen bottom: only the fill bleeds past the
|
|
894
|
+
// safe area, and with side insets (iPhone Duo) it stays inside them, off the side bar.
|
|
882
895
|
.background(
|
|
883
896
|
(transparent ? Color.clear : theme.colors.background.surface)
|
|
884
897
|
.ignoresSafeArea(.container, edges: hasSideInsets ? .bottom : [.bottom, .horizontal])
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/StackTransition.kt` (a 1:1 port of the RN kit's
|
|
6
|
-
// `forStackTransitionWithOverlay`) and of the NavHost it decorates. Every stack entry lives in
|
|
7
|
-
// its own UIHostingController, kept while the entry is on the stack and taken out of the window
|
|
8
|
-
// while covered, as UINavigationController does: a covered screen keeps its state, stops
|
|
9
|
-
// rendering and gets onDisappear / onAppear. The motion itself is drawn in SwiftUI, because an
|
|
10
|
-
// `offset` never moves the safe area the way a UIKit transform would.
|
|
11
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/StackTransition.kt` (RN `forStackTransitionWithOverlay`) and its NavHost.
|
|
2
|
+
// One UIHostingController per entry, out of the window while covered; motion is an `offset` to keep the safe area.
|
|
12
3
|
|
|
13
4
|
import SwiftUI
|
|
14
5
|
import UIKit
|
|
@@ -227,9 +218,11 @@ final class StackController: UIViewController {
|
|
|
227
218
|
let fraction = min(max((link.targetTimestamp - start) / transition.duration, 0), 1)
|
|
228
219
|
// linear for the stack: the gesture maps the finger straight onto this timeline
|
|
229
220
|
let eased = transition.kind == .rise ? fastOutSlowIn(CGFloat(fraction)) : CGFloat(fraction)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
221
|
+
if fraction >= 1 {
|
|
222
|
+
transition.coverage = transition.target
|
|
223
|
+
} else {
|
|
224
|
+
transition.coverage = transition.from + (transition.target - transition.from) * eased
|
|
225
|
+
}
|
|
233
226
|
apply(transition)
|
|
234
227
|
if fraction >= 1 { finish(transition) }
|
|
235
228
|
}
|