@momo-kits/native-kits 0.162.2-sp.1 → 0.162.2-sp.10-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/settings.local.json +15 -1
- package/CLAUDE.md +78 -0
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +190 -0
- package/compose/build.gradle.kts.backup +190 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -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 +123 -0
- package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -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 +106 -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 +294 -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 +826 -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 +82 -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 +356 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +113 -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 +543 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -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 +112 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +477 -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 +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +240 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +216 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +259 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +182 -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 +328 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +97 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +310 -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 +323 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +217 -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 +199 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +470 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +131 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +203 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +175 -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 +234 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -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 +276 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -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 +253 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +129 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +100 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +360 -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 +581 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +156 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +225 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -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 +320 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +81 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +309 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +34 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +360 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +128 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +70 -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 +58 -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 +105 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -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 +184 -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 +15 -2
- package/ios/Application/Components.swift +16 -0
- package/ios/Application/HeaderRight.swift +79 -45
- package/ios/Application/Localize.swift +277 -0
- package/ios/Application/MaxApi.swift +18 -0
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +3 -1
- package/ios/Application/Navigation/NavigationContainer.swift +53 -4
- package/ios/Application/Navigation/Navigator.swift +54 -29
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +98 -18
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +6 -0
- package/ios/Application/Navigation/Tracking/ScreenTracker.swift +117 -0
- package/ios/Application/Screen.swift +2 -1
- package/ios/Application/StackScreen.swift +55 -3
- package/ios/Badge/BadgeRibbon.swift +80 -0
- package/ios/Button/Button.swift +67 -11
- package/ios/Carousel/Carousel.swift +16 -1
- package/ios/Checkbox/Checkbox.swift +14 -20
- package/ios/Chip/Chip.swift +35 -26
- package/ios/Collapse/Collapse.swift +11 -1
- package/ios/Colors+Radius+Spacing/Colors.swift +20 -17
- package/ios/Colors+Radius+Spacing/Spacing.swift +3 -1
- package/ios/Colors+Radius+Spacing/Theme.swift +15 -15
- package/ios/DateTimePicker/DateTimePicker.swift +4 -2
- package/ios/DateTimePicker/WheelPicker.swift +7 -3
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +14 -0
- package/ios/Extensions/Color++.swift +32 -0
- package/ios/Icon/Icon.swift +5 -1
- package/ios/IconButton/IconButton.swift +35 -7
- package/ios/Image/Image.swift +16 -3
- package/ios/Information/Information.swift +3 -1
- package/ios/Input/ErrorView.swift +3 -1
- package/ios/Input/Input.swift +31 -8
- package/ios/Input/InputPhoneNumber.swift +14 -3
- package/ios/Input/InputSearch.swift +7 -1
- package/ios/Input/InputTextArea.swift +78 -34
- package/ios/InputDropDown/InputDropDown.swift +4 -1
- package/ios/InputMoney/InputMoney.swift +16 -4
- package/ios/Popup/PopupDisplay.swift +3 -4
- package/ios/Popup/PopupNotify.swift +3 -4
- package/ios/ProgressInfo/ProgressInfo.swift +4 -2
- package/ios/Radio/Radio.swift +12 -13
- package/ios/Rating/Rating.swift +1 -1
- package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +6 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +38 -0
- 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/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +38 -0
- package/ios/Stepper/Stepper.swift +2 -2
- package/ios/Steps/Steps.swift +22 -6
- package/ios/SuggestAction/SuggestAction.swift +5 -3
- package/ios/Swipeable/SwipeCell.swift +5 -3
- package/ios/Switch/Switch.swift +53 -28
- package/ios/TabView/TabView.swift +18 -14
- package/ios/Template/TrustBanner/TrustBanner.swift +6 -7
- package/ios/Tooltip/Tooltip.swift +3 -0
- package/ios/Typography/FontScaleStore.swift +19 -0
- package/ios/Typography/Text.swift +3 -0
- package/ios/Typography/Typography.swift +8 -5
- package/ios/Uploader/Uploader.swift +0 -9
- package/ios/native-kits.podspec +6 -3
- package/ios-demo/MoMoUIKitsDemo.podspec +5 -3
- package/ios-demo/README.md +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +9 -57
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +21 -3
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +188 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +2 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +5 -4
- package/local.properties +8 -0
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import CoreGraphics
|
|
2
|
+
|
|
3
|
+
/// App-wide font-scale preference for the SwiftUI kit. An exported holder the host writes once at
|
|
4
|
+
/// app startup (from the cache-backed `FontScaleProvider`); `scaleSize`/`appFont` read the snapshot.
|
|
5
|
+
/// No realtime: the SwiftUI kit has no navigation container to scope reactive updates, so a startup
|
|
6
|
+
/// snapshot is enough. When `useOSScaleRate` is false the kit applies `userScaleRate` instead of the
|
|
7
|
+
/// OS Dynamic Type factor.
|
|
8
|
+
public final class FontScaleStore {
|
|
9
|
+
public static let shared = FontScaleStore()
|
|
10
|
+
private init() {}
|
|
11
|
+
|
|
12
|
+
public private(set) var userScaleRate: CGFloat = 1
|
|
13
|
+
public private(set) var useOSScaleRate: Bool = true
|
|
14
|
+
|
|
15
|
+
public func update(userScaleRate: CGFloat, useOSScaleRate: Bool) {
|
|
16
|
+
self.userScaleRate = userScaleRate
|
|
17
|
+
self.useOSScaleRate = useOSScaleRate
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
3
|
public func scaleSize(_ size: CGFloat, _ scaleRate: CGFloat? = nil) -> CGFloat {
|
|
4
|
+
if !FontScaleStore.shared.useOSScaleRate {
|
|
5
|
+
return size * FontScaleStore.shared.userScaleRate
|
|
6
|
+
}
|
|
4
7
|
let defaultScreenSize: CGFloat = 375
|
|
5
8
|
let maxFontScale: CGFloat = scaleRate ?? 1.5
|
|
6
9
|
let maxDeviceScale: CGFloat = 5
|
|
@@ -11,13 +11,16 @@ public extension View {
|
|
|
11
11
|
|
|
12
12
|
public extension Font {
|
|
13
13
|
static func appFont(size: CGFloat) -> Font {
|
|
14
|
+
if !FontScaleStore.shared.useOSScaleRate {
|
|
15
|
+
return Font.system(size: size * FontScaleStore.shared.userScaleRate)
|
|
16
|
+
}
|
|
14
17
|
let defaultScreenSize: CGFloat = 375
|
|
15
18
|
let maxFontScale: CGFloat = 1.5
|
|
16
19
|
let maxDeviceScale: CGFloat = 5
|
|
17
|
-
|
|
20
|
+
|
|
18
21
|
let deviceWidth = UIScreen.main.bounds.width
|
|
19
22
|
let deviceScale = deviceWidth / defaultScreenSize
|
|
20
|
-
|
|
23
|
+
|
|
21
24
|
let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
22
25
|
let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
|
|
23
26
|
let fontScale = scaledFont.pointSize / defaultFont.pointSize
|
|
@@ -34,7 +37,7 @@ public extension Font {
|
|
|
34
37
|
|
|
35
38
|
return Font.system(size: fontSize)
|
|
36
39
|
}
|
|
37
|
-
|
|
40
|
+
|
|
38
41
|
// New supported typography styles
|
|
39
42
|
static let headline_default_bold = appFont(size: 24).weight(.bold)
|
|
40
43
|
static let header_m_bold = appFont(size: 18).weight(.bold)
|
|
@@ -52,7 +55,7 @@ public extension Font {
|
|
|
52
55
|
static let action_s_bold = appFont(size: 14).weight(.bold)
|
|
53
56
|
static let action_xs_bold = appFont(size: 12).weight(.bold)
|
|
54
57
|
static let action_xxs_bold = appFont(size: 10).weight(.bold)
|
|
55
|
-
|
|
58
|
+
|
|
56
59
|
// Legacy styles
|
|
57
60
|
static let headline_default = appFont(size: 28).weight(.semibold)
|
|
58
61
|
static let headline_s = appFont(size: 24).weight(.semibold)
|
|
@@ -77,7 +80,7 @@ public extension Font {
|
|
|
77
80
|
static let action_xxs = appFont(size: 10).weight(.bold)
|
|
78
81
|
static let action_xs = appFont(size: 12).weight(.bold)
|
|
79
82
|
static let action_s = appFont(size: 15).weight(.bold)
|
|
80
|
-
|
|
83
|
+
|
|
81
84
|
// deprecated
|
|
82
85
|
static let h1 = appFont(size: 36).weight(.semibold) //headline_xl
|
|
83
86
|
static let h2 = appFont(size: 32).weight(.semibold)
|
|
@@ -172,12 +172,3 @@ private struct UploaderImageItem: View {
|
|
|
172
172
|
.buttonStyle(ActiveOpacityButtonStyle())
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
// MARK: - Active opacity button style
|
|
177
|
-
|
|
178
|
-
private struct ActiveOpacityButtonStyle: ButtonStyle {
|
|
179
|
-
func makeBody(configuration: Configuration) -> some View {
|
|
180
|
-
configuration.label
|
|
181
|
-
.opacity(configuration.isPressed ? 0.5 : 1)
|
|
182
|
-
}
|
|
183
|
-
}
|
package/ios/native-kits.podspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = 'MoMoUIKits'
|
|
3
|
-
s.version = '0.162.2-sp.
|
|
3
|
+
s.version = '0.162.2-sp.10'
|
|
4
4
|
s.summary = 'MoMoUIKits for iOS'
|
|
5
5
|
s.homepage = 'https://momo.vn'
|
|
6
6
|
s.license = { :type => 'MIT' }
|
|
@@ -60,12 +60,15 @@ Pod::Spec.new do |s|
|
|
|
60
60
|
"Typography/**/*.{swift,m,h}",
|
|
61
61
|
"Uploader/**/*.{swift,m,h}"
|
|
62
62
|
]
|
|
63
|
+
s.resource_bundles = {
|
|
64
|
+
'MoMoUIKitsResources' => ['Resources/**/*']
|
|
65
|
+
}
|
|
63
66
|
s.public_header_files = "StatusBarTap/*.h"
|
|
64
67
|
s.frameworks = 'SwiftUI', 'Combine'
|
|
65
68
|
s.pod_target_xcconfig = {
|
|
66
69
|
'DEFINES_MODULE' => 'YES'
|
|
67
70
|
}
|
|
68
|
-
s.dependency 'SDWebImageSwiftUI', '2.2.
|
|
69
|
-
s.dependency 'lottie-ios', '4.
|
|
71
|
+
s.dependency 'SDWebImageSwiftUI', '2.2.1'
|
|
72
|
+
s.dependency 'lottie-ios', '4.6.0'
|
|
70
73
|
s.dependency 'SkeletonUI', '1.0.11'
|
|
71
74
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = 'MoMoUIKitsDemo'
|
|
3
|
-
s.version = '0.162.2-sp.
|
|
3
|
+
s.version = '0.162.2-sp.10'
|
|
4
4
|
s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
|
|
5
5
|
s.homepage = 'https://momo.vn'
|
|
6
6
|
s.license = { :type => 'MIT' }
|
|
@@ -11,8 +11,10 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.swift_version = '5.0'
|
|
12
12
|
|
|
13
13
|
s.source_files = 'Sources/**/*.{swift}'
|
|
14
|
-
s.
|
|
14
|
+
s.resource_bundles = {
|
|
15
|
+
'MoMoUIKitsDemoResources' => ['Resources/**/*']
|
|
16
|
+
}
|
|
15
17
|
s.frameworks = 'SwiftUI', 'UIKit'
|
|
16
18
|
s.dependency 'MoMoUIKits'
|
|
17
|
-
s.dependency 'lottie-ios', '4.
|
|
19
|
+
s.dependency 'lottie-ios', '4.6.0'
|
|
18
20
|
end
|
|
@@ -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
|
+
```
|
|
@@ -6,67 +6,19 @@ public enum MoMoUIKitsDemoViewControllerFactory {
|
|
|
6
6
|
public static func make(
|
|
7
7
|
context: MoMoUIKitsDemoContext = MoMoUIKitsDemoContext(),
|
|
8
8
|
composeViewController: (() -> UIViewController)? = nil
|
|
9
|
+
) -> UIViewController {
|
|
10
|
+
composeViewController?() ?? makeSwiftUI(context: context)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public static func makeSwiftUI(
|
|
14
|
+
context: MoMoUIKitsDemoContext = MoMoUIKitsDemoContext(),
|
|
15
|
+
onOpenCompose: @escaping () -> Void = {}
|
|
9
16
|
) -> UIViewController {
|
|
10
17
|
UIHostingController(
|
|
11
|
-
rootView:
|
|
18
|
+
rootView: SwiftUIDemoBrowserView(
|
|
12
19
|
context: context,
|
|
13
|
-
|
|
20
|
+
onOpenCompose: onOpenCompose
|
|
14
21
|
)
|
|
15
22
|
)
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
|
-
|
|
19
|
-
public struct MoMoUIKitsDemoView: View {
|
|
20
|
-
private let context: MoMoUIKitsDemoContext
|
|
21
|
-
private let composeViewController: (() -> UIViewController)?
|
|
22
|
-
@State private var mode: MoMoUIKitsDemoMode
|
|
23
|
-
|
|
24
|
-
public init(
|
|
25
|
-
context: MoMoUIKitsDemoContext = MoMoUIKitsDemoContext(),
|
|
26
|
-
composeViewController: (() -> UIViewController)? = nil
|
|
27
|
-
) {
|
|
28
|
-
self.context = context
|
|
29
|
-
self.composeViewController = composeViewController
|
|
30
|
-
_mode = State(initialValue: composeViewController == nil ? .swiftUI : .compose)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public var body: some View {
|
|
34
|
-
VStack(spacing: 0) {
|
|
35
|
-
Picker("", selection: $mode) {
|
|
36
|
-
if composeViewController != nil {
|
|
37
|
-
Text("Compose").tag(MoMoUIKitsDemoMode.compose)
|
|
38
|
-
}
|
|
39
|
-
Text("SwiftUI").tag(MoMoUIKitsDemoMode.swiftUI)
|
|
40
|
-
}
|
|
41
|
-
.pickerStyle(.segmented)
|
|
42
|
-
.padding(.horizontal, 16)
|
|
43
|
-
.padding(.vertical, 12)
|
|
44
|
-
.background(Color(.systemBackground))
|
|
45
|
-
|
|
46
|
-
Group {
|
|
47
|
-
if mode == .compose, let composeViewController {
|
|
48
|
-
ComposeDemoHostView(makeViewController: composeViewController)
|
|
49
|
-
} else {
|
|
50
|
-
SwiftUIDemoBrowserView(context: context)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private enum MoMoUIKitsDemoMode: String {
|
|
59
|
-
case compose
|
|
60
|
-
case swiftUI
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private struct ComposeDemoHostView: UIViewControllerRepresentable {
|
|
64
|
-
let makeViewController: () -> UIViewController
|
|
65
|
-
|
|
66
|
-
func makeUIViewController(context: Context) -> UIViewController {
|
|
67
|
-
makeViewController()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
|
|
71
|
-
}
|
|
72
|
-
|
|
@@ -89,6 +89,7 @@ public let ScreenUsages: [ScreenUsage] = [
|
|
|
89
89
|
ScreenUsage(title: "Bottom Tab", destination: AnyView(BottomTabDemo()), icon: getIcon(icon: "Layout")),
|
|
90
90
|
ScreenUsage(title: "Animated Header", destination: AnyView(AnimatedHeaderDemo()), icon: getIcon(icon: "Layout")),
|
|
91
91
|
ScreenUsage(title: "Theme", destination: AnyView(ThemeDemo()), icon: getIcon(icon: "Typography")),
|
|
92
|
+
ScreenUsage(title: "Localize", destination: AnyView(LocalizeDemo()), icon: getIcon(icon: "Typography")),
|
|
92
93
|
]
|
|
93
94
|
|
|
94
95
|
@available(iOS 16.0, *)
|
|
@@ -96,8 +97,22 @@ public struct HomeView: View {
|
|
|
96
97
|
// Mirrors Compose's `inputSearch` state: bound into the header search and
|
|
97
98
|
// forwarded into the content for filtering.
|
|
98
99
|
@State private var searchText = ""
|
|
100
|
+
private let onOpenCompose: () -> Void
|
|
101
|
+
private let applicationContext: MiniAppContext?
|
|
102
|
+
private let composeApi: KitComposeApi?
|
|
103
|
+
private let config: KitConfig?
|
|
99
104
|
|
|
100
|
-
public init(
|
|
105
|
+
public init(
|
|
106
|
+
onOpenCompose: @escaping () -> Void = {},
|
|
107
|
+
applicationContext: MiniAppContext? = nil,
|
|
108
|
+
composeApi: KitComposeApi? = nil,
|
|
109
|
+
config: KitConfig? = nil
|
|
110
|
+
) {
|
|
111
|
+
self.onOpenCompose = onOpenCompose
|
|
112
|
+
self.applicationContext = applicationContext
|
|
113
|
+
self.composeApi = composeApi
|
|
114
|
+
self.config = config
|
|
115
|
+
}
|
|
101
116
|
|
|
102
117
|
public var body: some View {
|
|
103
118
|
NavigationContainer(
|
|
@@ -124,7 +139,7 @@ public struct HomeView: View {
|
|
|
124
139
|
AnyView(
|
|
125
140
|
MoMoUIKits.Button(
|
|
126
141
|
title: "Footer Button",
|
|
127
|
-
action:
|
|
142
|
+
action: onOpenCompose,
|
|
128
143
|
type: .primary,
|
|
129
144
|
size: .large
|
|
130
145
|
)
|
|
@@ -179,7 +194,10 @@ public struct HomeView: View {
|
|
|
179
194
|
position: .right,
|
|
180
195
|
bottomPadding: nil
|
|
181
196
|
)
|
|
182
|
-
)
|
|
197
|
+
),
|
|
198
|
+
applicationContext: applicationContext,
|
|
199
|
+
composeApi: composeApi,
|
|
200
|
+
config: config
|
|
183
201
|
)
|
|
184
202
|
}
|
|
185
203
|
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LocalizeDemo.swift
|
|
3
|
+
// MoMoUIKitsDemo
|
|
4
|
+
//
|
|
5
|
+
// SwiftUI port of the Compose demo `sample/shared/.../screens/LocalizeUsage.kt`,
|
|
6
|
+
// showcasing the `Localize` i18n port (ios/Application/Localize.swift).
|
|
7
|
+
// Synced from sample/iosApp/iosApp/Demo/LocalizeDemo.swift.
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
import MoMoUIKits
|
|
11
|
+
import SwiftUI
|
|
12
|
+
|
|
13
|
+
// App-specific dictionary. Keys here do NOT exist in the kit defaults, so addTranslations
|
|
14
|
+
// registers them cleanly (addTranslations keeps existing keys on clash, host-default wins).
|
|
15
|
+
private let AppTranslations = LocalizationObject(
|
|
16
|
+
vi: [
|
|
17
|
+
"demo_greeting": "Xin chào MoMo!",
|
|
18
|
+
"demo_cart_title": "Giỏ hàng của bạn",
|
|
19
|
+
],
|
|
20
|
+
en: [
|
|
21
|
+
"demo_greeting": "Hello MoMo!",
|
|
22
|
+
"demo_cart_title": "Your cart",
|
|
23
|
+
]
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
struct LocalizeDemo: View {
|
|
27
|
+
@EnvironmentObject private var localize: Localize
|
|
28
|
+
|
|
29
|
+
private var isEnglish: Bool { localize.currentLanguage == Localize.EN }
|
|
30
|
+
|
|
31
|
+
var body: some View {
|
|
32
|
+
ScrollView {
|
|
33
|
+
VStack(alignment: .leading, spacing: 0) {
|
|
34
|
+
|
|
35
|
+
LocalizeSectionBox(title: "Đổi ngôn ngữ (toàn app)") {
|
|
36
|
+
MomoText(
|
|
37
|
+
"localize.changeLanguage(...) đổi ngôn ngữ cho cả NavigationContainer — mọi màn hình đang đọc translate() sẽ cập nhật theo.",
|
|
38
|
+
typography: .descriptionDefaultRegular
|
|
39
|
+
)
|
|
40
|
+
Switch(
|
|
41
|
+
.constant(isEnglish),
|
|
42
|
+
onChange: { _ in localize.changeLanguage(isEnglish ? Localize.VI : Localize.EN) },
|
|
43
|
+
title: "English"
|
|
44
|
+
)
|
|
45
|
+
MomoText("currentLanguage = \(localize.currentLanguage)", typography: .labelDefaultMedium)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
LocalizeSectionBox(title: "translate(key) — từ điển mặc định của kit") {
|
|
49
|
+
TranslationRow(key: "confirm", value: localize.translate("confirm"))
|
|
50
|
+
TranslationRow(key: "cancel", value: localize.translate("cancel"))
|
|
51
|
+
TranslationRow(key: "done", value: localize.translate("done"))
|
|
52
|
+
TranslationRow(key: "seeMore", value: localize.translate("seeMore"))
|
|
53
|
+
TranslationRow(key: "balance", value: localize.translate("balance"))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
LocalizeSectionBox(title: "Key thiếu → trả về chính key") {
|
|
57
|
+
MomoText(
|
|
58
|
+
"translate() với key không có (hoặc giá trị rỗng) sẽ trả lại đúng key để dễ phát hiện thiếu bản dịch.",
|
|
59
|
+
typography: .descriptionDefaultRegular
|
|
60
|
+
)
|
|
61
|
+
TranslationRow(key: "not_a_real_key", value: localize.translate("not_a_real_key"))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
LocalizeSectionBox(title: "Chèn tham số vào bản dịch") {
|
|
65
|
+
MomoText(
|
|
66
|
+
"Bản port không tự nội suy {placeholder} — tự replace ở nơi dùng.",
|
|
67
|
+
typography: .descriptionDefaultRegular
|
|
68
|
+
)
|
|
69
|
+
TranslationRow(
|
|
70
|
+
key: "voucherRemindHour",
|
|
71
|
+
value: localize.translate("voucherRemindHour").replacingOccurrences(of: "{hours}", with: "3")
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
LocalizeSectionBox(title: "translateData(vi:en:) — dịch nội tuyến") {
|
|
76
|
+
MomoText(
|
|
77
|
+
"Cho chuỗi dùng một lần, không cần khai báo key trong từ điển.",
|
|
78
|
+
typography: .descriptionDefaultRegular
|
|
79
|
+
)
|
|
80
|
+
MomoText(localize.translateData(vi: "Thanh toán ngay", en: "Pay now"), typography: .headerDefaultBold)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
LocalizeSectionBox(title: "translateData(map) — chọn theo ngôn ngữ") {
|
|
84
|
+
MomoText(
|
|
85
|
+
localize.translateData([
|
|
86
|
+
Localize.VI: "Lịch sử giao dịch",
|
|
87
|
+
Localize.EN: "Transaction history",
|
|
88
|
+
]),
|
|
89
|
+
typography: .headerDefaultBold
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
LocalizeSectionBox(title: "addTranslations — từ điển riêng của app") {
|
|
94
|
+
MomoText(
|
|
95
|
+
"Host đăng ký key riêng (đã add khi màn hình xuất hiện), rồi dùng translate() như key mặc định.",
|
|
96
|
+
typography: .descriptionDefaultRegular
|
|
97
|
+
)
|
|
98
|
+
TranslationRow(key: "demo_greeting", value: localize.translate("demo_greeting"))
|
|
99
|
+
TranslationRow(key: "demo_cart_title", value: localize.translate("demo_cart_title"))
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
LocalizeSectionBox(title: "Ví dụ thực tế") {
|
|
103
|
+
// errorCode already ends with a separator ("Mã lỗi: " / "Error code: ").
|
|
104
|
+
MomoText(localize.translate("errorCode") + "E-4097", typography: .bodyDefaultRegular)
|
|
105
|
+
HStack(spacing: Spacing.M) {
|
|
106
|
+
Button(
|
|
107
|
+
title: localize.translate("cancel"),
|
|
108
|
+
action: {},
|
|
109
|
+
type: .outline,
|
|
110
|
+
size: .medium,
|
|
111
|
+
isFull: false
|
|
112
|
+
)
|
|
113
|
+
Button(
|
|
114
|
+
title: localize.translate("confirm"),
|
|
115
|
+
action: {},
|
|
116
|
+
type: .primary,
|
|
117
|
+
size: .medium,
|
|
118
|
+
isFull: false
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
Spacer(minLength: 32)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Registers the app-specific dictionary once per appearance; addTranslations'
|
|
127
|
+
// merge is idempotent, so re-entry (e.g. re-navigating back to this screen) is safe.
|
|
128
|
+
.onAppear {
|
|
129
|
+
localize.addTranslations(AppTranslations)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// MARK: - LocalizeSectionBox
|
|
135
|
+
|
|
136
|
+
/// Titled rounded-card section container, mirroring Compose's `BasicColumnBox`
|
|
137
|
+
/// (title label above a `theme.colors.background.surface` card with `Radius.M` corners).
|
|
138
|
+
private struct LocalizeSectionBox<Content: View>: View {
|
|
139
|
+
@Environment(\.appTheme) private var theme
|
|
140
|
+
let title: String
|
|
141
|
+
@ViewBuilder let content: () -> Content
|
|
142
|
+
|
|
143
|
+
var body: some View {
|
|
144
|
+
VStack(alignment: .leading, spacing: 8) {
|
|
145
|
+
if !title.isEmpty {
|
|
146
|
+
MomoText(title, typography: .headerMBold)
|
|
147
|
+
.padding(.top, 8)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
VStack(alignment: .leading, spacing: 8) {
|
|
151
|
+
content()
|
|
152
|
+
}
|
|
153
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
154
|
+
.padding(12)
|
|
155
|
+
.background(theme.colors.background.surface)
|
|
156
|
+
.clipShape(RoundedRectangle(cornerRadius: Radius.M))
|
|
157
|
+
}
|
|
158
|
+
.padding(12)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// MARK: - TranslationRow
|
|
163
|
+
|
|
164
|
+
private struct TranslationRow: View {
|
|
165
|
+
@Environment(\.appTheme) private var theme
|
|
166
|
+
let key: String
|
|
167
|
+
let value: String
|
|
168
|
+
|
|
169
|
+
var body: some View {
|
|
170
|
+
VStack(alignment: .leading, spacing: 2) {
|
|
171
|
+
MomoText(key, typography: .labelDefaultMedium, color: theme.colors.text.secondary)
|
|
172
|
+
MomoText(value, typography: .bodyDefaultRegular)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// MARK: - Preview
|
|
178
|
+
|
|
179
|
+
#Preview {
|
|
180
|
+
if #available(iOS 16.0, *) {
|
|
181
|
+
NavigationStack {
|
|
182
|
+
LocalizeDemo()
|
|
183
|
+
.environmentObject(Localize())
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
// Fallback on earlier versions
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -23,6 +23,7 @@ struct NavigationDemo: View {
|
|
|
23
23
|
@available(iOS 16.0, *)
|
|
24
24
|
private struct NavigationDemoContent: View {
|
|
25
25
|
@EnvironmentObject private var navigator: Navigator
|
|
26
|
+
@State private var textValue1 = ""
|
|
26
27
|
|
|
27
28
|
var body: some View {
|
|
28
29
|
ScrollView {
|
|
@@ -72,6 +73,7 @@ private struct NavigationDemoContent: View {
|
|
|
72
73
|
row("Show Bottom Sheet") {
|
|
73
74
|
navigator.showBottomSheet({
|
|
74
75
|
VStack(spacing: 12) {
|
|
76
|
+
Input(text: $textValue1, placeholder: "Test Bottom Sheet")
|
|
75
77
|
ForEach(0..<4, id: \.self) { i in
|
|
76
78
|
MomoText("Bottom sheet row \(i + 1)")
|
|
77
79
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
@@ -3,20 +3,21 @@ import MoMoUIKits
|
|
|
3
3
|
|
|
4
4
|
struct SwiftUIDemoBrowserView: View {
|
|
5
5
|
let context: MoMoUIKitsDemoContext
|
|
6
|
+
let onOpenCompose: () -> Void
|
|
6
7
|
@State private var searchText = ""
|
|
7
8
|
|
|
8
9
|
var body: some View {
|
|
9
10
|
Group {
|
|
10
11
|
if #available(iOS 16.0, *) {
|
|
11
|
-
HomeView(
|
|
12
|
+
HomeView(
|
|
13
|
+
onOpenCompose: onOpenCompose,
|
|
14
|
+
applicationContext: context.miniAppContext
|
|
15
|
+
)
|
|
12
16
|
} else {
|
|
13
17
|
fallbackBrowser
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
.environment(\.appTheme, defaultTheme)
|
|
17
|
-
.environmentObject(
|
|
18
|
-
ApplicationEnvironment(applicationContext: context.miniAppContext)
|
|
19
|
-
)
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
private var fallbackBrowser: some View {
|
package/local.properties
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
+
# as it contains information specific to your local configuration.
|
|
3
|
+
#
|
|
4
|
+
# Location of the SDK. This is only used by Gradle.
|
|
5
|
+
# For customization when using a Version Control System, please read the
|
|
6
|
+
# header note.
|
|
7
|
+
#Tue Jun 02 17:05:32 ICT 2026
|
|
8
|
+
sdk.dir=/Users/sophia/Library/Android/sdk
|