@momo-kits/native-kits 0.300.3-debug → 0.300.4-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 +51 -7
- package/README.md +2 -2
- package/compose/build.gradle.kts +10 -2
- package/compose/build.gradle.kts.backup +8 -0
- package/compose/compose.podspec +1 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +4 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +2 -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 +0 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +351 -111
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +20 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +9 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +4 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +10 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +6 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +55 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +12 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +7 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +13 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +14 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +19 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +5 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +7 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +20 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +43 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +10 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +6 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +197 -60
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +132 -83
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +54 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +377 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +122 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +34 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +113 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +37 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +20 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +13 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +15 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +3 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +4 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +138 -0
- package/gradle/libs.versions.toml +3 -14
- package/gradle/wrapper/gradle-wrapper.properties +0 -2
- package/gradle.properties +3 -5
- package/ios/Application/ApplicationEnvironment.swift +24 -6
- package/ios/Application/DesignSystemKits.swift +100 -0
- package/ios/Application/DesignSystemKitsPayload.swift +68 -0
- package/ios/Application/MaxApi.swift +30 -3
- package/ios/Avatar/Avatar.swift +4 -3
- package/ios/Badge/Badge.swift +6 -4
- package/ios/Badge/BadgeDot.swift +1 -1
- package/ios/Badge/BadgeRibbon.swift +8 -2
- package/ios/Button/Button.swift +15 -12
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +64 -18
- package/ios/Carousel/Carousel.swift +29 -12
- package/ios/Checkbox/Checkbox.swift +7 -3
- package/ios/Chip/Chip.swift +5 -4
- package/ios/Collapse/Collapse.swift +70 -19
- package/ios/Colors+Radius+Spacing/Colors.swift +10 -1
- package/ios/Colors+Radius+Spacing/Radius.swift +6 -0
- package/ios/DateTimePicker/DateTimePicker.swift +54 -20
- package/ios/DateTimePicker/WheelPicker.swift +103 -105
- package/ios/Divider/Divider.swift +37 -4
- package/ios/Extensions/Color++.swift +38 -9
- package/ios/Extensions/OptionalEnvironmentObject.swift +12 -0
- package/ios/Extensions/SkeletonUICompat.swift +11 -0
- package/ios/Icon/Icon.swift +21 -23
- package/ios/Icon/Icons.swift +1329 -0
- package/ios/IconButton/IconButton.swift +15 -7
- package/ios/Image/Image.swift +7 -23
- package/ios/Information/Information.swift +27 -9
- package/ios/Input/ErrorView.swift +2 -2
- package/ios/Input/Input.swift +171 -148
- package/ios/Input/InputPhoneNumber.swift +10 -9
- package/ios/Input/InputSearch.swift +107 -78
- package/ios/Input/InputTextArea.swift +133 -148
- package/ios/InputDropDown/InputDropDown.swift +10 -7
- package/ios/InputMoney/InputMoney.swift +32 -11
- package/ios/InputOTP/InputOTP.swift +22 -12
- package/ios/Layout/Card.swift +50 -0
- package/ios/Layout/GridContext.swift +187 -3
- package/ios/Layout/Item.swift +5 -4
- package/ios/Layout/ScreenLayout.swift +415 -0
- package/ios/Layout/Section.swift +4 -100
- package/ios/Loader/Loader.swift +5 -9
- package/ios/Lottie/LottieView.swift +14 -2
- package/ios/{Application/Navigation/Overplay → Navigation}/BottomSheet.swift +169 -29
- package/ios/Navigation/BottomTab/BottomTab.swift +332 -0
- package/ios/{Application/Navigation → Navigation}/BottomTab/BottomTabBar.swift +18 -7
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +104 -0
- package/ios/Navigation/BottomTab/DuoTabBar.swift +329 -0
- package/ios/{Application → Navigation/Component}/FloatingButton.swift +43 -54
- package/ios/Navigation/Component/Header.swift +545 -0
- package/ios/Navigation/Component/HeaderBackground.swift +154 -0
- package/ios/Navigation/Component/HeaderJourney.swift +73 -0
- package/ios/Navigation/Component/HeaderLocation.swift +48 -0
- package/ios/Navigation/Component/HeaderRight.swift +425 -0
- package/ios/Navigation/Component/HeaderTitle.swift +36 -0
- package/ios/{Application/Navigation → Navigation/Component}/HeaderUser.swift +21 -24
- package/ios/Navigation/Component/SideBar.swift +183 -0
- package/ios/{Application/Navigation/Overplay → Navigation/Component}/SnackBar.swift +8 -8
- package/ios/Navigation/HostBackGestureBridge.swift +78 -0
- package/ios/{Application/Navigation/Overplay → Navigation}/ModalScreen.swift +9 -2
- package/ios/Navigation/Navigation.swift +204 -0
- package/ios/Navigation/NavigationContainer.swift +195 -0
- package/ios/{Application/Navigation → Navigation}/Navigator.swift +207 -107
- package/ios/Navigation/StackScreen.swift +930 -0
- package/ios/Navigation/StackTransition.swift +400 -0
- package/ios/Navigation/SwipeBackHaptic.swift +33 -0
- package/ios/{Application/Navigation → Navigation}/Tracking/ScreenTracker.swift +12 -5
- package/ios/OTPKeyboard/OTPKeyboard.swift +8 -11
- package/ios/Pagination/PaginationScroll.swift +2 -2
- package/ios/Popup/PopupDisplay.swift +72 -135
- package/ios/Popup/PopupInput.swift +10 -13
- package/ios/Popup/PopupLayout.swift +138 -0
- package/ios/Popup/PopupNotify.swift +59 -69
- package/ios/Popup/PopupPromotion.swift +31 -47
- package/ios/PopupView/FullscreenPopup.swift +13 -19
- package/ios/PopupView/PopupView.swift +1 -1
- package/ios/PopupView/Utils++.swift +0 -8
- package/ios/ProgressInfo/ProgressInfo.swift +4 -2
- package/ios/Radio/Radio.swift +2 -1
- package/ios/Rating/Rating.swift +9 -1
- package/ios/Resources/dot_loading.json +558 -0
- package/ios/Resources/lottie_circle_loader.json +1 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +11 -10
- package/ios/Skeleton/Skeleton.swift +22 -27
- package/ios/Slider/Slider.swift +16 -18
- package/ios/Stepper/Stepper.swift +7 -3
- package/ios/Steps/Steps.swift +8 -6
- package/ios/SuggestAction/SuggestAction.swift +5 -0
- package/ios/Swipeable/SwipeCell.swift +10 -6
- package/ios/Switch/Switch.swift +22 -20
- package/ios/TabView/TabView.swift +102 -21
- package/ios/Tag/Tag.swift +15 -4
- package/ios/Template/Logo/Logo.swift +2 -1
- package/ios/Template/TrustBanner/TrustBanner.swift +109 -55
- package/ios/Title/Title.swift +6 -17
- package/ios/Tooltip/Tooltip.swift +29 -14
- package/ios/Typography/FontScale.swift +17 -14
- package/ios/Typography/Text.swift +156 -20
- package/ios/Typography/Typography.swift +2 -2
- package/ios/Uploader/Uploader.swift +3 -1
- package/ios/native-kits.podspec +2 -3
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -3
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DuoTabDemo.swift +80 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +2 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IPhoneDuoDemo.swift +173 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +77 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +2 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +2 -0
- package/package.json +1 -1
- package/publish.sh +19 -2
- package/scripts/gen-ios-icons.mjs +36 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
- package/ios/Application/Components.swift +0 -270
- package/ios/Application/ComposeApi.swift +0 -22
- package/ios/Application/HeaderRight.swift +0 -306
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +0 -104
- package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
- package/ios/Application/Navigation/HeaderTitle.swift +0 -57
- package/ios/Application/Navigation/NavigationContainer.swift +0 -213
- package/ios/Application/Navigation/NavigationOptions.swift +0 -109
- package/ios/Application/Navigation/NavigatorManager.swift +0 -22
- package/ios/Application/Navigation/component/Header.swift +0 -178
- package/ios/Application/Navigation/component/HeaderBackground.swift +0 -83
- package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
- package/ios/Application/Navigation/component/HeaderRightWidthKey.swift +0 -11
- package/ios/Application/Navigation/component/NavigationFooter.swift +0 -90
- package/ios/Application/Navigation/component/NavigationHeaderRight.swift +0 -196
- package/ios/Application/Screen.swift +0 -250
- package/ios/Application/StackScreen.swift +0 -492
- package/ios/Typography/FontScaleStore.swift +0 -58
- package/ios/Typography/KitDesignSystem.swift +0 -17
- /package/ios/{Application/Navigation → Navigation}/BottomTab/CurvedContainer.swift +0 -0
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HeaderBackProps.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `HeaderBackProps` + `PopupNotifyProps`/`PopupAction`.
|
|
6
|
-
// When `preventBack` is set, `Navigator.onBackSafe` shows a confirm popup
|
|
7
|
-
// before actually leaving the screen — same behavior as Compose.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
import SwiftUI
|
|
11
|
-
|
|
12
|
-
/// Mirrors Compose's `PopupAction` (a titled button with an optional handler).
|
|
13
|
-
public struct PopupAction {
|
|
14
|
-
public let title: String
|
|
15
|
-
public let onPress: (() -> Void)?
|
|
16
|
-
|
|
17
|
-
public init(title: String, onPress: (() -> Void)? = nil) {
|
|
18
|
-
self.title = title
|
|
19
|
-
self.onPress = onPress
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/// Mirrors Compose's `PopupNotifyProps` as consumed by `headerBackProps.preventBack`.
|
|
24
|
-
public struct PreventBackProps {
|
|
25
|
-
public var image: String
|
|
26
|
-
public var title: String
|
|
27
|
-
public var description: String
|
|
28
|
-
public var error: String
|
|
29
|
-
public var primary: PopupAction?
|
|
30
|
-
public var secondary: PopupAction?
|
|
31
|
-
public var buttonDirection: PopupButtonDirection
|
|
32
|
-
public var isShowCloseIcon: Bool
|
|
33
|
-
public var onIconClose: (() -> Void)?
|
|
34
|
-
|
|
35
|
-
public init(
|
|
36
|
-
image: String = "",
|
|
37
|
-
title: String = "",
|
|
38
|
-
description: String = "",
|
|
39
|
-
error: String = "",
|
|
40
|
-
primary: PopupAction? = nil,
|
|
41
|
-
secondary: PopupAction? = nil,
|
|
42
|
-
buttonDirection: PopupButtonDirection = .row,
|
|
43
|
-
isShowCloseIcon: Bool = true,
|
|
44
|
-
onIconClose: (() -> Void)? = nil
|
|
45
|
-
) {
|
|
46
|
-
self.image = image
|
|
47
|
-
self.title = title
|
|
48
|
-
self.description = description
|
|
49
|
-
self.error = error
|
|
50
|
-
self.primary = primary
|
|
51
|
-
self.secondary = secondary
|
|
52
|
-
self.buttonDirection = buttonDirection
|
|
53
|
-
self.isShowCloseIcon = isShowCloseIcon
|
|
54
|
-
self.onIconClose = onIconClose
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/// Mirrors Compose's `HeaderBackProps`.
|
|
59
|
-
public struct HeaderBackProps {
|
|
60
|
-
/// When non-nil, a confirm popup is shown before the back navigation runs.
|
|
61
|
-
public var preventBack: PreventBackProps?
|
|
62
|
-
|
|
63
|
-
public init(preventBack: PreventBackProps? = nil) {
|
|
64
|
-
self.preventBack = preventBack
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HeaderTitle.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `sealed class HeaderTitle` (navigation/component/Header.kt).
|
|
6
|
-
// The header can show either a plain title (`.default`) or a rich "user" title
|
|
7
|
-
// with an avatar group, subtitle, inline icons and a status dot (`.user`).
|
|
8
|
-
// (Compose's `Location`/`Journey` variants are not rendered yet, so they are
|
|
9
|
-
// omitted here for parity with the implemented `HeaderUser`.)
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
import SwiftUI
|
|
13
|
-
|
|
14
|
-
/// Data backing a `.user` header title (mirrors `HeaderTitle.User`).
|
|
15
|
-
public struct HeaderUserData {
|
|
16
|
-
public var title: String
|
|
17
|
-
public var subTitle: String?
|
|
18
|
-
public var image: [String]?
|
|
19
|
-
public var dotColor: Color?
|
|
20
|
-
public var tintColor: Color?
|
|
21
|
-
public var onPress: (() -> Void)?
|
|
22
|
-
public var icons: [String]
|
|
23
|
-
public var isLoading: Bool
|
|
24
|
-
|
|
25
|
-
public init(
|
|
26
|
-
title: String,
|
|
27
|
-
subTitle: String? = nil,
|
|
28
|
-
image: [String]? = nil,
|
|
29
|
-
dotColor: Color? = nil,
|
|
30
|
-
tintColor: Color? = nil,
|
|
31
|
-
onPress: (() -> Void)? = nil,
|
|
32
|
-
icons: [String] = [],
|
|
33
|
-
isLoading: Bool = false
|
|
34
|
-
) {
|
|
35
|
-
self.title = title
|
|
36
|
-
self.subTitle = subTitle
|
|
37
|
-
self.image = image
|
|
38
|
-
self.dotColor = dotColor
|
|
39
|
-
self.tintColor = tintColor
|
|
40
|
-
self.onPress = onPress
|
|
41
|
-
self.icons = icons
|
|
42
|
-
self.isLoading = isLoading
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/// Mirrors Compose's `HeaderTitle` sealed class.
|
|
47
|
-
public enum HeaderTitle {
|
|
48
|
-
case `default`(String)
|
|
49
|
-
case user(HeaderUserData)
|
|
50
|
-
|
|
51
|
-
/// Plain title text, when this is a `.default` title (used by the legacy
|
|
52
|
-
/// string-based `Header`/`NavigationOptions` paths).
|
|
53
|
-
public var defaultTitle: String? {
|
|
54
|
-
if case let .default(text) = self { return text }
|
|
55
|
-
return nil
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// NavigationContainer.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's NavigationContainer.
|
|
6
|
-
// Wraps NavigationStack, injects Navigator into the environment, and renders
|
|
7
|
-
// every registered screen inside `Screen(options)` chrome — same auto-wrap
|
|
8
|
-
// behavior as Compose's StackScreen.
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
import SwiftUI
|
|
12
|
-
|
|
13
|
-
@available(iOS 16.0, *)
|
|
14
|
-
public struct NavigationContainer<Initial: View>: View {
|
|
15
|
-
@StateObject private var navigator: Navigator
|
|
16
|
-
@StateObject private var applicationEnvironment: ApplicationEnvironment
|
|
17
|
-
@StateObject private var localize: Localize
|
|
18
|
-
|
|
19
|
-
private let setNavigator: ((Navigator) -> Void)?
|
|
20
|
-
private let composeApi: KitComposeApi?
|
|
21
|
-
private let maxApi: MaxApi?
|
|
22
|
-
|
|
23
|
-
public init(
|
|
24
|
-
initialScreenName: String = "",
|
|
25
|
-
@ViewBuilder initialScreen: @escaping () -> Initial,
|
|
26
|
-
options: NavigationOptions? = nil,
|
|
27
|
-
applicationContext: MiniAppContext? = nil,
|
|
28
|
-
composeApi: KitComposeApi? = nil,
|
|
29
|
-
config: KitConfig? = nil,
|
|
30
|
-
maxApi: MaxApi? = nil,
|
|
31
|
-
localize: Localize? = nil,
|
|
32
|
-
setNavigator: ((Navigator) -> Void)? = nil
|
|
33
|
-
) {
|
|
34
|
-
let nav = Navigator(
|
|
35
|
-
initialScreenName: initialScreenName.isEmpty ? (options?.screenName ?? "") : initialScreenName,
|
|
36
|
-
initialContent: { AnyView(initialScreen()) },
|
|
37
|
-
options: options,
|
|
38
|
-
composeApi: composeApi
|
|
39
|
-
)
|
|
40
|
-
_navigator = StateObject(wrappedValue: nav)
|
|
41
|
-
_applicationEnvironment = StateObject(
|
|
42
|
-
wrappedValue: ApplicationEnvironment(
|
|
43
|
-
applicationContext: applicationContext,
|
|
44
|
-
composeApi: composeApi,
|
|
45
|
-
config: config,
|
|
46
|
-
maxApi: maxApi
|
|
47
|
-
)
|
|
48
|
-
)
|
|
49
|
-
// AI-GENERATED START: default to the app-language-observing shared Localize
|
|
50
|
-
_localize = StateObject(wrappedValue: localize ?? Localize.shared)
|
|
51
|
-
// AI-GENERATED END: default to the app-language-observing shared Localize
|
|
52
|
-
self.composeApi = composeApi
|
|
53
|
-
self.maxApi = maxApi
|
|
54
|
-
self.setNavigator = setNavigator
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public var body: some View {
|
|
58
|
-
NavigationStack(path: $navigator.path) {
|
|
59
|
-
screenView(for: navigator.rootRoute)
|
|
60
|
-
.navigationDestination(for: DynamicScreenRoute.self) { route in
|
|
61
|
-
screenView(for: route)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
.environmentObject(navigator)
|
|
65
|
-
.environmentObject(applicationEnvironment)
|
|
66
|
-
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
67
|
-
// AI-GENERATED START: route Localize + font-scale injection through the observing modifiers
|
|
68
|
-
.momoLocalize(localize)
|
|
69
|
-
.momoFontScale(context: applicationEnvironment.applicationContext)
|
|
70
|
-
// AI-GENERATED END: route Localize + font-scale injection through the observing modifiers
|
|
71
|
-
.fullScreenCover(item: $navigator.presented) { route in
|
|
72
|
-
screenView(forDialog: route)
|
|
73
|
-
.environmentObject(navigator)
|
|
74
|
-
.environmentObject(applicationEnvironment)
|
|
75
|
-
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
76
|
-
// AI-GENERATED START: route Localize + font-scale injection through the observing modifiers
|
|
77
|
-
.momoLocalize(localize)
|
|
78
|
-
.momoFontScale(context: applicationEnvironment.applicationContext)
|
|
79
|
-
// AI-GENERATED END: route Localize + font-scale injection through the observing modifiers
|
|
80
|
-
}
|
|
81
|
-
.overlay {
|
|
82
|
-
if let item = navigator.overplay {
|
|
83
|
-
OverplayHost(item: item)
|
|
84
|
-
.environmentObject(navigator)
|
|
85
|
-
.environmentObject(applicationEnvironment)
|
|
86
|
-
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
87
|
-
// AI-GENERATED START: route Localize + font-scale injection through the observing modifiers
|
|
88
|
-
.momoLocalize(localize)
|
|
89
|
-
.momoFontScale(context: applicationEnvironment.applicationContext)
|
|
90
|
-
// AI-GENERATED END: route Localize + font-scale injection through the observing modifiers
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
.onAppear {
|
|
94
|
-
if navigator.composeApi == nil {
|
|
95
|
-
navigator.composeApi = composeApi
|
|
96
|
-
}
|
|
97
|
-
setNavigator?(navigator)
|
|
98
|
-
// Register with the host swipe-back bridge (mirrors ComposeAppContainer's
|
|
99
|
-
// ComposeNavigatorManager.push). Idempotent, so a re-appear won't double-count.
|
|
100
|
-
NavigatorManager.shared.push(navigator)
|
|
101
|
-
// AI-GENERATED START: demote the MaxApi language pull to a seed of last resort
|
|
102
|
-
// Only a seed: a Localize with a language source already tracks the host in both
|
|
103
|
-
// directions, so asking maxApi would just race it. `changeLanguage` normalizes the
|
|
104
|
-
// raw response and hops to main itself.
|
|
105
|
-
guard !localize.observesAppLanguage else { return }
|
|
106
|
-
maxApi?.getLanguage { data in
|
|
107
|
-
localize.changeLanguage(data?["response"] as? String)
|
|
108
|
-
}
|
|
109
|
-
// AI-GENERATED END: demote the MaxApi language pull to a seed of last resort
|
|
110
|
-
}
|
|
111
|
-
.onDisappear {
|
|
112
|
-
NavigatorManager.shared.remove(navigator)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@ViewBuilder
|
|
117
|
-
private func screenView(for route: DynamicScreenRoute) -> some View {
|
|
118
|
-
if let screen = navigator.registry.getScreen(id: route.id) {
|
|
119
|
-
ScreenHost(screen: screen, navigator: navigator)
|
|
120
|
-
.navigationBarBackButtonHidden(true)
|
|
121
|
-
} else {
|
|
122
|
-
EmptyView()
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@ViewBuilder
|
|
127
|
-
private func screenView(forDialog route: DynamicDialogRoute) -> some View {
|
|
128
|
-
if let screen = navigator.registry.getScreen(id: route.id) {
|
|
129
|
-
ScreenHost(screen: screen, navigator: navigator)
|
|
130
|
-
} else {
|
|
131
|
-
EmptyView()
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// MARK: - ScreenHost
|
|
137
|
-
|
|
138
|
-
@available(iOS 16.0, *)
|
|
139
|
-
private struct ScreenHost: View {
|
|
140
|
-
let screen: DynamicScreen
|
|
141
|
-
let navigator: Navigator
|
|
142
|
-
|
|
143
|
-
var body: some View {
|
|
144
|
-
let options = screen.options ?? NavigationOptions()
|
|
145
|
-
StackScreen(
|
|
146
|
-
backgroundColor: options.backgroundColor,
|
|
147
|
-
headerTransparent: options.headerTransparent,
|
|
148
|
-
fullScreenContent: options.fullScreenContent,
|
|
149
|
-
tintColor: options.tintColor ?? Colors.black17,
|
|
150
|
-
isBack: !options.hiddenBack,
|
|
151
|
-
headerType: options.headerType,
|
|
152
|
-
useAnimated: options.useAnimated,
|
|
153
|
-
title: options.title,
|
|
154
|
-
headerTitle: options.headerTitle,
|
|
155
|
-
titlePosition: options.titlePosition,
|
|
156
|
-
goBack: options.hiddenBack ? nil : { navigator.onBackSafe() },
|
|
157
|
-
scrollable: options.scrollable,
|
|
158
|
-
scrollToTopCallback: options.scrollToTopCallback,
|
|
159
|
-
useAvoidKeyboard: options.useAvoidKeyboard,
|
|
160
|
-
keyboardShouldPersistTaps: options.keyboardShouldPersistTaps,
|
|
161
|
-
footer: options.footer,
|
|
162
|
-
headerRight: options.resolvedHeaderRight,
|
|
163
|
-
animatedHeader: options.animatedHeader,
|
|
164
|
-
layoutOffset: options.layoutOffset,
|
|
165
|
-
inputSearchProps: options.inputSearchProps,
|
|
166
|
-
fabProps: options.fabProps,
|
|
167
|
-
screenName: screen.name,
|
|
168
|
-
content: { screen.content() }
|
|
169
|
-
)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// MARK: - Overplay host
|
|
174
|
-
|
|
175
|
-
@available(iOS 16.0, *)
|
|
176
|
-
private struct OverplayHost: View {
|
|
177
|
-
let item: OverplayItem
|
|
178
|
-
@EnvironmentObject var navigator: Navigator
|
|
179
|
-
|
|
180
|
-
var body: some View {
|
|
181
|
-
// Each component self-animates on appear and drives its own exit through
|
|
182
|
-
// the Navigator before the item is removed (mirrors Compose's overplay).
|
|
183
|
-
switch item.type {
|
|
184
|
-
case .modal:
|
|
185
|
-
ModalScreen(barrierDismissible: item.barrierDismissible) {
|
|
186
|
-
item.content()
|
|
187
|
-
}
|
|
188
|
-
.id(item.id)
|
|
189
|
-
case .bottomSheet:
|
|
190
|
-
BottomSheetView(
|
|
191
|
-
header: item.header ?? .title(),
|
|
192
|
-
isSurface: item.isSurface,
|
|
193
|
-
barrierDismissible: item.barrierDismissible
|
|
194
|
-
) {
|
|
195
|
-
item.content()
|
|
196
|
-
}
|
|
197
|
-
.id(item.id)
|
|
198
|
-
case .snackBar:
|
|
199
|
-
if let snackBar = item.snackBar {
|
|
200
|
-
SnackBarView(snackBar: snackBar, bottomInset: safeAreaBottomInset() + Spacing.S)
|
|
201
|
-
.id(item.id)
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/// Bottom safe-area inset (home indicator), used to lift the snack bar.
|
|
208
|
-
@available(iOS 16.0, *)
|
|
209
|
-
private func safeAreaBottomInset() -> CGFloat {
|
|
210
|
-
UIApplication.shared.connectedScenes
|
|
211
|
-
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
212
|
-
.first ?? 0
|
|
213
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// NavigationOptions.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's NavigationOptions.
|
|
6
|
-
// Each option lines up with a parameter on the existing `Screen` view,
|
|
7
|
-
// so NavigationContainer can auto-wrap a registered screen body in `Screen(options)`.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
import SwiftUI
|
|
11
|
-
|
|
12
|
-
public struct NavigationOptions {
|
|
13
|
-
public var screenName: String?
|
|
14
|
-
public var title: String
|
|
15
|
-
/// Rich header title (mirrors Compose's `headerTitle`). When set to `.user`
|
|
16
|
-
/// the header renders an avatar group instead of `title`; `.default` keeps
|
|
17
|
-
/// the plain `title` text.
|
|
18
|
-
public var headerTitle: HeaderTitle?
|
|
19
|
-
public var titlePosition: TitlePosition
|
|
20
|
-
public var headerType: HeaderType
|
|
21
|
-
/// Mirrors Compose's `HeaderType.Extended/Default(useAnimated = ...)`: when true
|
|
22
|
-
/// and `inputSearchProps` is set, the search bar animates into the header on scroll.
|
|
23
|
-
public var useAnimated: Bool
|
|
24
|
-
public var headerTransparent: Bool
|
|
25
|
-
public var fullScreenContent: Bool
|
|
26
|
-
public var hiddenBack: Bool
|
|
27
|
-
public var backgroundColor: Color?
|
|
28
|
-
public var tintColor: Color?
|
|
29
|
-
public var scrollable: Bool
|
|
30
|
-
/// Mirrors Compose's `ScrollData.scrollToTopCallback`: invoked when the
|
|
31
|
-
/// screen is asked to scroll to top (e.g. on a status-bar tap).
|
|
32
|
-
public var scrollToTopCallback: (() -> Void)?
|
|
33
|
-
public var useAvoidKeyboard: Bool
|
|
34
|
-
/// Mirrors Compose's `KeyboardOptions.keyboardShouldPersistTaps`: when true,
|
|
35
|
-
/// tapping anywhere on the screen dismisses the keyboard.
|
|
36
|
-
public var keyboardShouldPersistTaps: Bool
|
|
37
|
-
/// Mirrors Compose's `HeaderBackProps`: drives the prevent-back confirm popup.
|
|
38
|
-
public var headerBackProps: HeaderBackProps?
|
|
39
|
-
/// Typed toolkit data for the default header right control (mirrors
|
|
40
|
-
/// Compose's `HeaderRight.Toolkit`). Use `headerRight` for `.custom` and nil
|
|
41
|
-
/// for `.none`.
|
|
42
|
-
public var headerRightData: HeaderRightData?
|
|
43
|
-
public var headerRight: (() -> any View)?
|
|
44
|
-
public var footer: (() -> AnyView)?
|
|
45
|
-
public var animatedHeader: AnimatedHeader?
|
|
46
|
-
public var layoutOffset: CGFloat
|
|
47
|
-
public var inputSearchProps: InputSearchProps?
|
|
48
|
-
public var fabProps: FabProps?
|
|
49
|
-
public var onBackHandler: (() -> Void)?
|
|
50
|
-
|
|
51
|
-
public init(
|
|
52
|
-
screenName: String? = nil,
|
|
53
|
-
title: String = "Stack",
|
|
54
|
-
headerTitle: HeaderTitle? = nil,
|
|
55
|
-
titlePosition: TitlePosition = .left,
|
|
56
|
-
headerType: HeaderType = .default,
|
|
57
|
-
useAnimated: Bool = false,
|
|
58
|
-
headerTransparent: Bool = false,
|
|
59
|
-
fullScreenContent: Bool = false,
|
|
60
|
-
hiddenBack: Bool = false,
|
|
61
|
-
backgroundColor: Color? = nil,
|
|
62
|
-
tintColor: Color? = Colors.black17,
|
|
63
|
-
scrollable: Bool = true,
|
|
64
|
-
scrollToTopCallback: (() -> Void)? = nil,
|
|
65
|
-
useAvoidKeyboard: Bool = true,
|
|
66
|
-
keyboardShouldPersistTaps: Bool = false,
|
|
67
|
-
headerBackProps: HeaderBackProps? = nil,
|
|
68
|
-
headerRightData: HeaderRightData? = nil,
|
|
69
|
-
headerRight: (() -> any View)? = { HeaderRight() },
|
|
70
|
-
footer: (() -> AnyView)? = nil,
|
|
71
|
-
animatedHeader: AnimatedHeader? = nil,
|
|
72
|
-
layoutOffset: CGFloat = 56,
|
|
73
|
-
inputSearchProps: InputSearchProps? = nil,
|
|
74
|
-
fabProps: FabProps? = nil,
|
|
75
|
-
onBackHandler: (() -> Void)? = nil
|
|
76
|
-
) {
|
|
77
|
-
self.screenName = screenName
|
|
78
|
-
self.title = title
|
|
79
|
-
self.headerTitle = headerTitle
|
|
80
|
-
self.titlePosition = titlePosition
|
|
81
|
-
self.headerType = headerType
|
|
82
|
-
self.useAnimated = useAnimated
|
|
83
|
-
self.headerTransparent = headerTransparent
|
|
84
|
-
self.fullScreenContent = fullScreenContent
|
|
85
|
-
self.hiddenBack = hiddenBack
|
|
86
|
-
self.backgroundColor = backgroundColor
|
|
87
|
-
self.tintColor = tintColor
|
|
88
|
-
self.scrollable = scrollable
|
|
89
|
-
self.scrollToTopCallback = scrollToTopCallback
|
|
90
|
-
self.useAvoidKeyboard = useAvoidKeyboard
|
|
91
|
-
self.keyboardShouldPersistTaps = keyboardShouldPersistTaps
|
|
92
|
-
self.headerBackProps = headerBackProps
|
|
93
|
-
self.headerRightData = headerRightData
|
|
94
|
-
self.headerRight = headerRight
|
|
95
|
-
self.footer = footer
|
|
96
|
-
self.animatedHeader = animatedHeader
|
|
97
|
-
self.layoutOffset = layoutOffset
|
|
98
|
-
self.inputSearchProps = inputSearchProps
|
|
99
|
-
self.fabProps = fabProps
|
|
100
|
-
self.onBackHandler = onBackHandler
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
extension NavigationOptions {
|
|
105
|
-
var resolvedHeaderRight: (() -> any View)? {
|
|
106
|
-
guard let headerRightData else { return headerRight }
|
|
107
|
-
return { HeaderRight(headerRight: headerRightData, tintColor: tintColor) }
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
@available(iOS 16.0, *)
|
|
4
|
-
public final class NavigatorManager {
|
|
5
|
-
public static let shared = NavigatorManager()
|
|
6
|
-
private init() {}
|
|
7
|
-
|
|
8
|
-
private var navigators: [Navigator] = []
|
|
9
|
-
|
|
10
|
-
public func push(_ navigator: Navigator) {
|
|
11
|
-
guard !navigators.contains(where: { $0 === navigator }) else { return }
|
|
12
|
-
navigators.append(navigator)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public func remove(_ navigator: Navigator) {
|
|
16
|
-
navigators.removeAll { $0 === navigator }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public func checkCanPop() -> Bool { !navigators.isEmpty }
|
|
20
|
-
|
|
21
|
-
public func pop() { navigators.last?.onBackSafe() }
|
|
22
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Header.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `Header` (navigation/component/Header.kt).
|
|
6
|
-
// Renders the 52pt header bar: a circular back button (colors resolved via
|
|
7
|
-
// `getHeaderColor`), the title area (`HeaderContent` → plain title, user title
|
|
8
|
-
// or inline search), the header-right toolkit, and a scroll-triggered bottom
|
|
9
|
-
// shadow. The header band background itself is painted by `HeaderBackground`.
|
|
10
|
-
//
|
|
11
|
-
// Named `NavigationHeader` to coexist with the legacy `Header` in
|
|
12
|
-
// `Components.swift` (kept as-is, used as a package elsewhere; to be marked
|
|
13
|
-
// deprecated later). Used by the new `StackScreen` navigation path.
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
import SwiftUI
|
|
17
|
-
|
|
18
|
-
public struct NavigationHeader: View {
|
|
19
|
-
var headerType: HeaderType = .default
|
|
20
|
-
var titlePosition: TitlePosition
|
|
21
|
-
var title: String
|
|
22
|
-
/// Optional rich title (mirrors Compose's `HeaderTitle`); `.user` renders an
|
|
23
|
-
/// avatar group, `.default`/nil renders plain `title`.
|
|
24
|
-
var headerTitle: HeaderTitle?
|
|
25
|
-
var headerRight: (() -> any View)? = { NavigationHeaderRight() }
|
|
26
|
-
var goBack: (() -> Void)?
|
|
27
|
-
var opacity: CGFloat = 1
|
|
28
|
-
var animatedHeader: AnimatedHeader?
|
|
29
|
-
var scrollState: CGFloat = 0
|
|
30
|
-
var inputSearchProps: InputSearchProps?
|
|
31
|
-
var tintColor: Color?
|
|
32
|
-
/// Title opacity; used by the animated search header to fade the title out on scroll.
|
|
33
|
-
var titleOpacity: CGFloat = 1
|
|
34
|
-
|
|
35
|
-
public init(
|
|
36
|
-
headerType: HeaderType = .default,
|
|
37
|
-
titlePosition: TitlePosition,
|
|
38
|
-
title: String,
|
|
39
|
-
headerTitle: HeaderTitle? = nil,
|
|
40
|
-
headerRight: (() -> any View)? = { HeaderRight() },
|
|
41
|
-
goBack: (() -> Void)? = nil,
|
|
42
|
-
opacity: CGFloat = 1,
|
|
43
|
-
animatedHeader: AnimatedHeader? = nil,
|
|
44
|
-
scrollState: CGFloat = 0,
|
|
45
|
-
inputSearchProps: InputSearchProps? = nil,
|
|
46
|
-
tintColor: Color? = nil,
|
|
47
|
-
titleOpacity: CGFloat = 1
|
|
48
|
-
) {
|
|
49
|
-
self.headerType = headerType
|
|
50
|
-
self.titlePosition = titlePosition
|
|
51
|
-
self.title = title
|
|
52
|
-
self.headerTitle = headerTitle
|
|
53
|
-
self.headerRight = headerRight
|
|
54
|
-
self.goBack = goBack
|
|
55
|
-
self.opacity = opacity
|
|
56
|
-
self.animatedHeader = animatedHeader
|
|
57
|
-
self.scrollState = scrollState
|
|
58
|
-
self.inputSearchProps = inputSearchProps
|
|
59
|
-
self.tintColor = tintColor
|
|
60
|
-
self.titleOpacity = titleOpacity
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private var isAnimated: Bool { animatedHeader != nil }
|
|
64
|
-
private var isSurface: Bool { animatedHeader?.isSurface ?? true }
|
|
65
|
-
|
|
66
|
-
private var headerColor: HeaderColor {
|
|
67
|
-
getHeaderColor(isAnimated: isAnimated, isSurface: isSurface, opacity: opacity, tintColor: tintColor)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/// Centered title needs a full-width overlay to stay screen-centered, not
|
|
71
|
-
/// boxed between the back button and the header-right (mirrors Compose).
|
|
72
|
-
private var centerTitle: Bool {
|
|
73
|
-
guard inputSearchProps == nil else { return false }
|
|
74
|
-
let isDefault = headerTitle == nil || headerTitle?.defaultTitle != nil
|
|
75
|
-
return titlePosition == .center && isDefault
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public var body: some View {
|
|
79
|
-
if headerType != .none {
|
|
80
|
-
ZStack {
|
|
81
|
-
HStack(spacing: 0) {
|
|
82
|
-
if let goBack {
|
|
83
|
-
BackButton(color: headerColor, onBack: goBack)
|
|
84
|
-
Spacer().frame(width: Spacing.S)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if centerTitle {
|
|
88
|
-
Spacer()
|
|
89
|
-
} else {
|
|
90
|
-
titleArea(centered: false)
|
|
91
|
-
.frame(maxWidth: .infinity, alignment: .leading)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if let headerRight {
|
|
95
|
-
AnyView(headerRight())
|
|
96
|
-
.background(
|
|
97
|
-
GeometryReader { geo in
|
|
98
|
-
Color.clear.preference(key: HeaderRightWidthKey.self, value: geo.size.width)
|
|
99
|
-
}
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
.padding(.horizontal, Spacing.M)
|
|
104
|
-
|
|
105
|
-
if centerTitle {
|
|
106
|
-
titleArea(centered: true)
|
|
107
|
-
.padding(.horizontal, Spacing.M)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
.frame(height: HEADER_HEIGHT)
|
|
111
|
-
.overlay(alignment: .bottom) { VerticalShadow(opacity: opacity) }
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/// Mirrors Compose's `HeaderContent`: plain title, user title, or — when a
|
|
116
|
-
/// header search is active — the inline search field.
|
|
117
|
-
@ViewBuilder
|
|
118
|
-
private func titleArea(centered: Bool) -> some View {
|
|
119
|
-
if let inputSearchProps {
|
|
120
|
-
InputSearch(props: inputSearchProps)
|
|
121
|
-
} else if case let .user(userData)? = headerTitle {
|
|
122
|
-
if #available(iOS 16.0, *) {
|
|
123
|
-
HeaderUserView(userData)
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
MomoText(
|
|
127
|
-
headerTitle?.defaultTitle ?? title,
|
|
128
|
-
typography: .actionSBold,
|
|
129
|
-
color: headerColor.tintIconColor,
|
|
130
|
-
textAlign: centered ? .center : .leading,
|
|
131
|
-
maxLines: 1
|
|
132
|
-
)
|
|
133
|
-
.opacity(titleOpacity)
|
|
134
|
-
.truncationMode(.tail)
|
|
135
|
-
.frame(maxWidth: centered ? .infinity : nil, alignment: centered ? .center : .leading)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// MARK: - Back button
|
|
141
|
-
|
|
142
|
-
/// Mirrors Compose's `BackButton`: a 28pt circular control with the back arrow.
|
|
143
|
-
private struct BackButton: View {
|
|
144
|
-
let color: HeaderColor
|
|
145
|
-
let onBack: () -> Void
|
|
146
|
-
|
|
147
|
-
var body: some View {
|
|
148
|
-
SwiftUI.Button(action: onBack) {
|
|
149
|
-
Circle()
|
|
150
|
-
.fill(color.backgroundButton)
|
|
151
|
-
.overlay(Circle().stroke(color.borderColor, lineWidth: 0.2))
|
|
152
|
-
.frame(width: 28, height: 28)
|
|
153
|
-
.overlay(Icon(source: "arrow-back", size: 20, color: color.tintIconColor))
|
|
154
|
-
}
|
|
155
|
-
.buttonStyle(.plain)
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// MARK: - Vertical shadow
|
|
160
|
-
|
|
161
|
-
/// Mirrors Compose's `VerticalShadow`: a 6pt drop shadow under the header that
|
|
162
|
-
/// only appears once the header is fully opaque (scrolled).
|
|
163
|
-
private struct VerticalShadow: View {
|
|
164
|
-
let opacity: CGFloat
|
|
165
|
-
|
|
166
|
-
var body: some View {
|
|
167
|
-
if opacity >= 1 {
|
|
168
|
-
LinearGradient(
|
|
169
|
-
gradient: Gradient(colors: [Color.black.opacity(0.05), .clear]),
|
|
170
|
-
startPoint: .top,
|
|
171
|
-
endPoint: .bottom
|
|
172
|
-
)
|
|
173
|
-
.frame(height: 6)
|
|
174
|
-
.frame(maxWidth: .infinity)
|
|
175
|
-
.offset(y: 6)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|