@momo-kits/native-kits 0.168.1-beta.3-debug → 0.168.1-beta.30
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 +14 -10
- package/README.md +2 -10
- package/ios/Application/ApplicationEnvironment.swift +7 -6
- package/ios/Application/DesignSystemKits.swift +163 -0
- package/ios/Application/DesignSystemKitsPayload.swift +68 -0
- package/ios/Badge/BadgeRibbon.swift +8 -1
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Input/Input.swift +13 -3
- package/ios/Input/InputPhoneNumber.swift +1 -3
- package/ios/Input/InputSearch.swift +1 -2
- package/ios/Input/InputTextArea.swift +5 -3
- package/ios/InputMoney/InputMoney.swift +6 -7
- package/ios/Layout/ScreenLayout.swift +65 -10
- package/ios/Navigation/BottomSheet.swift +152 -21
- package/ios/Navigation/BottomTab/BottomTab.swift +12 -18
- package/ios/Navigation/BottomTab/BottomTabBar.swift +255 -114
- package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +63 -172
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
- package/ios/Navigation/Component/HeaderBackground.swift +22 -1
- package/ios/Navigation/Component/SnackBar.swift +4 -0
- package/ios/Navigation/ModalScreen.swift +7 -3
- package/ios/Navigation/StackScreen.swift +6 -8
- package/ios/Popup/PopupDisplay.swift +2 -2
- package/ios/Popup/PopupInput.swift +2 -2
- package/ios/Popup/PopupLayout.swift +15 -10
- package/ios/Popup/PopupNotify.swift +2 -2
- package/ios/Stepper/Stepper.swift +1 -2
- package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
- package/ios/Typography/FontScale.swift +29 -15
- package/ios/Typography/Text.swift +86 -12
- package/ios/Typography/Typography.swift +2 -2
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +224 -59
- package/package.json +1 -1
- package/publish.sh +2 -7
- package/build.gradle.kts +0 -13
- package/compose/build.gradle.kts +0 -197
- package/compose/build.gradle.kts.backup +0 -197
- package/compose/compose.podspec +0 -47
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -65
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -283
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -309
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -215
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -404
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -233
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -98
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -312
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -413
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -135
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -36
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -94
- package/gradle/libs.versions.toml +0 -76
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -10
- package/gradle.properties +0 -26
- package/gradlew +0 -252
- package/gradlew.bat +0 -94
- package/ios/Typography/FontScaleStore.swift +0 -58
- package/ios/Typography/KitDesignSystem.swift +0 -17
- package/ios-demo/README.md +0 -120
- package/settings.gradle.kts +0 -64
|
@@ -11,7 +11,7 @@ import SDWebImageSwiftUI
|
|
|
11
11
|
|
|
12
12
|
let jsonUrl = "https://static.momocdn.net/app/json/component-kits/design_system.json"
|
|
13
13
|
|
|
14
|
-
public struct TrustBannerData: Decodable {
|
|
14
|
+
public struct TrustBannerData: Decodable, Equatable {
|
|
15
15
|
public let content: [String: String]
|
|
16
16
|
public let subContent: [String: String]
|
|
17
17
|
public let pciImage: String?
|
|
@@ -85,6 +85,7 @@ let defaultBanner = TrustBannerData(
|
|
|
85
85
|
public struct TrustBanner: View {
|
|
86
86
|
@Environment(\.applicationEnvironment) var applicationEnvironment
|
|
87
87
|
@Environment(\.localize) private var localize
|
|
88
|
+
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
88
89
|
|
|
89
90
|
var onPress: ((String)->Void)?
|
|
90
91
|
private let serviceName: String
|
|
@@ -104,7 +105,8 @@ public struct TrustBanner: View {
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
private var banner: TrustBannerData {
|
|
107
|
-
|
|
108
|
+
// Container config wins, else the host-pushed DesignSystemKits config (Compose parity).
|
|
109
|
+
(applicationEnvironment.config ?? designSystemKitsConfigs.designSystemConfig)?.trustBanner ?? defaultBanner
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
func onPressSecurity() {
|
|
@@ -19,11 +19,19 @@ public struct FontScale: Equatable {
|
|
|
19
19
|
public let useOSScaleRate: Bool
|
|
20
20
|
/// OS Dynamic Type factor at the time the snapshot was taken.
|
|
21
21
|
public let osFontScale: CGFloat
|
|
22
|
+
// AI-GENERATED START: device scale from the app window, not UIScreen.main (fixed to one display on iPhone Duo)
|
|
23
|
+
public let windowShortSide: CGFloat
|
|
22
24
|
|
|
23
|
-
public init(
|
|
25
|
+
public init(
|
|
26
|
+
userScaleRate: CGFloat = 1,
|
|
27
|
+
useOSScaleRate: Bool = true,
|
|
28
|
+
osFontScale: CGFloat = 1,
|
|
29
|
+
windowShortSide: CGFloat? = nil
|
|
30
|
+
) {
|
|
24
31
|
self.userScaleRate = userScaleRate
|
|
25
32
|
self.useOSScaleRate = useOSScaleRate
|
|
26
33
|
self.osFontScale = osFontScale
|
|
34
|
+
self.windowShortSide = windowShortSide ?? DesignSystemKits.currentWindowShortSide()
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
/// `callAsFunction` so call sites keep reading like Compose's `scaleSize(16)`.
|
|
@@ -31,8 +39,8 @@ public struct FontScale: Equatable {
|
|
|
31
39
|
guard useOSScaleRate else { return size * userScaleRate }
|
|
32
40
|
|
|
33
41
|
// Short side, not width: landscape must not inflate every font (and so every popup's height).
|
|
34
|
-
let
|
|
35
|
-
|
|
42
|
+
let deviceScale = windowShortSide / Self.defaultScreenSize
|
|
43
|
+
// AI-GENERATED END: device scale from the app window, not UIScreen.main (fixed to one display on iPhone Duo)
|
|
36
44
|
|
|
37
45
|
var deviceScaled = size
|
|
38
46
|
var osScaled = size
|
|
@@ -52,13 +60,16 @@ public struct FontScale: Equatable {
|
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
/// A host-pushed mini-app context wins per field, matching Compose's
|
|
55
|
-
/// `context?.useOSScaleRate ?:
|
|
63
|
+
/// `context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate`.
|
|
56
64
|
public func overriding(userScaleRate: CGFloat?, useOSScaleRate: Bool?) -> FontScale {
|
|
57
65
|
guard userScaleRate != nil || useOSScaleRate != nil else { return self }
|
|
58
66
|
return FontScale(
|
|
59
67
|
userScaleRate: userScaleRate ?? self.userScaleRate,
|
|
60
68
|
useOSScaleRate: useOSScaleRate ?? self.useOSScaleRate,
|
|
61
|
-
osFontScale: osFontScale
|
|
69
|
+
osFontScale: osFontScale,
|
|
70
|
+
// AI-GENERATED START: keep the window size through context overrides
|
|
71
|
+
windowShortSide: windowShortSide
|
|
72
|
+
// AI-GENERATED END: keep the window size through context overrides
|
|
62
73
|
)
|
|
63
74
|
}
|
|
64
75
|
}
|
|
@@ -66,7 +77,7 @@ public struct FontScale: Equatable {
|
|
|
66
77
|
private struct FontScaleKey: EnvironmentKey {
|
|
67
78
|
/// Computed, never stored: a bare `UIHostingController` root that never got `.momoFontScale()`
|
|
68
79
|
/// still reads the live store instead of a value frozen at first access.
|
|
69
|
-
static var defaultValue: FontScale {
|
|
80
|
+
static var defaultValue: FontScale { DesignSystemKits.shared.fontScale }
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
public extension EnvironmentValues {
|
|
@@ -77,9 +88,10 @@ public extension EnvironmentValues {
|
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
public extension View {
|
|
80
|
-
/// Injects a Dynamic-Type-observing font scale
|
|
91
|
+
/// Injects a Dynamic-Type-observing font scale plus `\.designSystemKitsConfigs` (whitelist, remote config)
|
|
92
|
+
/// and re-renders this subtree on change.
|
|
81
93
|
/// Use at every `UIHostingController` root that is not inside a `NavigationContainer`.
|
|
82
|
-
func momoFontScale(_ store:
|
|
94
|
+
func momoFontScale(_ store: DesignSystemKits = .shared, context: MiniAppContext? = nil) -> some View {
|
|
83
95
|
modifier(MomoFontScaleModifier(store: store, context: context))
|
|
84
96
|
}
|
|
85
97
|
}
|
|
@@ -87,17 +99,19 @@ public extension View {
|
|
|
87
99
|
/// `@ObservedObject` is load-bearing, same as `MomoLocalizeModifier`: `@Environment(\.momoFontScale)`
|
|
88
100
|
/// only invalidates when the boxed snapshot changes, which requires *this* body to re-run on publish.
|
|
89
101
|
private struct MomoFontScaleModifier: ViewModifier {
|
|
90
|
-
@ObservedObject var store:
|
|
102
|
+
@ObservedObject var store: DesignSystemKits
|
|
91
103
|
let context: MiniAppContext?
|
|
92
104
|
|
|
93
105
|
func body(content: Content) -> some View {
|
|
94
|
-
content
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
content
|
|
107
|
+
.environment(
|
|
108
|
+
\.momoFontScale,
|
|
109
|
+
store.fontScale.overriding(
|
|
110
|
+
userScaleRate: context?.userScaleRate,
|
|
111
|
+
useOSScaleRate: context?.useOSScaleRate
|
|
112
|
+
)
|
|
99
113
|
)
|
|
100
|
-
|
|
114
|
+
.environment(\.designSystemKitsConfigs, store.getConfigs())
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
// AI-GENERATED END: reactive font-scale snapshot injected through the environment
|
|
@@ -4,7 +4,7 @@ import SwiftUI
|
|
|
4
4
|
/// free functions). Inside a SwiftUI view prefer `@Environment(\.momoFontScale)` so the view
|
|
5
5
|
/// re-renders when Dynamic Type or the host preference changes.
|
|
6
6
|
public func scaleSize(_ size: CGFloat) -> CGFloat {
|
|
7
|
-
|
|
7
|
+
DesignSystemKits.shared.fontScale(size)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
@available(*, deprecated, message: "Max font scale is fixed at 1.5; this override is no longer applied. Drop the second argument.")
|
|
@@ -105,10 +105,10 @@ private enum MomoFontFace {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
/// Port of Compose `getFontFamily`; SF Pro Text is the iOS system font, so the legacy family is `.system`.
|
|
108
|
-
private func momoFontFace(family: String, weight: Font.Weight) -> MomoFontFace? {
|
|
108
|
+
private func momoFontFace(family: String, weight: Font.Weight, isWhiteList: Bool) -> MomoFontFace? {
|
|
109
109
|
let isNewFamily = family == "MomoTrustSans" || family == headerFontFamily
|
|
110
110
|
// Outside the whitelist the new DS families drop to the legacy font, as before DS-791.
|
|
111
|
-
if family == "SFProText" || (isNewFamily && !
|
|
111
|
+
if family == "SFProText" || (isNewFamily && !isWhiteList) { return .system }
|
|
112
112
|
// single-file families (Compose maps every weight to the same .otf)
|
|
113
113
|
if family == headerFontFamily || family == "MoMoSignature" { return .named(family) }
|
|
114
114
|
guard family == "MomoTrustSans" else { return nil }
|
|
@@ -127,8 +127,14 @@ private func momoFontFace(family: String, weight: Font.Weight) -> MomoFontFace?
|
|
|
127
127
|
/// Header title family (Compose `HEADER_FONT_FAMILY`), whitelist only like the default font.
|
|
128
128
|
let headerFontFamily = "MoMoTrustDisplay"
|
|
129
129
|
|
|
130
|
-
private func momoFont(
|
|
131
|
-
|
|
130
|
+
private func momoFont(
|
|
131
|
+
size: CGFloat,
|
|
132
|
+
weight: Font.Weight,
|
|
133
|
+
family: String,
|
|
134
|
+
fallbackFamily: String? = nil,
|
|
135
|
+
isWhiteList: Bool
|
|
136
|
+
) -> Font {
|
|
137
|
+
switch momoFontFace(family: family, weight: weight, isWhiteList: isWhiteList) {
|
|
132
138
|
case .system:
|
|
133
139
|
return .system(size: size, weight: weight)
|
|
134
140
|
case .named(let name) where UIFont(name: name, size: size) != nil:
|
|
@@ -136,15 +142,15 @@ private func momoFont(size: CGFloat, weight: Font.Weight, family: String, fallba
|
|
|
136
142
|
default:
|
|
137
143
|
// Compose falls back to the default font file when a family is missing
|
|
138
144
|
if let fallbackFamily, fallbackFamily != family {
|
|
139
|
-
return momoFont(size: size, weight: weight, family: fallbackFamily)
|
|
145
|
+
return momoFont(size: size, weight: weight, family: fallbackFamily, isWhiteList: isWhiteList)
|
|
140
146
|
}
|
|
141
147
|
return .system(size: size, weight: weight)
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
// lineHeight is identical across weights of a family, so the regular face is enough.
|
|
146
|
-
private func momoLineHeight(size: CGFloat, family: String, fallbackFamily: String? = nil) -> CGFloat {
|
|
147
|
-
switch momoFontFace(family: family, weight: .regular) {
|
|
152
|
+
private func momoLineHeight(size: CGFloat, family: String, fallbackFamily: String? = nil, isWhiteList: Bool) -> CGFloat {
|
|
153
|
+
switch momoFontFace(family: family, weight: .regular, isWhiteList: isWhiteList) {
|
|
148
154
|
case .system:
|
|
149
155
|
break
|
|
150
156
|
case .named(let name):
|
|
@@ -152,15 +158,71 @@ private func momoLineHeight(size: CGFloat, family: String, fallbackFamily: Strin
|
|
|
152
158
|
fallthrough
|
|
153
159
|
case nil:
|
|
154
160
|
if let fallbackFamily, fallbackFamily != family {
|
|
155
|
-
return momoLineHeight(size: size, family: fallbackFamily)
|
|
161
|
+
return momoLineHeight(size: size, family: fallbackFamily, isWhiteList: isWhiteList)
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
return UIFont.systemFont(ofSize: size).lineHeight
|
|
159
165
|
}
|
|
160
166
|
|
|
167
|
+
/// UIKit counterpart of `momoFont`, for text that is not a `MomoText` (UITextField/UITextView, text measuring).
|
|
168
|
+
func momoUIFont(size: CGFloat, weight: UIFont.Weight, family: String, isWhiteList: Bool) -> UIFont {
|
|
169
|
+
guard case .named(let name) = momoFontFace(family: family, weight: Font.Weight(weight), isWhiteList: isWhiteList),
|
|
170
|
+
let font = UIFont(name: name, size: size) else {
|
|
171
|
+
return .systemFont(ofSize: size, weight: weight)
|
|
172
|
+
}
|
|
173
|
+
return font
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private extension Font.Weight {
|
|
177
|
+
init(_ weight: UIFont.Weight) {
|
|
178
|
+
switch weight {
|
|
179
|
+
case .ultraLight: self = .ultraLight
|
|
180
|
+
case .thin: self = .thin
|
|
181
|
+
case .light: self = .light
|
|
182
|
+
case .medium: self = .medium
|
|
183
|
+
case .semibold: self = .semibold
|
|
184
|
+
case .bold: self = .bold
|
|
185
|
+
case .heavy: self = .heavy
|
|
186
|
+
case .black: self = .black
|
|
187
|
+
default: self = .regular
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/// Gives input text the same family as `MomoText` (Compose's `getFontFamily`), e.g. a TextField
|
|
193
|
+
/// next to a `MomoText` placeholder. `size` is unscaled; the environment font scale is applied here.
|
|
194
|
+
private struct KitFontModifier: ViewModifier {
|
|
195
|
+
@Environment(\.appTheme) private var theme
|
|
196
|
+
@Environment(\.momoFontScale) private var fontScale
|
|
197
|
+
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
198
|
+
let size: CGFloat
|
|
199
|
+
let weight: Font.Weight
|
|
200
|
+
|
|
201
|
+
func body(content: Content) -> some View {
|
|
202
|
+
content.font(momoFont(
|
|
203
|
+
size: fontScale(size),
|
|
204
|
+
weight: weight,
|
|
205
|
+
family: theme.font,
|
|
206
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
207
|
+
))
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
extension View {
|
|
212
|
+
func kitFont(_ typography: TypographyStyle) -> some View {
|
|
213
|
+
modifier(KitFontModifier(size: typography.fontSize, weight: typography.fontWeight))
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
func kitFont(size: CGFloat, weight: Font.Weight = .regular) -> some View {
|
|
217
|
+
modifier(KitFontModifier(size: size, weight: weight))
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
161
221
|
public struct MomoText: View {
|
|
162
222
|
@Environment(\.appTheme) private var theme
|
|
163
223
|
@Environment(\.momoFontScale) private var fontScale
|
|
224
|
+
// From the environment, not DesignSystemKits.shared, so a whitelist flip re-renders the text.
|
|
225
|
+
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
164
226
|
private let content: String
|
|
165
227
|
private let typography: TypographyStyle
|
|
166
228
|
private let color: Color?
|
|
@@ -236,7 +298,8 @@ public struct MomoText: View {
|
|
|
236
298
|
size: fontScale(fontSize),
|
|
237
299
|
weight: typography.fontWeight,
|
|
238
300
|
family: fontFamily ?? theme.font,
|
|
239
|
-
fallbackFamily: theme.font
|
|
301
|
+
fallbackFamily: theme.font,
|
|
302
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
240
303
|
)
|
|
241
304
|
}
|
|
242
305
|
|
|
@@ -244,7 +307,13 @@ public struct MomoText: View {
|
|
|
244
307
|
private var baseText: SwiftUI.Text {
|
|
245
308
|
let keywords = highlightText.filter { !$0.isEmpty }.sorted { $0.count > $1.count }
|
|
246
309
|
guard !keywords.isEmpty else { return SwiftUI.Text(content) }
|
|
247
|
-
let highlightFont = momoFont(
|
|
310
|
+
let highlightFont = momoFont(
|
|
311
|
+
size: fontScale(fontSize),
|
|
312
|
+
weight: TypographyStyle.headerXsSemibold.fontWeight,
|
|
313
|
+
family: fontFamily ?? theme.font,
|
|
314
|
+
fallbackFamily: theme.font,
|
|
315
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
316
|
+
)
|
|
248
317
|
func isWordChar(_ character: Character?) -> Bool {
|
|
249
318
|
guard let character else { return false }
|
|
250
319
|
return character.isLetter || character.isNumber || character == "_"
|
|
@@ -282,7 +351,12 @@ public struct MomoText: View {
|
|
|
282
351
|
|
|
283
352
|
// lineSpacing is added on top of the font's natural line height, not on top of fontSize.
|
|
284
353
|
let lineSpacing = max(0, fontScale(lineHeight)
|
|
285
|
-
- momoLineHeight(
|
|
354
|
+
- momoLineHeight(
|
|
355
|
+
size: fontScale(fontSize),
|
|
356
|
+
family: fontFamily ?? theme.font,
|
|
357
|
+
fallbackFamily: theme.font,
|
|
358
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
359
|
+
))
|
|
286
360
|
|
|
287
361
|
var text = baseText
|
|
288
362
|
.font(font)
|
|
@@ -10,12 +10,12 @@ public extension View {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
public extension Font {
|
|
13
|
-
/// Non-reactive: resolves against the current `
|
|
13
|
+
/// Non-reactive: resolves against the current `DesignSystemKits` font scale at each access. The
|
|
14
14
|
/// styles below are computed properties for that reason — as stored `static let`s they would
|
|
15
15
|
/// freeze the scale at first access and never pick up a Dynamic Type change.
|
|
16
16
|
/// Inside a view, `@Environment(\.momoFontScale)` + `fontScale.font(size:weight:)` also re-renders.
|
|
17
17
|
static func appFont(size: CGFloat) -> Font {
|
|
18
|
-
|
|
18
|
+
DesignSystemKits.shared.fontScale.font(size: size)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// New supported typography styles
|
package/ios/native-kits.podspec
CHANGED
|
@@ -2,77 +2,246 @@
|
|
|
2
2
|
// BottomTabDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
// Usage demo for the bottom-tab navigation
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// Usage demo for the bottom-tab navigation, same as RN app/screens/Navigation/BottomTab and
|
|
6
|
+
// Compose's `BottomTabUsage`: the bar shows right away, every tab holds the options and each
|
|
7
|
+
// change rebuilds the bar below. Must be hosted inside a `NavigationContainer`.
|
|
8
8
|
//
|
|
9
9
|
|
|
10
10
|
import MoMoUIKits
|
|
11
11
|
import SwiftUI
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
private struct TabConfig: Hashable {
|
|
14
|
+
let name: String
|
|
15
|
+
var label: String
|
|
16
|
+
var icon: String
|
|
17
|
+
// nil = no badge, "" = dot, "0" = hidden, numbers > 99 = 99+, text = text badge
|
|
18
|
+
var badgeLabel: String?
|
|
19
|
+
var showDot = false
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private struct DemoConfig: Hashable {
|
|
23
|
+
var tabs: [TabConfig] = [
|
|
24
|
+
TabConfig(name: "Momo", label: "Momo", icon: "home_momo_active"),
|
|
25
|
+
TabConfig(name: "UuDai", label: "Ưu đãi", icon: "home_promotions_active", badgeLabel: "Mới"),
|
|
26
|
+
TabConfig(name: "GiaoDich", label: "Giao dịch", icon: "home_history_active", badgeLabel: "5"),
|
|
27
|
+
TabConfig(name: "Toi", label: "Tôi", icon: "home_friends_active", badgeLabel: ""),
|
|
28
|
+
TabConfig(name: "Vi", label: "Ví", icon: "home_wallet_inactive", badgeLabel: "1999"),
|
|
29
|
+
]
|
|
30
|
+
var tabCount = 4
|
|
31
|
+
var longLabels = false
|
|
32
|
+
var special = true
|
|
33
|
+
var ctaLabel = "Quét mọi QR"
|
|
34
|
+
var ctaIcon = "momomain_scan_code"
|
|
35
|
+
var initialRouteName = "Momo"
|
|
36
|
+
var compressionBehavior: DuoBarCompressionBehavior = .toolbar
|
|
37
|
+
var backToInitialTab = true
|
|
38
|
+
|
|
39
|
+
var visibleTabs: [TabConfig] { Array(tabs.prefix(tabCount)) }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private let icons = [
|
|
43
|
+
"home_momo_active", "home_promotions_active", "home_history_active", "home_friends_active",
|
|
44
|
+
"home_wallet_inactive", "notifications_bell", "basic_setting",
|
|
45
|
+
]
|
|
46
|
+
private let ctaIcons = ["momomain_scan_code", "navigation_scan", "navigation_qrcode"]
|
|
47
|
+
private let badges: [(String, String?)] = [
|
|
48
|
+
("Không", nil), ("Dot \"\"", ""), ("\"0\"", "0"), ("\"5\"", "5"),
|
|
49
|
+
("\"1999\"", "1999"), ("\"Mới\"", "Mới"), ("Chữ dài", "Khuyến mãi lớn"),
|
|
50
|
+
]
|
|
51
|
+
|
|
14
52
|
struct BottomTabDemoContent: View {
|
|
15
|
-
@
|
|
53
|
+
@State private var config = DemoConfig()
|
|
54
|
+
// the bar is rebuilt on every change: reopen it on the tab the user is on
|
|
55
|
+
@State private var focused = DemoConfig().initialRouteName
|
|
16
56
|
|
|
17
57
|
var body: some View {
|
|
58
|
+
let tabs = config.visibleTabs
|
|
59
|
+
let initial = tabs.contains { $0.name == focused } ? focused : tabs[0].name
|
|
18
60
|
BottomTab(
|
|
19
|
-
items:
|
|
61
|
+
items: tabs.map { tab in
|
|
20
62
|
BottomTabItem(
|
|
21
|
-
name:
|
|
22
|
-
label: "
|
|
23
|
-
icon:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
BottomTabItem(
|
|
29
|
-
name: "Tab2",
|
|
30
|
-
label: "Option 2",
|
|
31
|
-
icon: "help_center",
|
|
32
|
-
badgeLabel: "0", // hidden (mirrors Compose's "0" → no badge)
|
|
33
|
-
options: NavigationOptions(headerTitle: .default("Option 2")),
|
|
34
|
-
screen: { tabBody("Option 2", Colors.pink09) }
|
|
35
|
-
),
|
|
36
|
-
BottomTabItem(
|
|
37
|
-
name: "Tab3",
|
|
38
|
-
label: "Option 3 with a very long label",
|
|
39
|
-
icon: "pin_star",
|
|
40
|
-
badgeLabel: "New",
|
|
41
|
-
options: NavigationOptions(headerTitle: .default("Option 3")),
|
|
42
|
-
screen: { tabBody("Option 3", Colors.yellow09) }
|
|
43
|
-
),
|
|
44
|
-
BottomTabItem(
|
|
45
|
-
name: "Tab4",
|
|
46
|
-
label: "Option 4 also quite long here",
|
|
47
|
-
icon: "navigation_more_icon",
|
|
48
|
-
badgeLabel: "9999",
|
|
49
|
-
options: NavigationOptions(headerTitle: .default("Option 4")),
|
|
50
|
-
screen: { tabBody("Option 4", Colors.blue10) }
|
|
63
|
+
name: tab.name,
|
|
64
|
+
label: config.longLabels ? "\(tab.label) dài quá" : tab.label,
|
|
65
|
+
icon: tab.icon,
|
|
66
|
+
showDot: tab.showDot,
|
|
67
|
+
badgeLabel: tab.badgeLabel,
|
|
68
|
+
options: NavigationOptions(headerTitle: .default(tab.label)),
|
|
69
|
+
screen: { TabContent(name: tab.name, config: $config, focused: $focused) }
|
|
51
70
|
)
|
|
52
|
-
|
|
53
|
-
floatingButton:
|
|
54
|
-
icon:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
},
|
|
72
|
+
floatingButton: config.special
|
|
73
|
+
? BottomTabFloatingButton(icon: config.ctaIcon, label: config.ctaLabel, onPress: {})
|
|
74
|
+
: nil,
|
|
75
|
+
compressionBehavior: config.compressionBehavior,
|
|
76
|
+
initialRouteName: initial,
|
|
77
|
+
onTabPress: { index, switchTab in
|
|
78
|
+
focused = tabs[index].name
|
|
79
|
+
switchTab()
|
|
80
|
+
},
|
|
81
|
+
backToInitialTab: config.backToInitialTab
|
|
58
82
|
)
|
|
83
|
+
.id(config)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// Content of every tab: this tab's own props, the bar props, then the center action. The tab's
|
|
88
|
+
/// StackScreen scrolls it under the floating bar and keeps its end clear of it.
|
|
89
|
+
private struct TabContent: View {
|
|
90
|
+
let name: String
|
|
91
|
+
@Binding var config: DemoConfig
|
|
92
|
+
@Binding var focused: String
|
|
93
|
+
|
|
94
|
+
private var tab: TabConfig { config.tabs.first { $0.name == name }! }
|
|
95
|
+
|
|
96
|
+
private func updateTab(_ change: (inout TabConfig) -> Void) {
|
|
97
|
+
guard let index = config.tabs.firstIndex(where: { $0.name == name }) else { return }
|
|
98
|
+
change(&config.tabs[index])
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private func yesNo(_ value: Bool, _ onChange: @escaping (Bool) -> Void) -> [Option] {
|
|
102
|
+
[Option(title: "Có", selected: value) { onChange(true) },
|
|
103
|
+
Option(title: "Không", selected: !value) { onChange(false) }]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var body: some View {
|
|
107
|
+
let ctaHidden = config.special && config.tabCount % 2 != 0
|
|
108
|
+
VStack(alignment: .leading, spacing: Spacing.M) {
|
|
109
|
+
MomoText("Chạm các tab bên dưới để xem indicator chạy qua lại. Mỗi thay đổi áp dụng ngay lên thanh tab.",
|
|
110
|
+
typography: .bodyDefaultRegular)
|
|
111
|
+
|
|
112
|
+
Section(title: "Tab đang mở · \(name)") {
|
|
113
|
+
IconOptions(title: "icon", icons: icons, value: tab.icon) { icon in updateTab { $0.icon = icon } }
|
|
114
|
+
Options(title: "badgeLabel",
|
|
115
|
+
hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ dài bị cắt ở 58",
|
|
116
|
+
options: badges.map { title, value in
|
|
117
|
+
Option(title: title, selected: tab.badgeLabel == value) { updateTab { $0.badgeLabel = value } }
|
|
118
|
+
})
|
|
119
|
+
Options(title: "showDot",
|
|
120
|
+
hint: "Hiện dot khi không có badgeLabel hoặc badgeLabel là \"0\"",
|
|
121
|
+
options: yesNo(tab.showDot) { value in updateTab { $0.showDot = value } })
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Section(title: "Thanh tab") {
|
|
125
|
+
Options(title: "Số tab (items)", options: (2...5).map { count in
|
|
126
|
+
Option(title: "\(count)", selected: config.tabCount == count) { config.tabCount = count }
|
|
127
|
+
})
|
|
128
|
+
Options(title: "label", options: [
|
|
129
|
+
Option(title: "Ngắn", selected: !config.longLabels) { config.longLabels = false },
|
|
130
|
+
Option(title: "Dài", selected: config.longLabels) { config.longLabels = true },
|
|
131
|
+
])
|
|
132
|
+
Options(title: "initialRouteName", hint: "Tab được chọn khi BottomTab mở",
|
|
133
|
+
options: config.visibleTabs.map { item in
|
|
134
|
+
Option(title: item.name, selected: config.initialRouteName == item.name) {
|
|
135
|
+
focused = item.name
|
|
136
|
+
config.initialRouteName = item.name
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
Options(title: "compressionBehavior",
|
|
140
|
+
hint: "iPhone Duo: bar nào thu gọn trước khi side bar không đủ chỗ",
|
|
141
|
+
options: [
|
|
142
|
+
Option(title: "toolbar", selected: config.compressionBehavior == .toolbar) {
|
|
143
|
+
config.compressionBehavior = .toolbar
|
|
144
|
+
},
|
|
145
|
+
Option(title: "tabBar", selected: config.compressionBehavior == .tabBar) {
|
|
146
|
+
config.compressionBehavior = .tabBar
|
|
147
|
+
},
|
|
148
|
+
])
|
|
149
|
+
Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
|
|
150
|
+
options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
Section(title: "Nút giữa (floatingButton)") {
|
|
154
|
+
Options(title: "floatingButton",
|
|
155
|
+
hint: ctaHidden
|
|
156
|
+
? "Đang ẩn: nút giữa chỉ hiện khi có 2 hoặc 4 tab"
|
|
157
|
+
: "Có = Special (nút giữa trong notch), Không = Default",
|
|
158
|
+
options: yesNo(config.special) { config.special = $0 })
|
|
159
|
+
if config.special {
|
|
160
|
+
Options(title: "label", options: ["Quét mọi QR", "Quét mã thanh toán"].map { label in
|
|
161
|
+
Option(title: label, selected: config.ctaLabel == label) { config.ctaLabel = label }
|
|
162
|
+
})
|
|
163
|
+
IconOptions(title: "icon", icons: ctaIcons, value: config.ctaIcon) { config.ctaIcon = $0 }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
MoMoUIKits.Button(title: "Khôi phục mặc định", action: { config = DemoConfig() }, type: .outline)
|
|
168
|
+
}
|
|
169
|
+
.padding(Spacing.M)
|
|
59
170
|
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private struct Option: Identifiable {
|
|
174
|
+
var id: String { title }
|
|
175
|
+
let title: String
|
|
176
|
+
let selected: Bool
|
|
177
|
+
let onPress: () -> Void
|
|
178
|
+
}
|
|
60
179
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
180
|
+
private struct Section<Content: View>: View {
|
|
181
|
+
let title: String
|
|
182
|
+
@ViewBuilder let content: () -> Content
|
|
183
|
+
|
|
184
|
+
@Environment(\.appTheme) private var theme
|
|
185
|
+
|
|
186
|
+
var body: some View {
|
|
187
|
+
VStack(alignment: .leading, spacing: Spacing.M) {
|
|
188
|
+
MomoText(title, typography: .headerSSemibold)
|
|
189
|
+
content()
|
|
67
190
|
}
|
|
68
|
-
.
|
|
69
|
-
.
|
|
191
|
+
.padding(Spacing.M)
|
|
192
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
193
|
+
.background(RoundedRectangle(cornerRadius: Radius.M).fill(theme.colors.background.surface))
|
|
70
194
|
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private struct Options: View {
|
|
198
|
+
let title: String
|
|
199
|
+
var hint: String? = nil
|
|
200
|
+
let options: [Option]
|
|
71
201
|
|
|
72
|
-
|
|
73
|
-
VStack
|
|
74
|
-
|
|
75
|
-
|
|
202
|
+
var body: some View {
|
|
203
|
+
VStack(alignment: .leading, spacing: Spacing.XS) {
|
|
204
|
+
MomoText(title, typography: .labelDefaultMedium)
|
|
205
|
+
if let hint {
|
|
206
|
+
MomoText(hint, typography: .descriptionXsRegular)
|
|
207
|
+
}
|
|
208
|
+
LazyVGrid(columns: [GridItem(.adaptive(minimum: 88), spacing: Spacing.S, alignment: .leading)],
|
|
209
|
+
alignment: .leading, spacing: Spacing.S) {
|
|
210
|
+
ForEach(options) { option in
|
|
211
|
+
MoMoUIKits.Button(title: option.title, action: option.onPress,
|
|
212
|
+
type: option.selected ? .primary : .outline, size: .small, isFull: false)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private struct IconOptions: View {
|
|
220
|
+
let title: String
|
|
221
|
+
let icons: [String]
|
|
222
|
+
let value: String
|
|
223
|
+
let onChange: (String) -> Void
|
|
224
|
+
|
|
225
|
+
@Environment(\.appTheme) private var theme
|
|
226
|
+
|
|
227
|
+
var body: some View {
|
|
228
|
+
VStack(alignment: .leading, spacing: Spacing.XS) {
|
|
229
|
+
MomoText(title, typography: .labelDefaultMedium)
|
|
230
|
+
HStack(spacing: Spacing.S) {
|
|
231
|
+
ForEach(icons, id: \.self) { icon in
|
|
232
|
+
let selected = icon == value
|
|
233
|
+
SwiftUI.Button { onChange(icon) } label: {
|
|
234
|
+
Icon(source: icon, size: 24, color: selected ? theme.colors.primary : theme.colors.text.default)
|
|
235
|
+
.frame(width: 40, height: 40)
|
|
236
|
+
.overlay(
|
|
237
|
+
RoundedRectangle(cornerRadius: Radius.S)
|
|
238
|
+
.stroke(selected ? theme.colors.primary : theme.colors.border.default, lineWidth: 1)
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
.buttonStyle(.plain)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
76
245
|
}
|
|
77
246
|
}
|
|
78
247
|
|
|
@@ -80,10 +249,6 @@ struct BottomTabDemoContent: View {
|
|
|
80
249
|
|
|
81
250
|
struct BottomTabDemo: View {
|
|
82
251
|
var body: some View {
|
|
83
|
-
|
|
84
|
-
BottomTabDemoContent()
|
|
85
|
-
} else {
|
|
86
|
-
Text("Bottom tab demo requires iOS 16+").padding()
|
|
87
|
-
}
|
|
252
|
+
BottomTabDemoContent()
|
|
88
253
|
}
|
|
89
254
|
}
|