@momo-kits/native-kits 0.167.1-duo.8 → 0.167.1-duo.9-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 +4 -1
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +204 -0
- package/compose/build.gradle.kts.backup +204 -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 +153 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +124 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +293 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +831 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +378 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +361 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -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 +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +297 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +338 -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 +137 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +393 -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 +708 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +312 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +408 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +92 -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 +366 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +37 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +40 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +86 -0
- package/gradle/libs.versions.toml +69 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Application/ApplicationEnvironment.swift +11 -0
- package/ios/Application/ComposeApi.swift +2 -1
- package/ios/Application/{Components.swift → LegacyHeader.swift} +6 -62
- package/ios/Application/Screen.swift +3 -2
- 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 +0 -1
- package/ios/Button/Button.swift +15 -12
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +12 -20
- 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 +9 -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 +18 -0
- package/ios/Icon/Icon.swift +7 -1
- package/ios/IconButton/IconButton.swift +15 -7
- package/ios/Image/Image.swift +7 -34
- package/ios/Information/Information.swift +27 -9
- package/ios/Input/ErrorView.swift +2 -2
- package/ios/Input/Input.swift +160 -147
- package/ios/Input/InputPhoneNumber.swift +12 -9
- package/ios/Input/InputSearch.swift +102 -75
- package/ios/Input/InputTextArea.swift +128 -145
- package/ios/InputDropDown/InputDropDown.swift +10 -7
- package/ios/InputMoney/InputMoney.swift +33 -11
- package/ios/InputOTP/InputOTP.swift +22 -12
- package/ios/Layout/Card.swift +50 -0
- package/ios/Layout/GridContext.swift +123 -3
- package/ios/Layout/Item.swift +5 -4
- package/ios/Layout/Section.swift +4 -100
- package/ios/Loader/Loader.swift +5 -9
- package/ios/Lottie/LottieView.swift +10 -0
- package/ios/{Application/Navigation/Overplay → Navigation}/BottomSheet.swift +61 -9
- package/ios/{Application/Navigation → Navigation}/BottomTab/BottomTab.swift +60 -34
- package/ios/{Application/Navigation → Navigation}/BottomTab/BottomTabBar.swift +11 -6
- package/ios/{Application → Navigation/Component}/FloatingButton.swift +14 -3
- package/ios/Navigation/Component/Header.swift +493 -0
- package/ios/Navigation/Component/HeaderBackground.swift +134 -0
- package/ios/Navigation/Component/HeaderJourney.swift +73 -0
- package/ios/Navigation/Component/HeaderLocation.swift +48 -0
- package/ios/Navigation/Component/HeaderRight.swift +386 -0
- package/ios/Navigation/Component/HeaderTitle.swift +36 -0
- package/ios/{Application/Navigation → Navigation/Component}/HeaderUser.swift +20 -23
- package/ios/{Application/Navigation/component → Navigation/Component}/SideBar.swift +49 -28
- package/ios/{Application/Navigation/Overplay → Navigation/Component}/SnackBar.swift +5 -5
- package/ios/Navigation/HostBackGestureBridge.swift +57 -0
- package/ios/Navigation/Navigation.swift +190 -0
- package/ios/{Application/Navigation → Navigation}/NavigationContainer.swift +46 -41
- package/ios/{Application/Navigation → Navigation}/Navigator.swift +65 -9
- package/ios/{Application → Navigation}/StackScreen.swift +236 -103
- 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 +79 -159
- package/ios/Popup/PopupInput.swift +10 -13
- package/ios/Popup/PopupLayout.swift +97 -2
- package/ios/Popup/PopupNotify.swift +27 -55
- package/ios/Popup/PopupPromotion.swift +22 -50
- 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/ScrollIndicator/ScrollIndicator.swift +11 -10
- package/ios/Skeleton/Skeleton.swift +22 -27
- package/ios/Slider/Slider.swift +16 -18
- package/ios/Stepper/Stepper.swift +6 -1
- 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 +41 -27
- package/ios/Title/Title.swift +6 -17
- package/ios/Tooltip/Tooltip.swift +29 -14
- package/ios/Typography/Text.swift +61 -19
- package/ios/Uploader/Uploader.swift +3 -1
- package/ios/native-kits.podspec +1 -0
- package/ios-demo/README.md +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +77 -1
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
- package/ios/Application/HeaderRight.swift +0 -324
- package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
- package/ios/Application/Navigation/HeaderTitle.swift +0 -57
- package/ios/Application/Navigation/NavigationOptions.swift +0 -109
- package/ios/Application/Navigation/NavigatorManager.swift +0 -29
- package/ios/Application/Navigation/component/DuoScrollGradient.swift +0 -54
- package/ios/Application/Navigation/component/Header.swift +0 -183
- package/ios/Application/Navigation/component/HeaderBackground.swift +0 -84
- 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 -280
- /package/ios/{Application/Layout → Layout}/ScreenLayout.swift +0 -0
- /package/ios/{Application/Navigation → Navigation}/BottomTab/CurvedContainer.swift +0 -0
- /package/ios/{Application/Navigation → Navigation}/BottomTab/DuoBarCompression.swift +0 -0
- /package/ios/{Application/Navigation → Navigation}/BottomTab/DuoTabBar.swift +0 -0
- /package/ios/{Application/Navigation/Overplay → Navigation}/ModalScreen.swift +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# MoMoUIKitsDemo
|
|
2
|
+
|
|
3
|
+
SwiftUI demo browser for `MoMoUIKits`.
|
|
4
|
+
|
|
5
|
+
The package can optionally host a Compose UIKits screen by receiving a
|
|
6
|
+
`UIViewController` factory from the host app. It does not import the KMP
|
|
7
|
+
`shared` module directly.
|
|
8
|
+
|
|
9
|
+
SwiftUI mode reuses the full demo screen set from
|
|
10
|
+
`sample/iosApp/iosApp/Demo`, including the sample `HomeView` registry and demo
|
|
11
|
+
screens for all currently available components.
|
|
12
|
+
|
|
13
|
+
## CocoaPods
|
|
14
|
+
|
|
15
|
+
In the host app `Podfile`, include both local pods:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
pod 'MoMoUIKits', :path => '../momo-native-kits/ios/native-kits.podspec'
|
|
19
|
+
pod 'MoMoUIKitsDemo', :path => '../momo-native-kits/ios-demo'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Adjust the relative paths to match the host app checkout.
|
|
23
|
+
|
|
24
|
+
## Host App Usage
|
|
25
|
+
|
|
26
|
+
```swift
|
|
27
|
+
import MoMoUIKitsDemo
|
|
28
|
+
import shared
|
|
29
|
+
|
|
30
|
+
class UIKitsViewController: BaseComposeAppViewController {
|
|
31
|
+
override func getViewController() -> UIViewController? {
|
|
32
|
+
let params = self.application.data as? [String: Any]
|
|
33
|
+
|
|
34
|
+
return MoMoUIKitsDemoViewControllerFactory.make(
|
|
35
|
+
context: MoMoUIKitsDemoContext(
|
|
36
|
+
appId: params?["appId"] as? String ?? "",
|
|
37
|
+
appCode: params?["code"] as? String ?? "",
|
|
38
|
+
appName: params?["name"] as? String,
|
|
39
|
+
appIcon: params?["icon"] as? String ?? ""
|
|
40
|
+
),
|
|
41
|
+
composeViewController: {
|
|
42
|
+
UIKitsScreenComposeViewControllerKt.UIKitsScreenComposeViewController(
|
|
43
|
+
params: params
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override func viewDidDisappear(_ animated: Bool) {
|
|
50
|
+
super.viewDidDisappear(animated)
|
|
51
|
+
composeViewController = nil
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If the host does not pass `composeViewController`, the demo opens directly in
|
|
57
|
+
SwiftUI mode.
|
|
58
|
+
|
|
59
|
+
## Included SwiftUI Demos
|
|
60
|
+
|
|
61
|
+
The pod includes the sample demo screens for:
|
|
62
|
+
|
|
63
|
+
- Animated Header
|
|
64
|
+
- Avatar
|
|
65
|
+
- Badge
|
|
66
|
+
- Baseline View
|
|
67
|
+
- Bottom Tab
|
|
68
|
+
- Button
|
|
69
|
+
- Carousel
|
|
70
|
+
- Checkbox
|
|
71
|
+
- Chip
|
|
72
|
+
- Collapse
|
|
73
|
+
- DateTimePicker
|
|
74
|
+
- Divider
|
|
75
|
+
- Header User
|
|
76
|
+
- Icon Button
|
|
77
|
+
- Image
|
|
78
|
+
- Information
|
|
79
|
+
- Input
|
|
80
|
+
- Input DropDown
|
|
81
|
+
- Input Money
|
|
82
|
+
- Input OTP
|
|
83
|
+
- Input Phone Number
|
|
84
|
+
- Input Search
|
|
85
|
+
- Input TextArea
|
|
86
|
+
- Loader
|
|
87
|
+
- Navigation
|
|
88
|
+
- Pagination
|
|
89
|
+
- Popup Display
|
|
90
|
+
- Popup Notify
|
|
91
|
+
- Popup Promotion
|
|
92
|
+
- Progress Info
|
|
93
|
+
- Radio
|
|
94
|
+
- Rating
|
|
95
|
+
- Skeleton
|
|
96
|
+
- Slider
|
|
97
|
+
- SnackBar
|
|
98
|
+
- Stepper
|
|
99
|
+
- Steps
|
|
100
|
+
- Suggest Action
|
|
101
|
+
- Swipe
|
|
102
|
+
- Switch
|
|
103
|
+
- TabView
|
|
104
|
+
- Tag
|
|
105
|
+
- Theme
|
|
106
|
+
- Title
|
|
107
|
+
- Tooltip
|
|
108
|
+
- Typography
|
|
109
|
+
- Uploader
|
|
110
|
+
|
|
111
|
+
## Validation Notes
|
|
112
|
+
|
|
113
|
+
Validated locally with:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
pod ipc spec ios/MoMoUIKits.podspec
|
|
117
|
+
pod ipc spec ios-demo/MoMoUIKitsDemo.podspec
|
|
118
|
+
pod lib lint ios/MoMoUIKits.podspec --allow-warnings --skip-import-validation
|
|
119
|
+
pod lib lint ios-demo/MoMoUIKitsDemo.podspec --allow-warnings --skip-import-validation --include-podspecs=ios/MoMoUIKits.podspec
|
|
120
|
+
```
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Usage demo for the navigation flow. Mirrors Compose's `NavigationUsage`:
|
|
6
6
|
// exercises push / present / replace / reset, the modal & bottom-sheet
|
|
7
|
-
// overplays, the snack bar, the
|
|
7
|
+
// overplays, the snack bar, the header titles, runtime options and the bottom-tab layout.
|
|
8
8
|
//
|
|
9
9
|
|
|
10
10
|
import MoMoUIKits
|
|
@@ -149,6 +149,52 @@ private struct NavigationDemoContent: View {
|
|
|
149
149
|
)
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
row("Header Location Title") {
|
|
153
|
+
navigator.push(
|
|
154
|
+
{ DemoLeafScreen(title: "Location title", color: Colors.blue09) },
|
|
155
|
+
options: NavigationOptions(
|
|
156
|
+
headerTitle: .location(
|
|
157
|
+
HeaderLocationData(description: "Deliver to", location: "123 Nguyen Hue, District 1", onPress: { print("location") })
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
row("Header Journey Title") {
|
|
164
|
+
navigator.push(
|
|
165
|
+
{ DemoLeafScreen(title: "Journey title", color: Colors.pink09) },
|
|
166
|
+
options: NavigationOptions(
|
|
167
|
+
headerTitle: .journey(
|
|
168
|
+
HeaderJourneyData(start: "Ho Chi Minh", end: "Ha Noi", description: "Mon, 12/10 · 1 adult", icon: "16_arrow_chevron_right", onPress: { print("journey") })
|
|
169
|
+
)
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
row("Update Options At Runtime") {
|
|
175
|
+
navigator.push(
|
|
176
|
+
{ UpdateOptionsScreen() },
|
|
177
|
+
options: NavigationOptions(title: "Before update")
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
row("Bottom Sheet With Footer") {
|
|
182
|
+
navigator.showBottomSheet({
|
|
183
|
+
VStack(spacing: 12) {
|
|
184
|
+
ForEach(0..<6, id: \.self) { i in
|
|
185
|
+
MomoText("Bottom sheet row \(i + 1)")
|
|
186
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
.padding(Spacing.L)
|
|
190
|
+
}, header: .title("Footer"), draggable: false, footer: {
|
|
191
|
+
AnyView(
|
|
192
|
+
MoMoUIKits.Button(title: "Confirm", action: { navigator.hideOverplay() }, type: .primary, size: .large)
|
|
193
|
+
.padding(.horizontal, Spacing.M)
|
|
194
|
+
)
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
|
|
152
198
|
row("Header Animated") {
|
|
153
199
|
navigator.push(
|
|
154
200
|
{ AnimatedHeaderDemoContent() },
|
|
@@ -177,6 +223,36 @@ private struct NavigationDemoContent: View {
|
|
|
177
223
|
|
|
178
224
|
// MARK: - Leaf / presented screens
|
|
179
225
|
|
|
226
|
+
/// A screen changing its own header and footer after it is shown (Compose `LocalNavigation`).
|
|
227
|
+
@available(iOS 16.0, *)
|
|
228
|
+
private struct UpdateOptionsScreen: View {
|
|
229
|
+
@EnvironmentObject private var navigation: Navigation
|
|
230
|
+
@EnvironmentObject private var navigator: Navigator
|
|
231
|
+
|
|
232
|
+
var body: some View {
|
|
233
|
+
VStack(spacing: 16) {
|
|
234
|
+
MoMoUIKits.Button(title: "Change title", action: {
|
|
235
|
+
navigation.setOptions { $0.title = "Updated at \(Date().formatted(date: .omitted, time: .standard))" }
|
|
236
|
+
}, type: .primary, size: .large)
|
|
237
|
+
MoMoUIKits.Button(title: "Add footer", action: {
|
|
238
|
+
navigation.setOptions {
|
|
239
|
+
$0.footer = { AnyView(MoMoUIKits.Button(title: "Footer action", action: {}, type: .primary, size: .large)) }
|
|
240
|
+
}
|
|
241
|
+
}, type: .secondary, size: .large)
|
|
242
|
+
MoMoUIKits.Button(title: "Show snack bar above the footer", action: {
|
|
243
|
+
navigator.showSnackBar(.custom(duration: 2.0) {
|
|
244
|
+
MomoText("Snack bar", color: Colors.black01)
|
|
245
|
+
.frame(maxWidth: .infinity, minHeight: 48)
|
|
246
|
+
.background(Colors.black17)
|
|
247
|
+
.clipShape(RoundedRectangle(cornerRadius: Radius.M))
|
|
248
|
+
.padding(.horizontal, Spacing.M)
|
|
249
|
+
})
|
|
250
|
+
}, type: .secondary, size: .large)
|
|
251
|
+
}
|
|
252
|
+
.padding(16)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
180
256
|
@available(iOS 16.0, *)
|
|
181
257
|
private struct DemoLeafScreen: View {
|
|
182
258
|
@EnvironmentObject private var navigator: Navigator
|
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import org.gradle.kotlin.dsl.maven
|
|
2
|
+
|
|
3
|
+
rootProject.name = "momo-native-kits"
|
|
4
|
+
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
|
5
|
+
|
|
6
|
+
pluginManagement {
|
|
7
|
+
repositories {
|
|
8
|
+
google {
|
|
9
|
+
mavenContent {
|
|
10
|
+
includeGroupAndSubgroups("androidx")
|
|
11
|
+
includeGroupAndSubgroups("com.android")
|
|
12
|
+
includeGroupAndSubgroups("com.google")
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
mavenCentral()
|
|
16
|
+
gradlePluginPortal()
|
|
17
|
+
maven {
|
|
18
|
+
url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
|
|
19
|
+
credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
|
|
20
|
+
}
|
|
21
|
+
maven {
|
|
22
|
+
url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
|
|
23
|
+
credentials {
|
|
24
|
+
username = "viewer"
|
|
25
|
+
password = "viewer"
|
|
26
|
+
}
|
|
27
|
+
isAllowInsecureProtocol = true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dependencyResolutionManagement {
|
|
33
|
+
repositories {
|
|
34
|
+
google {
|
|
35
|
+
mavenContent {
|
|
36
|
+
includeGroupAndSubgroups("androidx")
|
|
37
|
+
includeGroupAndSubgroups("com.android")
|
|
38
|
+
includeGroupAndSubgroups("com.google")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
mavenCentral()
|
|
42
|
+
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
|
|
43
|
+
maven {
|
|
44
|
+
url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
|
|
45
|
+
credentials {
|
|
46
|
+
username = "download_packages";
|
|
47
|
+
password = "gldt-bjDqLpU_sPcHDuXau2ws"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
maven {
|
|
51
|
+
url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
|
|
52
|
+
credentials {
|
|
53
|
+
username = "viewer"
|
|
54
|
+
password = "viewer"
|
|
55
|
+
}
|
|
56
|
+
isAllowInsecureProtocol = true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
include(":compose")
|
|
62
|
+
|
|
63
|
+
include(":sample:androidApp")
|
|
64
|
+
include(":sample:shared")
|
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
import Foundation
|
|
3
|
-
|
|
4
|
-
public struct HeaderRightData {
|
|
5
|
-
var useShortcut: Bool
|
|
6
|
-
var useMore: Bool
|
|
7
|
-
var tools: [ToolGroup]
|
|
8
|
-
var toolCallback: ((String) -> Void)?
|
|
9
|
-
var useSystemTools: Bool
|
|
10
|
-
var useCloseIcon: Bool
|
|
11
|
-
|
|
12
|
-
public init(
|
|
13
|
-
useShortcut: Bool = false,
|
|
14
|
-
useMore: Bool = false,
|
|
15
|
-
tools: [ToolGroup] = [],
|
|
16
|
-
toolCallback: ((String) -> Void)? = nil,
|
|
17
|
-
useSystemTools: Bool = true,
|
|
18
|
-
useCloseIcon: Bool = false
|
|
19
|
-
) {
|
|
20
|
-
self.useShortcut = useShortcut
|
|
21
|
-
self.useMore = useMore
|
|
22
|
-
self.tools = tools
|
|
23
|
-
self.toolCallback = toolCallback
|
|
24
|
-
self.useSystemTools = useSystemTools
|
|
25
|
-
self.useCloseIcon = useCloseIcon
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/// Close-circle instead of home, as RN `headerRight.useCloseIcon`.
|
|
29
|
-
var closeIcon: String { useCloseIcon ? "16_navigation_close_circle" : "16_basic_home" }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/// The Help Center mini-app hides its own help-center button.
|
|
33
|
-
func showsHelpCenter(_ context: MiniAppContext?) -> Bool {
|
|
34
|
-
context?.appId != "vn.momo.helpcenter"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public struct Tool {
|
|
38
|
-
var key: String
|
|
39
|
-
var icon: String
|
|
40
|
-
var showBadge: Bool
|
|
41
|
-
var name: [String: String]
|
|
42
|
-
var showRightIcon: Bool
|
|
43
|
-
|
|
44
|
-
public init(
|
|
45
|
-
key: String,
|
|
46
|
-
icon: String,
|
|
47
|
-
name: [String: String] = [:],
|
|
48
|
-
showBadge: Bool = false,
|
|
49
|
-
showRightIcon: Bool = true
|
|
50
|
-
) {
|
|
51
|
-
self.key = key
|
|
52
|
-
self.icon = icon
|
|
53
|
-
self.showBadge = showBadge
|
|
54
|
-
self.name = name
|
|
55
|
-
self.showRightIcon = showRightIcon
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
func toMap() -> [String: Any] {
|
|
59
|
-
return [
|
|
60
|
-
"key": key,
|
|
61
|
-
"icon": icon,
|
|
62
|
-
"showBadge": showBadge,
|
|
63
|
-
"name": name,
|
|
64
|
-
"showRightIcon": showRightIcon
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public struct ToolGroup {
|
|
70
|
-
var title: [String: String]
|
|
71
|
-
var items: [Tool]
|
|
72
|
-
|
|
73
|
-
public init(
|
|
74
|
-
title: [String: String] = [:],
|
|
75
|
-
items: [Tool]
|
|
76
|
-
) {
|
|
77
|
-
self.title = title
|
|
78
|
-
self.items = items
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
func toMap() -> [String: Any] {
|
|
82
|
-
return [
|
|
83
|
-
"title": title,
|
|
84
|
-
"items": items.map { $0.toMap() }
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
struct NavigationButtonConfig {
|
|
90
|
-
let icon: String
|
|
91
|
-
let onPress: () -> Void
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// MARK: - Components
|
|
95
|
-
public struct HeaderRight: View {
|
|
96
|
-
public init(headerRight: HeaderRightData? = nil, tintColor: Color? = nil) {
|
|
97
|
-
self.headerRight = headerRight
|
|
98
|
-
self.tintColor = tintColor
|
|
99
|
-
}
|
|
100
|
-
var headerRight: HeaderRightData?
|
|
101
|
-
var tintColor: Color? = nil
|
|
102
|
-
|
|
103
|
-
public var body: some View {
|
|
104
|
-
HStack(alignment: .center) {
|
|
105
|
-
ToolkitHeaderRight(headerRight: headerRight, tintColor: tintColor)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
struct ToolkitHeaderRight: View {
|
|
111
|
-
var headerRight: HeaderRightData?
|
|
112
|
-
var tintColor: Color?
|
|
113
|
-
@State private var isFavorite: Bool = false
|
|
114
|
-
@State private var isLoading: Bool = false
|
|
115
|
-
// Legacy hosts inject with `.environmentObject`, containers with the keyed value; outside
|
|
116
|
-
// both this used to trap, so read the object optionally and fall back to the keyed one.
|
|
117
|
-
@OptionalEnvironmentObject private var injectedEnvironment: ApplicationEnvironment?
|
|
118
|
-
@Environment(\.applicationEnvironment) private var keyedEnvironment
|
|
119
|
-
|
|
120
|
-
private var environment: ApplicationEnvironment { injectedEnvironment ?? keyedEnvironment }
|
|
121
|
-
|
|
122
|
-
// MARK: - Actions
|
|
123
|
-
private func onPressShortcut() {
|
|
124
|
-
// onToolAction needs the app context (appId/code) so the host knows which app to (un)favorite;
|
|
125
|
-
// without it the favorite is a no-op. Mirrors onPressMore below and the Compose HeaderRight.
|
|
126
|
-
let context = environment.applicationContext
|
|
127
|
-
environment.composeApi?.request(
|
|
128
|
-
funcName: "onToolAction",
|
|
129
|
-
params: [
|
|
130
|
-
"item": ["key": "onFavorite"],
|
|
131
|
-
"context": [
|
|
132
|
-
"appId": context?.appId,
|
|
133
|
-
"code": context?.appCode,
|
|
134
|
-
"name": context?.appName,
|
|
135
|
-
"icon": context?.appIcon,
|
|
136
|
-
"description": context?.description,
|
|
137
|
-
"support": context?.support,
|
|
138
|
-
"toolkitConfig": context?.toolkitConfig,
|
|
139
|
-
"providerId": context?.providerId,
|
|
140
|
-
"permissions": context?.permissions
|
|
141
|
-
]
|
|
142
|
-
]
|
|
143
|
-
) { _ in
|
|
144
|
-
isFavorite.toggle()
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
private func onPressHelpCenter() {
|
|
149
|
-
let context = environment.applicationContext
|
|
150
|
-
let paramMap: [String: Any] = [
|
|
151
|
-
"appId": context?.appId,
|
|
152
|
-
"code": context?.appCode,
|
|
153
|
-
"name": context?.appName,
|
|
154
|
-
"icon": context?.appIcon,
|
|
155
|
-
"description": context?.description
|
|
156
|
-
]
|
|
157
|
-
environment.composeApi?.request(
|
|
158
|
-
funcName: "showHelpCenter",
|
|
159
|
-
params: paramMap
|
|
160
|
-
) { _ in }
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
private func onPressClose() {
|
|
164
|
-
environment.composeApi?.request(
|
|
165
|
-
funcName: "dismissAll",
|
|
166
|
-
params: ""
|
|
167
|
-
) { _ in }
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private func onPressMore() {
|
|
171
|
-
let context = environment.applicationContext
|
|
172
|
-
let params: [String: Any] = [
|
|
173
|
-
"useSystemTools": headerRight?.useSystemTools,
|
|
174
|
-
"tools": headerRight?.tools.map { $0.toMap() } ?? [],
|
|
175
|
-
"context": [
|
|
176
|
-
"appId": context?.appId,
|
|
177
|
-
"code": context?.appCode,
|
|
178
|
-
"name": context?.appName,
|
|
179
|
-
"icon": context?.appIcon,
|
|
180
|
-
"description": context?.description,
|
|
181
|
-
"support": context?.support,
|
|
182
|
-
"toolkitConfig": context?.toolkitConfig,
|
|
183
|
-
"providerId": context?.providerId,
|
|
184
|
-
"permissions": context?.permissions
|
|
185
|
-
]
|
|
186
|
-
]
|
|
187
|
-
environment.composeApi?.request(
|
|
188
|
-
funcName: "showTools",
|
|
189
|
-
params: params
|
|
190
|
-
) { response in
|
|
191
|
-
do {
|
|
192
|
-
if let jsonData = response.data(using: .utf8),
|
|
193
|
-
let json = try JSONSerialization.jsonObject(with: jsonData) as? [String: Any],
|
|
194
|
-
let toolResponse = json["response"] as? String {
|
|
195
|
-
headerRight?.toolCallback?(toolResponse)
|
|
196
|
-
}
|
|
197
|
-
} catch {
|
|
198
|
-
print("Error parsing response:", error)
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Load the current favorite state on appear so the star reflects reality; without this the button
|
|
204
|
-
// always renders "not favorited" until the user taps it. Mirrors the Compose LaunchedEffect.
|
|
205
|
-
private func loadFavoriteState() {
|
|
206
|
-
let context = environment.applicationContext
|
|
207
|
-
environment.composeApi?.request(
|
|
208
|
-
funcName: "isFavoriteApp",
|
|
209
|
-
params: ["code": context?.appCode]
|
|
210
|
-
) { response in
|
|
211
|
-
guard let data = response.data(using: .utf8),
|
|
212
|
-
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
|
|
213
|
-
return
|
|
214
|
-
}
|
|
215
|
-
isFavorite = (json["response"] as? Bool) ?? false
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
private func getNavigationButtonConfig() -> NavigationButtonConfig {
|
|
220
|
-
let totalTools = headerRight?.tools.reduce(0) { $0 + $1.items.count } ?? 0
|
|
221
|
-
var icon = isFavorite ? "pin_star_checked" : "pin_star"
|
|
222
|
-
var onClickHandler: () -> Void = onPressShortcut
|
|
223
|
-
|
|
224
|
-
if totalTools > 1 || headerRight?.useMore == true {
|
|
225
|
-
icon = "navigation_more_icon"
|
|
226
|
-
onClickHandler = onPressMore
|
|
227
|
-
} else if totalTools == 1, let singleTool = headerRight?.tools.first?.items.first {
|
|
228
|
-
icon = singleTool.icon
|
|
229
|
-
onClickHandler = {
|
|
230
|
-
headerRight?.toolCallback?(singleTool.key)
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return NavigationButtonConfig(icon: icon, onPress: onClickHandler)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
var body: some View {
|
|
238
|
-
let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
|
|
239
|
-
let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
|
|
240
|
-
let navButtonConfig = getNavigationButtonConfig()
|
|
241
|
-
let showBadge = headerRight?.tools.contains { group in
|
|
242
|
-
group.items.contains { $0.showBadge }
|
|
243
|
-
} ?? false
|
|
244
|
-
|
|
245
|
-
HStack(alignment: .center, spacing: 0) {
|
|
246
|
-
if headerRight?.useShortcut == true {
|
|
247
|
-
NavigationButton(
|
|
248
|
-
disabled: isLoading,
|
|
249
|
-
icon: navButtonConfig.icon,
|
|
250
|
-
showBadge: showBadge,
|
|
251
|
-
onClick: navButtonConfig.onPress,
|
|
252
|
-
tintColor: tintColor
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
HStack(alignment: .center, spacing: 0) {
|
|
257
|
-
if showsHelpCenter(environment.applicationContext) {
|
|
258
|
-
Icon(source: "help_center", size: 20, color: tintColor ?? Colors.black17)
|
|
259
|
-
.padding(4)
|
|
260
|
-
.onTapGesture {
|
|
261
|
-
onPressHelpCenter()
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
Rectangle()
|
|
265
|
-
.fill(tintColor ?? Colors.black20)
|
|
266
|
-
.frame(width: 0.5, height: 12)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
Icon(source: headerRight?.closeIcon ?? "16_basic_home", size: 20, color: tintColor ?? Colors.black17)
|
|
270
|
-
.padding(4)
|
|
271
|
-
.onTapGesture {
|
|
272
|
-
onPressClose()
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
.frame(width: 65, height: 28)
|
|
276
|
-
.background(backgroundButtonColor)
|
|
277
|
-
.cornerRadius(14)
|
|
278
|
-
.overlay(
|
|
279
|
-
RoundedRectangle(cornerRadius: 14)
|
|
280
|
-
.stroke(borderColor, lineWidth: 0.2)
|
|
281
|
-
)
|
|
282
|
-
.padding(.leading, Spacing.S)
|
|
283
|
-
}
|
|
284
|
-
.onAppear {
|
|
285
|
-
loadFavoriteState()
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
struct NavigationButton: View {
|
|
291
|
-
var disabled: Bool
|
|
292
|
-
var icon: String
|
|
293
|
-
var showBadge: Bool
|
|
294
|
-
var onClick: () -> Void
|
|
295
|
-
var tintColor: Color?
|
|
296
|
-
|
|
297
|
-
var body: some View {
|
|
298
|
-
let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
|
|
299
|
-
let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
|
|
300
|
-
|
|
301
|
-
ZStack {
|
|
302
|
-
Circle()
|
|
303
|
-
.fill(backgroundButtonColor)
|
|
304
|
-
.overlay(
|
|
305
|
-
Circle()
|
|
306
|
-
.stroke(borderColor, lineWidth: 0.2)
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
Icon(source: icon, size: 16, color: tintColor)
|
|
310
|
-
|
|
311
|
-
if showBadge {
|
|
312
|
-
BadgeDot(size: .small)
|
|
313
|
-
.offset(x: -2, y: -2)
|
|
314
|
-
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
.frame(width: 28, height: 28)
|
|
318
|
-
.onTapGesture {
|
|
319
|
-
if !disabled {
|
|
320
|
-
onClick()
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
@@ -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
|
-
}
|