@momo-kits/native-kits 0.0.1-beta.4 → 0.0.2-alpha.1
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 +99 -0
- package/PUBLISH_GUIDE.md +675 -0
- package/README.md +184 -5
- package/ios/Application/ApplicationEnvironment.swift +71 -0
- package/ios/Application/Components.swift +270 -0
- package/ios/Application/ComposeApi.swift +22 -0
- package/ios/Application/FloatingButton.swift +174 -0
- package/ios/Application/HeaderRight.swift +306 -0
- package/ios/Application/LanguageSource.swift +93 -0
- package/ios/Application/Localize.swift +378 -0
- package/ios/Application/LocalizeModifier.swift +30 -0
- package/ios/Application/MaxApi.swift +18 -0
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +104 -0
- package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +215 -0
- package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +65 -0
- package/ios/Application/Navigation/HeaderBackProps.swift +66 -0
- package/ios/Application/Navigation/HeaderTitle.swift +57 -0
- package/ios/Application/Navigation/HeaderUser.swift +209 -0
- package/ios/Application/Navigation/NavigationContainer.swift +213 -0
- package/ios/Application/Navigation/NavigationOptions.swift +109 -0
- package/ios/Application/Navigation/Navigator.swift +453 -0
- package/ios/Application/Navigation/NavigatorManager.swift +22 -0
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +256 -0
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +74 -0
- package/ios/Application/Navigation/Overplay/SnackBar.swift +144 -0
- package/ios/Application/Navigation/Tracking/ScreenTracker.swift +117 -0
- package/ios/Application/Navigation/component/Header.swift +178 -0
- package/ios/Application/Navigation/component/HeaderBackground.swift +83 -0
- package/ios/Application/Navigation/component/HeaderColor.swift +65 -0
- package/ios/Application/Navigation/component/HeaderRightWidthKey.swift +11 -0
- package/ios/Application/Navigation/component/NavigationFooter.swift +90 -0
- package/ios/Application/Navigation/component/NavigationHeaderRight.swift +196 -0
- package/ios/Application/Screen.swift +250 -0
- package/ios/Application/StackScreen.swift +492 -0
- package/ios/Avatar/Avatar.swift +193 -0
- package/ios/Badge/Badge.swift +84 -0
- package/ios/Badge/BadgeDot.swift +31 -0
- package/ios/Badge/BadgeRibbon.swift +319 -0
- package/ios/BaselineView/BaselineView.swift +163 -0
- package/ios/Button/Button.swift +232 -84
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
- package/ios/Carousel/Carousel.swift +196 -0
- package/ios/Checkbox/Checkbox.swift +77 -0
- package/ios/Chip/Chip.swift +120 -0
- package/ios/Collapse/Collapse.swift +192 -0
- package/ios/{Colors+Spacing → Colors+Radius+Spacing}/Colors.swift +42 -37
- package/ios/Colors+Radius+Spacing/Radius.swift +22 -0
- package/ios/{Colors+Spacing → Colors+Radius+Spacing}/Spacing.swift +3 -1
- package/ios/Colors+Radius+Spacing/Theme.swift +295 -0
- package/ios/DateTimePicker/DateTimePicker.swift +212 -0
- package/ios/DateTimePicker/DateTimePickerTypes.swift +55 -0
- package/ios/DateTimePicker/DateTimePickerUtils.swift +167 -0
- package/ios/DateTimePicker/WheelPicker.swift +165 -0
- package/ios/Divider/Divider.swift +16 -0
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +14 -0
- package/ios/Extensions/Color++.swift +32 -0
- package/ios/Icon/Icon.swift +69 -0
- package/ios/IconButton/IconButton.swift +140 -0
- package/ios/Image/Image.swift +87 -0
- package/ios/Information/Information.swift +156 -0
- package/ios/Input/ErrorView.swift +58 -0
- package/ios/Input/Input.swift +461 -77
- package/ios/Input/InputPhoneNumber.swift +192 -0
- package/ios/Input/InputSearch.swift +301 -0
- package/ios/Input/InputTextArea.swift +318 -0
- package/ios/InputDropDown/InputDropDown.swift +201 -0
- package/ios/InputMoney/InputMoney.swift +405 -0
- package/ios/InputOTP/InputOTP.swift +211 -0
- package/ios/Layout/GridContext.swift +30 -0
- package/ios/Layout/Item.swift +42 -0
- package/ios/Layout/Section.swift +134 -0
- package/ios/Loader/Loader.swift +113 -0
- package/ios/Lottie/LottieView.swift +86 -0
- package/ios/MoMoUIKits.podspec +5 -0
- package/ios/OTPKeyboard/KeyboardButton.swift +13 -5
- package/ios/OTPKeyboard/OTPKeyboard.swift +1 -1
- package/ios/Pagination/PaginationDot.swift +61 -0
- package/ios/Pagination/PaginationNumber.swift +35 -0
- package/ios/Pagination/PaginationScroll.swift +101 -0
- package/ios/Pagination/PaginationWhiteDot.swift +37 -0
- package/ios/Popup/PopupDisplay.swift +279 -0
- package/ios/Popup/PopupInput.swift +92 -0
- package/ios/Popup/PopupNotify.swift +219 -0
- package/ios/Popup/PopupPromotion.swift +74 -0
- package/ios/PopupView/FullscreenPopup.swift +251 -0
- package/ios/{Popup → PopupView}/Modifiers.swift +6 -20
- package/ios/{Popup → PopupView}/PopupView.swift +38 -146
- package/ios/PopupView/Utils++.swift +281 -0
- package/ios/ProgressInfo/ProgressInfo.swift +297 -0
- package/ios/Radio/Radio.swift +69 -0
- package/ios/Rating/Rating.swift +83 -0
- package/{example/ios/Example/Preview Content/Preview Assets.xcassets/Contents.json → ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json} +5 -0
- package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Text.colorset/Contents.json +3 -3
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +9 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +38 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +110 -0
- package/ios/Skeleton/Skeleton.swift +99 -0
- package/ios/Slider/Slider.swift +237 -0
- package/ios/StatusBarTap/StatusBarTap.h +13 -0
- package/ios/StatusBarTap/StatusBarTap.m +75 -0
- package/ios/Stepper/Stepper.swift +221 -0
- package/ios/Steps/Steps.swift +467 -0
- package/ios/SuggestAction/SuggestAction.swift +100 -0
- package/ios/Swipeable/SwipeCell.swift +226 -31
- package/ios/Swipeable/SwipeCellModel.swift +21 -0
- package/ios/Switch/Switch.swift +69 -0
- package/ios/TabView/TabView.swift +534 -0
- package/ios/Tag/Tag.swift +99 -0
- package/ios/Template/Logo/Logo.swift +75 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +123 -0
- package/ios/Title/Title.swift +270 -0
- package/ios/Tooltip/Tooltip.swift +486 -0
- package/ios/Typography/FontScale.swift +103 -0
- package/ios/Typography/FontScaleStore.swift +58 -0
- package/ios/Typography/KitDesignSystem.swift +17 -0
- package/ios/Typography/Text.swift +262 -0
- package/ios/Typography/Typography.swift +80 -23
- package/ios/Uploader/Uploader.swift +174 -0
- package/ios/native-kits.podspec +73 -13
- package/ios-demo/MoMoUIKitsDemo.podspec +20 -0
- package/ios-demo/Resources/dot_loading.json +558 -0
- package/ios-demo/Resources/icon.json +4052 -0
- package/ios-demo/Resources/lottie_circle_loader.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +48 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +25 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +26 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +19 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +33 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +48 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +21 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +17 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +28 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +31 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +24 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +110 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +107 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +75 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +117 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +89 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +108 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +96 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +60 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +76 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +102 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +107 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +100 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DemoScreen.swift +420 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +56 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +49 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +276 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +93 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconDemo.swift +81 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +65 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +96 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +117 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +94 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +94 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +88 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +85 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +87 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +73 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +235 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +241 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +68 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PlaygroundData.swift +76 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +175 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +95 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +67 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +101 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +64 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +68 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SectionDemo.swift +83 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +61 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +90 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +82 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +93 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +90 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +107 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +58 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +86 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +181 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +104 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +118 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +87 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +85 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +53 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +15 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +73 -0
- package/package.json +6 -6
- package/publish.sh +554 -20
- package/scripts/gen-ios-color.mjs +136 -0
- package/CODE_OF_CONDUCT.md +0 -133
- package/CONTRIBUTING.md +0 -114
- package/LICENSE +0 -20
- package/android/build.gradle +0 -82
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifest.xml +0 -4
- package/android/src/main/java/com/momoplatform/nativekits/NativeKitsPackage.kt +0 -17
- package/android/src/main/java/com/momoplatform/nativekits/NativeKitsViewManager.kt +0 -20
- package/example/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -63
- package/example/ios/Example/ComponentDetail.swift +0 -35
- package/example/ios/Example/ComponentItem.swift +0 -24
- package/example/ios/Example/ComponentModel.swift +0 -33
- package/example/ios/Example/ContentView.swift +0 -53
- package/example/ios/Example/Example.entitlements +0 -10
- package/example/ios/Example/Foundation/ButtonDemo.swift +0 -80
- package/example/ios/Example/Foundation/Popup/ActionSheets.swift +0 -136
- package/example/ios/Example/Foundation/Popup/Floats.swift +0 -127
- package/example/ios/Example/Foundation/Popup/Popups.swift +0 -101
- package/example/ios/Example/Foundation/PopupDemo.swift +0 -366
- package/example/ios/Example/Foundation/TextInputDemo.swift +0 -31
- package/example/ios/Example/Foundation/TypographyDemo.swift +0 -53
- package/example/ios/Example/Foundation.swift +0 -26
- package/example/ios/Example/Info.plist +0 -18
- package/example/ios/Example/Library/SwipeableDemo.swift +0 -105
- package/example/ios/Example/Library.swift +0 -26
- package/example/ios/Example/Main.swift +0 -11
- package/example/ios/Example/Overview.swift +0 -20
- package/example/ios/Example/Resource/SFProText-Black.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Bold.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Heavy.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Light.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Medium.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Regular.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Semibold.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Thin.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Ultralight.ttf +0 -0
- package/example/ios/Example/Resource/foundation.json +0 -33
- package/example/ios/Example/Resource/library.json +0 -8
- package/example/ios/Example/Utils.swift +0 -30
- package/example/ios/Example/ViewModifier/DarkViewModifier.swift +0 -22
- package/example/ios/Example.xcodeproj/project.pbxproj +0 -570
- package/example/ios/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/example/ios/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/Example.xcodeproj/project.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/example/ios/Example.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/example/ios/Podfile +0 -6
- package/example/ios/Podfile.lock +0 -16
- package/example/ios/Pods/Local Podspecs/MoMoUIKits.podspec.json +0 -29
- package/example/ios/Pods/Manifest.lock +0 -16
- package/example/ios/Pods/Pods.xcodeproj/project.pbxproj +0 -661
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -25
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.debug.xcconfig +0 -12
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.release.xcconfig +0 -12
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.markdown +0 -3
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.plist +0 -29
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig +0 -14
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig +0 -14
- package/ios/Colors+Spacing/Radius.swift +0 -11
- package/ios/Popup/Utils++.swift +0 -163
- package/ios/Theme.md +0 -18
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Background.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Border.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Card.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Error.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Primary.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/PrimaryDark.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/PrimaryLight.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Secondary.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Success.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/TextSecondary.colorset/Contents.json +0 -0
- /package/{example/ios/Example/Assets.xcassets → ios/Resources/MoMoUIKitsColors.xcassets}/Warning.colorset/Contents.json +0 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Localize.swift
|
|
3
|
+
// MoMoUIKits
|
|
4
|
+
//
|
|
5
|
+
// SwiftUI mirror of Compose's `application/Localize.kt`, itself a port of
|
|
6
|
+
// momo-kits React Native's `Application/Localize.ts`. Holds the merged
|
|
7
|
+
// dictionary (kit defaults + host overrides) and the active language,
|
|
8
|
+
// switched at runtime via `changeLanguage`. `Localize` is an `ObservableObject`
|
|
9
|
+
// so a language switch republishes to consumers of `translate`/`translateData`,
|
|
10
|
+
// mirroring Compose's snapshot-state-backed `language`.
|
|
11
|
+
//
|
|
12
|
+
|
|
13
|
+
import Foundation
|
|
14
|
+
import SwiftUI
|
|
15
|
+
|
|
16
|
+
/// Translation dictionary keyed by language; both `vi` and `en` are required.
|
|
17
|
+
public struct LocalizationObject {
|
|
18
|
+
public var vi: [String: String]
|
|
19
|
+
public var en: [String: String]
|
|
20
|
+
|
|
21
|
+
public init(vi: [String: String] = [:], en: [String: String] = [:]) {
|
|
22
|
+
self.vi = vi
|
|
23
|
+
self.en = en
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public final class Localize: ObservableObject {
|
|
28
|
+
public static let VI = "vi"
|
|
29
|
+
public static let EN = "en"
|
|
30
|
+
|
|
31
|
+
// AI-GENERATED START: follow the host app language and publish dictionary changes
|
|
32
|
+
/// App-wide instance bound to the host language; the environment default uses it too,
|
|
33
|
+
/// so every screen agrees on one language.
|
|
34
|
+
public static let shared = Localize()
|
|
35
|
+
// AI-GENERATED END: follow the host app language and publish dictionary changes
|
|
36
|
+
|
|
37
|
+
private var assets: LocalizationObject
|
|
38
|
+
@Published public private(set) var currentLanguage: String = Localize.VI
|
|
39
|
+
|
|
40
|
+
// AI-GENERATED START: follow the host app language and publish dictionary changes
|
|
41
|
+
/// Bumped by `addTranslations` — `assets` is not published, so without this the dictionary
|
|
42
|
+
/// can change without any consumer re-rendering.
|
|
43
|
+
@Published public private(set) var revision: Int = 0
|
|
44
|
+
|
|
45
|
+
private let languageSource: LanguageSource?
|
|
46
|
+
|
|
47
|
+
/// `NavigationContainer` uses this to skip its legacy one-shot `MaxApi` pull.
|
|
48
|
+
var observesAppLanguage: Bool { languageSource != nil }
|
|
49
|
+
|
|
50
|
+
/// Pass `languageSource: nil` to opt out and keep the old "starts at vi" behavior.
|
|
51
|
+
public init(
|
|
52
|
+
_ translations: LocalizationObject = LocalizationObject(),
|
|
53
|
+
languageSource: LanguageSource? = UserDefaultsLanguageSource()
|
|
54
|
+
) {
|
|
55
|
+
self.assets = Localize.merge(base: Localize.defaultLanguage, override: translations)
|
|
56
|
+
self.languageSource = languageSource
|
|
57
|
+
guard let languageSource else { return }
|
|
58
|
+
// Seed synchronously so the first frame is already correct (no vi -> en flash).
|
|
59
|
+
currentLanguage = languageSource.currentLanguage
|
|
60
|
+
languageSource.startObserving { [weak self] language in self?.apply(language) }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
deinit {
|
|
64
|
+
languageSource?.stopObserving()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// Host values are sometimes legacy JSON-quoted (`"\"vi\""`); anything that is not `en` is `vi`.
|
|
68
|
+
public static func normalize(_ raw: String?) -> String {
|
|
69
|
+
let cleaned = (raw ?? "")
|
|
70
|
+
.replacingOccurrences(of: "\"", with: "")
|
|
71
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
72
|
+
.lowercased()
|
|
73
|
+
return cleaned == Localize.EN ? Localize.EN : Localize.VI
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private func apply(_ language: String) {
|
|
77
|
+
// KVO and didChangeNotification both fire for one write; publish once, on main.
|
|
78
|
+
onMain {
|
|
79
|
+
guard self.currentLanguage != language else { return }
|
|
80
|
+
self.currentLanguage = language
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// Synchronous when already on main — an async hop would defer the switch by a frame.
|
|
85
|
+
private func onMain(_ work: @escaping () -> Void) {
|
|
86
|
+
if Thread.isMainThread { work() } else { DispatchQueue.main.async(execute: work) }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// A local override: the next host language change supersedes it.
|
|
90
|
+
public func changeLanguage(_ language: String?) {
|
|
91
|
+
apply(Localize.normalize(language))
|
|
92
|
+
}
|
|
93
|
+
// AI-GENERATED END: follow the host app language and publish dictionary changes
|
|
94
|
+
|
|
95
|
+
public func translate(_ key: String) -> String {
|
|
96
|
+
let dictionary = currentLanguage == Localize.EN ? assets.en : assets.vi
|
|
97
|
+
if let value = dictionary[key], !value.isEmpty { return value }
|
|
98
|
+
return key
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public func translateData(_ data: [String: String]) -> String {
|
|
102
|
+
if let value = data[currentLanguage] { return value }
|
|
103
|
+
let body = data.map { "\"\($0.key)\":\"\($0.value)\"" }.joined(separator: ",")
|
|
104
|
+
return "{\(body)}"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public func translateData(vi: String, en: String) -> String {
|
|
108
|
+
currentLanguage == Localize.EN ? en : vi
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// Existing keys win (mirrors Compose: `merge(translations, assets)`).
|
|
112
|
+
public func addTranslations(_ translations: LocalizationObject) {
|
|
113
|
+
assets = Localize.merge(base: translations, override: assets)
|
|
114
|
+
// AI-GENERATED START: publish dictionary changes so consumers re-render
|
|
115
|
+
onMain { self.revision &+= 1 }
|
|
116
|
+
// AI-GENERATED END: publish dictionary changes so consumers re-render
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private static func merge(base: LocalizationObject, override: LocalizationObject) -> LocalizationObject {
|
|
120
|
+
LocalizationObject(
|
|
121
|
+
vi: base.vi.merging(override.vi) { _, new in new },
|
|
122
|
+
en: base.en.merging(override.en) { _, new in new }
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private static let defaultLanguage = LocalizationObject(
|
|
127
|
+
vi: [
|
|
128
|
+
"errorCode": "Mã lỗi: ",
|
|
129
|
+
"seeMore": "Xem thêm",
|
|
130
|
+
"cancel": "Huỷ",
|
|
131
|
+
"done": "Xong",
|
|
132
|
+
"confirm": "Xác nhận",
|
|
133
|
+
"month": "tháng",
|
|
134
|
+
"day": "ngày",
|
|
135
|
+
"choose": "Chọn",
|
|
136
|
+
"sent": "Đã gửi",
|
|
137
|
+
"received": "Đã tiếp nhận",
|
|
138
|
+
"processing": "Đang xử lý",
|
|
139
|
+
"processed": "Đã xử lý",
|
|
140
|
+
"addImg": "Thêm hình",
|
|
141
|
+
"chooseBtn": "Chọn button",
|
|
142
|
+
"imgEg": "Hình ảnh tham khảo",
|
|
143
|
+
"filter": "Sắp xếp",
|
|
144
|
+
"shipping": "Đang giao hàng",
|
|
145
|
+
"men": "Nam",
|
|
146
|
+
"women": "Nữ",
|
|
147
|
+
"more": "Khác",
|
|
148
|
+
"expDate": "Ngày hết hạn",
|
|
149
|
+
"exp": "HSD",
|
|
150
|
+
"inActive": "Chưa kích hoạt",
|
|
151
|
+
"voucherRemindHour": "Hết hạn sau {hours} giờ",
|
|
152
|
+
"voucherRemindMinute": "Hết hạn sau {minutes} phút",
|
|
153
|
+
"voucherRemindSecond": "Hết hạn sau {seconds} giây",
|
|
154
|
+
"voucherRemindDay": "Hết hạn sau {days} ngày",
|
|
155
|
+
"chooseRoundtrip": "Chọn vé khứ hồi",
|
|
156
|
+
"depart": "Ngày đi",
|
|
157
|
+
"return": "Ngày về",
|
|
158
|
+
"departing": "Đi",
|
|
159
|
+
"returning": "Về",
|
|
160
|
+
"jan": "Tháng 1",
|
|
161
|
+
"feb": "Tháng 2",
|
|
162
|
+
"mar": "Tháng 3",
|
|
163
|
+
"apr": "Tháng 4",
|
|
164
|
+
"may": "Tháng 5",
|
|
165
|
+
"jun": "Tháng 6",
|
|
166
|
+
"jul": "Tháng 7",
|
|
167
|
+
"aug": "Tháng 8",
|
|
168
|
+
"sep": "Tháng 9",
|
|
169
|
+
"oct": "Tháng 10",
|
|
170
|
+
"nov": "Tháng 11",
|
|
171
|
+
"dec": "Tháng 12",
|
|
172
|
+
"mon": "T2",
|
|
173
|
+
"tue": "T3",
|
|
174
|
+
"wed": "T4",
|
|
175
|
+
"thu": "T5",
|
|
176
|
+
"fri": "T6",
|
|
177
|
+
"sat": "T7",
|
|
178
|
+
"sun": "CN",
|
|
179
|
+
"showLunar": "Hiển thị lịch âm",
|
|
180
|
+
"newYear": "Tết Dương lịch",
|
|
181
|
+
"valentine": "Ngày Lễ Tình nhân",
|
|
182
|
+
"womenDay": "Ngày Quốc tế Phụ nữ",
|
|
183
|
+
"liberationDay": "Ngày giải phóng Miền Nam thống nhất đất nước",
|
|
184
|
+
"laborDay": "Ngày Quốc tế Lao động",
|
|
185
|
+
"childrenDay": "Ngày Quốc tế Thiếu nhi",
|
|
186
|
+
"nationalDay": "Quốc khánh nước CHXHCN Việt Nam",
|
|
187
|
+
"womenDayVN": "Ngày Phụ nữ Việt Nam",
|
|
188
|
+
"teacherDay": "Ngày Nhà giáo Việt Nam",
|
|
189
|
+
"christmasEve": "Ngày Lễ Giáng Sinh",
|
|
190
|
+
"christmas": "Ngày Lễ Giáng Sinh",
|
|
191
|
+
"lunarNewYear": "Tết Nguyên Đán",
|
|
192
|
+
"hungKingDay": "Giỗ Tổ Hùng Vương",
|
|
193
|
+
"balance": "Số dư trong ví",
|
|
194
|
+
"chooseDate": "Chọn ngày tháng năm",
|
|
195
|
+
"year": "năm",
|
|
196
|
+
"hour": "giờ",
|
|
197
|
+
"minute": "phút",
|
|
198
|
+
"from": "Từ",
|
|
199
|
+
"to": "Đến",
|
|
200
|
+
"connected": "Đã kết nối",
|
|
201
|
+
"disconnected": "Mất kết nối",
|
|
202
|
+
"hide": "Ẩn",
|
|
203
|
+
"viewAllTitle": "Xem tất cả",
|
|
204
|
+
"headerTitle": "Lịch sử thanh toán",
|
|
205
|
+
"SHORTEN": "THU GỌN",
|
|
206
|
+
"viewMoreBank": "XEM THÊM (${otherItemCount} ngân hàng)",
|
|
207
|
+
"transaction_success": "Thành công",
|
|
208
|
+
"transaction_fail": "Thất bại",
|
|
209
|
+
"transaction_processing": "Đang xử lý",
|
|
210
|
+
"viewMore": "Xem thêm",
|
|
211
|
+
"shorten": "Thu gọn",
|
|
212
|
+
"Payment": "Thanh toán ${serviceName}",
|
|
213
|
+
"currencyUnit": "đ",
|
|
214
|
+
"Month": "Tháng",
|
|
215
|
+
"save": "Lưu",
|
|
216
|
+
"favoriteIn": "Thêm dịch vụ yêu thích",
|
|
217
|
+
"favoriteOut": "Xóa dịch vụ yêu thích",
|
|
218
|
+
"deviceIn": "Thêm vào thiết bị",
|
|
219
|
+
"setting": "Cài đặt",
|
|
220
|
+
"transaction": "Lịch sử giao dịch",
|
|
221
|
+
"share": "Chia sẽ dịch vụ",
|
|
222
|
+
"information": "Thông tin chung",
|
|
223
|
+
"tutorial": "Hướng dẫn sử dụng",
|
|
224
|
+
"question": "Câu hỏi thường gặp",
|
|
225
|
+
"support": "Trung tâm hỗ trợ",
|
|
226
|
+
"skip": "Bỏ qua",
|
|
227
|
+
"enterPhoneNumber": "Vui lòng nhập số điện thoại",
|
|
228
|
+
"invalidPhoneNumber": "Số điện thoại không đúng",
|
|
229
|
+
],
|
|
230
|
+
en: [
|
|
231
|
+
"seeMore": "See more",
|
|
232
|
+
"cancel": "Cancel",
|
|
233
|
+
"done": "Done",
|
|
234
|
+
"confirm": "Confirm",
|
|
235
|
+
"month": "month",
|
|
236
|
+
"day": "day",
|
|
237
|
+
"choose": "Choose",
|
|
238
|
+
"sent": "Sent",
|
|
239
|
+
"received": "Received",
|
|
240
|
+
"processing": "Processing",
|
|
241
|
+
"processed": "Done",
|
|
242
|
+
"addImg": "Add image",
|
|
243
|
+
"chooseBtn": "Choose button",
|
|
244
|
+
"imgEg": "Example images",
|
|
245
|
+
"filter": "Filter",
|
|
246
|
+
"shipping": "Shipping",
|
|
247
|
+
"men": "Men",
|
|
248
|
+
"women": "Women",
|
|
249
|
+
"more": "More",
|
|
250
|
+
"expDate": "Expiration date",
|
|
251
|
+
"exp": "EXP",
|
|
252
|
+
"inActive": "Not Activated",
|
|
253
|
+
"voucherRemindHour": "Revoke after {hours} hours",
|
|
254
|
+
"voucherRemindMinute": "Revoke after {minutes} minutes",
|
|
255
|
+
"voucherRemindSecond": "Revoke after {seconds} seconds",
|
|
256
|
+
"voucherRemindDay": "Revoke after {days} days",
|
|
257
|
+
"chooseRoundtrip": "Choose roundtrip ticket",
|
|
258
|
+
"depart": "Departing",
|
|
259
|
+
"return": "Returning",
|
|
260
|
+
"departing": "De",
|
|
261
|
+
"returning": "Re",
|
|
262
|
+
"jan": "January",
|
|
263
|
+
"feb": "February",
|
|
264
|
+
"mar": "March",
|
|
265
|
+
"apr": "April",
|
|
266
|
+
"may": "May",
|
|
267
|
+
"jun": "June",
|
|
268
|
+
"jul": "July",
|
|
269
|
+
"aug": "August",
|
|
270
|
+
"sep": "September",
|
|
271
|
+
"oct": "October",
|
|
272
|
+
"nov": "November",
|
|
273
|
+
"dec": "December",
|
|
274
|
+
"mon": "Mon",
|
|
275
|
+
"tue": "Tue",
|
|
276
|
+
"wed": "Wed",
|
|
277
|
+
"thu": "Thu",
|
|
278
|
+
"fri": "Fri",
|
|
279
|
+
"sat": "Sat",
|
|
280
|
+
"sun": "Sun",
|
|
281
|
+
"showLunar": "Show Lunar Calendar",
|
|
282
|
+
"newYear": "New Year's Day",
|
|
283
|
+
"valentine": "Valentine's Day",
|
|
284
|
+
"womenDay": "International Women's Day",
|
|
285
|
+
"liberationDay": "Liberation Day",
|
|
286
|
+
"laborDay": "Internation Labor's Day",
|
|
287
|
+
"childrenDay": "International Labor's Day",
|
|
288
|
+
"nationalDay": "National Day",
|
|
289
|
+
"womenDayVN": "Vietnamese Women's Day",
|
|
290
|
+
"teacherDay": "Teacher's Day",
|
|
291
|
+
"christmasEve": "Christmas Eve",
|
|
292
|
+
"christmas": "Christmas Day",
|
|
293
|
+
"lunarNewYear": "Lunar New Year",
|
|
294
|
+
"hungKingDay": "Hung Kings' Festival",
|
|
295
|
+
"balance": "Wallet Balance",
|
|
296
|
+
"chooseDate": "Choose date",
|
|
297
|
+
"year": "year",
|
|
298
|
+
"hour": "hour",
|
|
299
|
+
"minute": "minute",
|
|
300
|
+
"from": "From",
|
|
301
|
+
"to": "To",
|
|
302
|
+
"connected": "Connected",
|
|
303
|
+
"disconnected": "Disconnected",
|
|
304
|
+
"hide": "Hide",
|
|
305
|
+
"viewAllTitle": "View all",
|
|
306
|
+
"headerTitle": "Transaction history",
|
|
307
|
+
"SHORTEN": "SHORTEN",
|
|
308
|
+
"viewMoreBank": "VIEW MORE (${otherItemCount} banks)",
|
|
309
|
+
"transaction_success": "Success",
|
|
310
|
+
"transaction_fail": "Fail",
|
|
311
|
+
"transaction_processing": "Processing",
|
|
312
|
+
"viewMore": "View more",
|
|
313
|
+
"shorten": "Shorten",
|
|
314
|
+
"Payment": "${serviceName} payment",
|
|
315
|
+
"currencyUnit": "VND",
|
|
316
|
+
"Month": "Month",
|
|
317
|
+
"save": "Save",
|
|
318
|
+
"favoriteIn": "Add to favorite services",
|
|
319
|
+
"favoriteOut": "Remove to favorite services",
|
|
320
|
+
"deviceIn": "Add to device",
|
|
321
|
+
"setting": "Settings",
|
|
322
|
+
"transaction": "Transaction History",
|
|
323
|
+
"share": "Share",
|
|
324
|
+
"information": "Information",
|
|
325
|
+
"tutorial": "Instruction",
|
|
326
|
+
"question": "FAQ",
|
|
327
|
+
"support": "Support center",
|
|
328
|
+
"errorCode": "Error code: ",
|
|
329
|
+
"skip": "Skip",
|
|
330
|
+
"enterPhoneNumber": "Please enter your phone number",
|
|
331
|
+
"invalidPhoneNumber": "Invalid phone number",
|
|
332
|
+
]
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/// Snapshots `currentLanguage` alongside the instance so SwiftUI sees an environment
|
|
337
|
+
/// *change* on `changeLanguage`: the `Localize` reference alone never changes, and
|
|
338
|
+
/// `@Environment` does not subscribe to `@Published` the way `@EnvironmentObject` does.
|
|
339
|
+
private struct LocalizeBox: Equatable {
|
|
340
|
+
let localize: Localize
|
|
341
|
+
let language: String
|
|
342
|
+
// AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
|
|
343
|
+
let revision: Int
|
|
344
|
+
// AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
|
|
345
|
+
|
|
346
|
+
init(_ localize: Localize) {
|
|
347
|
+
self.localize = localize
|
|
348
|
+
self.language = localize.currentLanguage
|
|
349
|
+
// AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
|
|
350
|
+
self.revision = localize.revision
|
|
351
|
+
// AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
static func == (lhs: LocalizeBox, rhs: LocalizeBox) -> Bool {
|
|
355
|
+
// AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
|
|
356
|
+
lhs.localize === rhs.localize && lhs.language == rhs.language && lhs.revision == rhs.revision
|
|
357
|
+
// AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
private struct LocalizeKey: EnvironmentKey {
|
|
362
|
+
/// A default-constructed `Localize` already carries the full kit dictionary, so a
|
|
363
|
+
/// consumer that never injects one renders untranslated-but-correct text instead of
|
|
364
|
+
/// trapping the way `@EnvironmentObject` does.
|
|
365
|
+
// AI-GENERATED START: default to the app-language-observing shared instance
|
|
366
|
+
/// `defaultValue` is a `static let`, so this box is never rebuilt: without a provider the
|
|
367
|
+
/// language is right on first render but does not live-update. Wrap the root in
|
|
368
|
+
/// `.momoLocalize()` (or use `NavigationContainer`) to get updates.
|
|
369
|
+
static let defaultValue = LocalizeBox(Localize.shared)
|
|
370
|
+
// AI-GENERATED END: default to the app-language-observing shared instance
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
public extension EnvironmentValues {
|
|
374
|
+
var localize: Localize {
|
|
375
|
+
get { self[LocalizeKey.self].localize }
|
|
376
|
+
set { self[LocalizeKey.self] = LocalizeBox(newValue) }
|
|
377
|
+
}
|
|
378
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// File: ios/Application/LocalizeModifier.swift
|
|
2
|
+
// Created At: 2026-07-29 10:00:00 +07:00
|
|
3
|
+
// Created By: AI
|
|
4
|
+
// AI Agent: Claude Code
|
|
5
|
+
// Model: claude-opus-5[1m]
|
|
6
|
+
|
|
7
|
+
// AI-GENERATED START: inject a language-observing Localize into any SwiftUI subtree
|
|
8
|
+
import SwiftUI
|
|
9
|
+
|
|
10
|
+
public extension View {
|
|
11
|
+
/// Injects an app-language-observing `Localize` and re-renders this subtree on change.
|
|
12
|
+
/// Use at every `UIHostingController` root that is not inside a `NavigationContainer`.
|
|
13
|
+
func momoLocalize(_ localize: Localize = .shared) -> some View {
|
|
14
|
+
modifier(MomoLocalizeModifier(localize: localize))
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// `@ObservedObject` is load-bearing: `@Environment(\.localize)` only invalidates when the boxed
|
|
19
|
+
/// value changes, which requires *this* body to re-run on every publish. A plain helper that just
|
|
20
|
+
/// set `\.localize` would inject a snapshot that never updates.
|
|
21
|
+
private struct MomoLocalizeModifier: ViewModifier {
|
|
22
|
+
@ObservedObject var localize: Localize
|
|
23
|
+
|
|
24
|
+
func body(content: Content) -> some View {
|
|
25
|
+
content
|
|
26
|
+
.environmentObject(localize)
|
|
27
|
+
.environment(\.localize, localize)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// AI-GENERATED END: inject a language-observing Localize into any SwiftUI subtree
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MaxApi.swift
|
|
3
|
+
// MoMoUIKits
|
|
4
|
+
//
|
|
5
|
+
// Swift mirror of the host-app bridge exposed on Kotlin as `vn.momo.maxapi.IMaxApi`
|
|
6
|
+
// (`LocalMaxApi`). `IMaxApi` itself is an external compiled dependency with no
|
|
7
|
+
// source in this repo, so this protocol intentionally exposes only the methods
|
|
8
|
+
// this kit's Kotlin source actually calls (`track`, `dismiss`, `getLanguage`) —
|
|
9
|
+
// not a full guess at IMaxApi's real surface.
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
import Foundation
|
|
13
|
+
|
|
14
|
+
public protocol MaxApi {
|
|
15
|
+
func track(eventName: String, params: [String: Any?])
|
|
16
|
+
func dismiss(completion: (() -> Void)?)
|
|
17
|
+
func getLanguage(callback: @escaping ([String: Any?]?) -> Void)
|
|
18
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//
|
|
2
|
+
// BottomTab.swift
|
|
3
|
+
// MoMoUIKits
|
|
4
|
+
//
|
|
5
|
+
// SwiftUI mirror of Compose's `BottomTab` (navigation/bottomtab/BottomTab.kt).
|
|
6
|
+
// Hosts a set of tabbed screens, each wrapped in `StackScreen` chrome built
|
|
7
|
+
// from that tab's `NavigationOptions`, with a `BottomTabBar` pinned to the
|
|
8
|
+
// bottom. Switching tabs cross-fades + scales the content (parity with Compose).
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
import SwiftUI
|
|
12
|
+
|
|
13
|
+
@available(iOS 16.0, *)
|
|
14
|
+
public struct BottomTab: View {
|
|
15
|
+
private let items: [BottomTabItem]
|
|
16
|
+
private let floatingButton: BottomTabFloatingButton?
|
|
17
|
+
|
|
18
|
+
@EnvironmentObject private var navigator: Navigator
|
|
19
|
+
@State private var selectedIndex: Int = 0
|
|
20
|
+
|
|
21
|
+
public init(items: [BottomTabItem], floatingButton: BottomTabFloatingButton? = nil) {
|
|
22
|
+
self.items = items
|
|
23
|
+
self.floatingButton = floatingButton
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private var bottomInset: CGFloat { safeAreaBottomInset() }
|
|
27
|
+
private var reservedBottom: CGFloat { BOTTOM_TAB_BAR_HEIGHT + bottomInset + Spacing.S }
|
|
28
|
+
|
|
29
|
+
public var body: some View {
|
|
30
|
+
ZStack(alignment: .bottom) {
|
|
31
|
+
// Tab content area, inset above the bar.
|
|
32
|
+
ZStack {
|
|
33
|
+
ForEach(items.indices, id: \.self) { index in
|
|
34
|
+
if index == selectedIndex {
|
|
35
|
+
tabScreen(for: index)
|
|
36
|
+
.transition(.scale(scale: 0.97).combined(with: .opacity))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
.padding(.bottom, reservedBottom)
|
|
41
|
+
.animation(.easeInOut(duration: 0.2), value: selectedIndex)
|
|
42
|
+
|
|
43
|
+
// Tab bar + home-indicator filler.
|
|
44
|
+
VStack(spacing: 0) {
|
|
45
|
+
BottomTabBar(
|
|
46
|
+
items: items,
|
|
47
|
+
floatingButton: floatingButton,
|
|
48
|
+
selectedIndex: selectedIndex,
|
|
49
|
+
onTabSelected: { index in
|
|
50
|
+
if index != selectedIndex { selectedIndex = index }
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
Colors.black01
|
|
54
|
+
.frame(height: bottomInset + Spacing.S)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
58
|
+
.ignoresSafeArea(edges: .bottom)
|
|
59
|
+
.preference(key: IsBottomTabRootKey.self, value: true)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@ViewBuilder
|
|
63
|
+
private func tabScreen(for index: Int) -> some View {
|
|
64
|
+
let item = items[index]
|
|
65
|
+
let options = item.options ?? NavigationOptions()
|
|
66
|
+
StackScreen(
|
|
67
|
+
backgroundColor: options.backgroundColor,
|
|
68
|
+
headerTransparent: options.headerTransparent,
|
|
69
|
+
fullScreenContent: options.fullScreenContent,
|
|
70
|
+
tintColor: options.tintColor ?? Colors.black17,
|
|
71
|
+
isBack: !options.hiddenBack,
|
|
72
|
+
headerType: options.headerType,
|
|
73
|
+
useAnimated: options.useAnimated,
|
|
74
|
+
title: options.title,
|
|
75
|
+
headerTitle: options.headerTitle,
|
|
76
|
+
titlePosition: options.titlePosition,
|
|
77
|
+
// Tab back: non-first tab returns to the first tab, first tab
|
|
78
|
+
// delegates to the navigator (mirrors Compose's onBackHandler).
|
|
79
|
+
goBack: options.hiddenBack ? nil : {
|
|
80
|
+
if index != 0 { selectedIndex = 0 } else { navigator.onBackSafe() }
|
|
81
|
+
},
|
|
82
|
+
scrollable: options.scrollable,
|
|
83
|
+
scrollToTopCallback: options.scrollToTopCallback,
|
|
84
|
+
useAvoidKeyboard: options.useAvoidKeyboard,
|
|
85
|
+
keyboardShouldPersistTaps: options.keyboardShouldPersistTaps,
|
|
86
|
+
footer: options.footer,
|
|
87
|
+
headerRight: options.resolvedHeaderRight,
|
|
88
|
+
animatedHeader: options.animatedHeader,
|
|
89
|
+
layoutOffset: options.layoutOffset,
|
|
90
|
+
inputSearchProps: options.inputSearchProps,
|
|
91
|
+
fabProps: options.fabProps,
|
|
92
|
+
content: { item.screen() }
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// Bottom safe-area inset (home indicator).
|
|
98
|
+
@available(iOS 16.0, *)
|
|
99
|
+
private func safeAreaBottomInset() -> CGFloat {
|
|
100
|
+
let bottomInset = UIApplication.shared.connectedScenes
|
|
101
|
+
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
102
|
+
.first ?? 0
|
|
103
|
+
return min(bottomInset, 21)
|
|
104
|
+
}
|