@momo-kits/native-kits 0.162.30 → 0.162.31
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 +19 -0
- package/ios/Application/ApplicationEnvironment.swift +14 -6
- package/ios/Application/LanguageSource.swift +93 -0
- package/ios/Application/Localize.swift +73 -4
- package/ios/Application/LocalizeModifier.swift +30 -0
- package/ios/Application/Navigation/NavigationContainer.swift +28 -18
- package/ios/Application/Navigation/Navigator.swift +121 -53
- package/ios/Application/Navigation/NavigatorManager.swift +49 -0
- package/ios/Application/Navigation/component/NavigationFooter.swift +90 -0
- package/ios/Application/StackScreen.swift +19 -28
- package/ios/Badge/Badge.swift +2 -1
- package/ios/Badge/BadgeRibbon.swift +6 -2
- package/ios/Button/Button.swift +41 -61
- package/ios/Chip/Chip.swift +6 -5
- package/ios/Icon/Icon.swift +13 -4
- package/ios/Input/ErrorView.swift +2 -1
- package/ios/Input/Input.swift +9 -2
- package/ios/Input/InputPhoneNumber.swift +2 -1
- package/ios/Input/InputSearch.swift +3 -2
- package/ios/Input/InputTextArea.swift +6 -1
- package/ios/InputMoney/InputMoney.swift +5 -2
- package/ios/InputOTP/InputOTP.swift +2 -1
- package/ios/Layout/GridContext.swift +30 -0
- package/ios/Layout/Item.swift +42 -0
- package/ios/Layout/Section.swift +134 -0
- package/ios/Popup/PopupNotify.swift +2 -1
- package/ios/ProgressInfo/ProgressInfo.swift +4 -3
- package/ios/Rating/Rating.swift +2 -1
- package/ios/Stepper/Stepper.swift +2 -1
- package/ios/SuggestAction/SuggestAction.swift +3 -2
- package/ios/Tag/Tag.swift +2 -1
- package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
- package/ios/Title/Title.swift +3 -2
- package/ios/Tooltip/Tooltip.swift +2 -1
- package/ios/Typography/FontScale.swift +103 -0
- package/ios/Typography/FontScaleStore.swift +52 -13
- package/ios/Typography/Text.swift +12 -29
- package/ios/Typography/Typography.swift +66 -86
- package/ios/native-kits.podspec +2 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +87 -73
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +55 -249
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +90 -82
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +74 -104
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +47 -50
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +63 -7
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +90 -81
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +73 -97
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DemoScreen.swift +420 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +46 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +54 -57
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +80 -45
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconDemo.swift +81 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +49 -62
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +66 -116
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +104 -98
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +76 -118
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +73 -86
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +69 -54
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +74 -54
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +73 -20
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +68 -38
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +55 -52
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +51 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +14 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +47 -51
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PlaygroundData.swift +76 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +67 -93
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +34 -43
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +83 -71
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +55 -23
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +58 -46
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SectionDemo.swift +83 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +41 -12
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +67 -127
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +54 -110
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +69 -79
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +78 -58
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +76 -65
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +82 -127
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +44 -19
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +92 -168
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +79 -27
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +0 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +87 -92
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +94 -163
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +70 -70
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +68 -114
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +3 -1
- package/package.json +2 -2
|
@@ -2,56 +2,86 @@
|
|
|
2
2
|
// InputTextAreaDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo for InputTextArea.
|
|
6
6
|
//
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
9
10
|
|
|
10
11
|
struct InputTextAreaDemo: View {
|
|
11
12
|
var body: some View {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.font(.headline)
|
|
17
|
-
|
|
18
|
-
TextAreaPreview()
|
|
19
|
-
|
|
20
|
-
// Text("Playground")
|
|
21
|
-
// .font(.headline)
|
|
22
|
-
|
|
23
|
-
// TextAreaPlayground()
|
|
24
|
-
}
|
|
25
|
-
.padding()
|
|
26
|
-
}
|
|
27
|
-
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { TextAreaPreview() }, playground: { TextAreaPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
28
17
|
}
|
|
29
18
|
}
|
|
30
19
|
}
|
|
31
20
|
|
|
32
|
-
|
|
21
|
+
// MARK: - Preview
|
|
22
|
+
|
|
23
|
+
private struct TextAreaPreview: View {
|
|
33
24
|
@State private var text = ""
|
|
34
|
-
let url = "https://img.mservice.io/momo_app_v2/new_version/img/appx_icon/momomain_momo.png"
|
|
35
|
-
|
|
25
|
+
private let url = "https://img.mservice.io/momo_app_v2/new_version/img/appx_icon/momomain_momo.png"
|
|
26
|
+
|
|
36
27
|
var body: some View {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
InputTextArea(text: .constant("Error"),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
InputTextArea(text: .constant("Error"),
|
|
49
|
-
errorSpacing: true)
|
|
50
|
-
|
|
51
|
-
Text("Disabled")
|
|
52
|
-
InputTextArea(text: .constant("Disabled"),
|
|
53
|
-
disabled: true)
|
|
28
|
+
BasicColumnBox("Floating Value", alignment: .leading) {
|
|
29
|
+
InputTextArea(text: $text, floatingValue: "Momo", floatingIcon: url, floatingIconColor: Colors.pink03)
|
|
30
|
+
}
|
|
31
|
+
BasicColumnBox("Error", alignment: .leading) {
|
|
32
|
+
InputTextArea(text: .constant("Error"), error: "Error")
|
|
33
|
+
}
|
|
34
|
+
BasicColumnBox("Error Spacing", alignment: .leading) {
|
|
35
|
+
InputTextArea(text: .constant("Error"), errorSpacing: true)
|
|
36
|
+
}
|
|
37
|
+
BasicColumnBox("Disabled", alignment: .leading) {
|
|
38
|
+
InputTextArea(text: .constant("Disabled"), disabled: true)
|
|
54
39
|
}
|
|
55
40
|
}
|
|
56
41
|
}
|
|
57
42
|
|
|
43
|
+
// MARK: - Playground
|
|
44
|
+
|
|
45
|
+
@available(iOS 16.0, *)
|
|
46
|
+
private struct TextAreaPlayground: View {
|
|
47
|
+
@State private var text = ""
|
|
48
|
+
@State private var placeholder = "Enter text"
|
|
49
|
+
@State private var floatingValue = "Label"
|
|
50
|
+
@State private var error = ""
|
|
51
|
+
@State private var maxLength = "200"
|
|
52
|
+
@State private var height: Double = 120
|
|
53
|
+
@State private var disabled = false
|
|
54
|
+
@State private var errorSpacing = false
|
|
55
|
+
@State private var loading = false
|
|
56
|
+
@State private var required = false
|
|
57
|
+
|
|
58
|
+
var body: some View {
|
|
59
|
+
PlaygroundTab(
|
|
60
|
+
component: {
|
|
61
|
+
InputTextArea(
|
|
62
|
+
text: $text,
|
|
63
|
+
maxLength: Int(maxLength) ?? 200,
|
|
64
|
+
height: CGFloat(height),
|
|
65
|
+
floatingValue: floatingValue,
|
|
66
|
+
placeholder: placeholder,
|
|
67
|
+
error: error,
|
|
68
|
+
errorSpacing: errorSpacing,
|
|
69
|
+
disabled: disabled,
|
|
70
|
+
loading: loading,
|
|
71
|
+
required: required
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
params: [
|
|
75
|
+
.string("Placeholder", $placeholder),
|
|
76
|
+
.string("FloatingValue", $floatingValue),
|
|
77
|
+
.string("Error", $error),
|
|
78
|
+
.number("MaxLength", $maxLength),
|
|
79
|
+
.slider("Height", $height, min: 60, max: 240, step: 10),
|
|
80
|
+
.checkbox("Disabled", $disabled),
|
|
81
|
+
.checkbox("ErrorSpacing", $errorSpacing),
|
|
82
|
+
.checkbox("Loading", $loading),
|
|
83
|
+
.checkbox("Required", $required),
|
|
84
|
+
]
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -2,69 +2,72 @@
|
|
|
2
2
|
// LoaderDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo for Loader / DotLoader / SpinnerLoader / ProgressBar.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import SwiftUI
|
|
9
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
private let loaderTypeList: [PlaygroundOption] = [
|
|
12
|
+
.init("dot", LoaderType.dot),
|
|
13
|
+
.init("spinner", LoaderType.spinner),
|
|
14
|
+
]
|
|
13
15
|
|
|
16
|
+
struct LoaderDemo: View {
|
|
14
17
|
var body: some View {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
row("DotLoader with tint") {
|
|
21
|
-
DotLoader(tintColor: Colors.pink03)
|
|
22
|
-
}
|
|
23
|
-
row("SpinnerLoader (default)") {
|
|
24
|
-
SpinnerLoader()
|
|
25
|
-
}
|
|
26
|
-
row("SpinnerLoader with tint") {
|
|
27
|
-
SpinnerLoader(tintColor: Colors.pink03)
|
|
28
|
-
}
|
|
29
|
-
row("Loader(type: .dot)") {
|
|
30
|
-
Loader(type: .dot)
|
|
31
|
-
}
|
|
32
|
-
row("Loader(type: .spinner)") {
|
|
33
|
-
Loader(type: .spinner, tintColor: Colors.pink03)
|
|
34
|
-
}
|
|
35
|
-
row("ProgressBar 0%") {
|
|
36
|
-
ProgressBar(percent: 0)
|
|
37
|
-
}
|
|
38
|
-
row("ProgressBar 40%") {
|
|
39
|
-
ProgressBar(percent: 40)
|
|
40
|
-
}
|
|
41
|
-
row("ProgressBar 100%") {
|
|
42
|
-
ProgressBar(percent: 100)
|
|
43
|
-
}
|
|
44
|
-
row("ProgressBar with tint (65%)") {
|
|
45
|
-
ProgressBar(percent: 65, color: Colors.pink03)
|
|
46
|
-
}
|
|
47
|
-
VStack(alignment: .leading, spacing: 8) {
|
|
48
|
-
Text("ProgressBar (interactive: \(Int(progress))%)")
|
|
49
|
-
.font(.subheadline)
|
|
50
|
-
ProgressBar(percent: progress, color: Colors.pink03)
|
|
51
|
-
Slider(value: $progress, in: 0...100)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
.padding()
|
|
18
|
+
if #available(iOS 16.0, *) {
|
|
19
|
+
DemoScreen(preview: { LoaderPreview() }, playground: { LoaderPlayground() })
|
|
20
|
+
} else {
|
|
21
|
+
Text("Requires iOS 16+").padding()
|
|
55
22
|
}
|
|
56
23
|
}
|
|
24
|
+
}
|
|
57
25
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
26
|
+
// MARK: - Preview
|
|
27
|
+
|
|
28
|
+
private struct LoaderPreview: View {
|
|
29
|
+
var body: some View {
|
|
30
|
+
BasicColumnBox("DotLoader", alignment: .leading) {
|
|
31
|
+
DotLoader()
|
|
32
|
+
DotLoader(tintColor: Colors.pink03)
|
|
33
|
+
}
|
|
34
|
+
BasicColumnBox("SpinnerLoader", alignment: .leading) {
|
|
35
|
+
SpinnerLoader()
|
|
36
|
+
SpinnerLoader(tintColor: Colors.pink03)
|
|
37
|
+
}
|
|
38
|
+
BasicColumnBox("ProgressBar", alignment: .leading) {
|
|
39
|
+
ProgressBar(percent: 0)
|
|
40
|
+
ProgressBar(percent: 40)
|
|
41
|
+
ProgressBar(percent: 100)
|
|
42
|
+
ProgressBar(percent: 65, color: Colors.pink03)
|
|
64
43
|
}
|
|
65
44
|
}
|
|
66
45
|
}
|
|
67
46
|
|
|
68
|
-
|
|
69
|
-
|
|
47
|
+
// MARK: - Playground
|
|
48
|
+
|
|
49
|
+
@available(iOS 16.0, *)
|
|
50
|
+
private struct LoaderPlayground: View {
|
|
51
|
+
@State private var type: PlaygroundOption? = loaderTypeList.first { $0.key == "dot" }
|
|
52
|
+
@State private var tint: PlaygroundOption? = playgroundColors.first { $0.key == "pink03" }
|
|
53
|
+
@State private var percent: Double = 65
|
|
54
|
+
|
|
55
|
+
var body: some View {
|
|
56
|
+
PlaygroundTab(
|
|
57
|
+
component: {
|
|
58
|
+
VStack(alignment: .leading, spacing: Spacing.L) {
|
|
59
|
+
Loader(
|
|
60
|
+
type: (type?.value as? LoaderType) ?? .dot,
|
|
61
|
+
tintColor: tint?.value as? Color
|
|
62
|
+
)
|
|
63
|
+
ProgressBar(percent: CGFloat(percent), color: tint?.value as? Color)
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
params: [
|
|
67
|
+
.radio("Type", loaderTypeList, $type),
|
|
68
|
+
.color("TintColor", playgroundColors, $tint),
|
|
69
|
+
.slider("ProgressBar percent", $percent, min: 0, max: 100, step: 1),
|
|
70
|
+
]
|
|
71
|
+
)
|
|
72
|
+
}
|
|
70
73
|
}
|
|
@@ -24,27 +24,72 @@ private let AppTranslations = LocalizationObject(
|
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
struct LocalizeDemo: View {
|
|
27
|
-
|
|
27
|
+
// AI-GENERATED START: observe the app language and drive it through the real platform API
|
|
28
|
+
@Environment(\.localize) private var localize
|
|
29
|
+
@Environment(\.applicationEnvironment) private var applicationEnvironment
|
|
30
|
+
// AI-GENERATED END: observe the app language and drive it through the real platform API
|
|
28
31
|
|
|
29
32
|
private var isEnglish: Bool { localize.currentLanguage == Localize.EN }
|
|
30
33
|
|
|
34
|
+
// AI-GENERATED START: observe the app language and drive it through the real platform API
|
|
35
|
+
private var storedLanguage: String {
|
|
36
|
+
UserDefaults.standard.string(forKey: UserDefaultsLanguageSource.defaultKey) ?? "nil"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private func setLanguage(_ language: String) {
|
|
40
|
+
// Platform API -> KMP LanguageApi.SetLanguage -> LocalizationProvider.set, which also
|
|
41
|
+
// mirrors AppleLanguages. KVO then pushes the change back into Localize. The real wire.
|
|
42
|
+
if let composeApi = applicationEnvironment.composeApi {
|
|
43
|
+
_ = composeApi.request(funcName: "setLanguage", params: language)
|
|
44
|
+
} else {
|
|
45
|
+
localize.changeLanguage(language) // #Preview / sample app: no host bridge
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// AI-GENERATED END: observe the app language and drive it through the real platform API
|
|
49
|
+
|
|
31
50
|
var body: some View {
|
|
32
51
|
ScrollView {
|
|
33
52
|
VStack(alignment: .leading, spacing: 0) {
|
|
34
53
|
|
|
35
54
|
LocalizeSectionBox(title: "Đổi ngôn ngữ (toàn app)") {
|
|
36
55
|
MomoText(
|
|
37
|
-
"
|
|
56
|
+
"Switch gọi platform API setLanguage — đổi ngôn ngữ THẬT của app. Localize observe lại "
|
|
57
|
+
+ "qua UserDefaults nên mọi màn hình đang đọc translate() đều cập nhật.",
|
|
38
58
|
typography: .descriptionDefaultRegular
|
|
39
59
|
)
|
|
40
60
|
Switch(
|
|
41
61
|
.constant(isEnglish),
|
|
42
|
-
onChange: { _ in
|
|
62
|
+
onChange: { _ in setLanguage(isEnglish ? Localize.VI : Localize.EN) },
|
|
43
63
|
title: "English"
|
|
44
64
|
)
|
|
45
65
|
MomoText("currentLanguage = \(localize.currentLanguage)", typography: .labelDefaultMedium)
|
|
46
66
|
}
|
|
47
67
|
|
|
68
|
+
// AI-GENERATED START: prove the observation loop, not kit-local state, drives updates
|
|
69
|
+
LocalizeSectionBox(title: "Nguồn thật: UserDefaults") {
|
|
70
|
+
MomoText(
|
|
71
|
+
"Ghi thẳng vào UserDefaults, bỏ qua mọi API của kit — màn hình vẫn đổi, chứng minh "
|
|
72
|
+
+ "Localize đang observe ngôn ngữ app.",
|
|
73
|
+
typography: .descriptionDefaultRegular
|
|
74
|
+
)
|
|
75
|
+
TranslationRow(key: UserDefaultsLanguageSource.defaultKey, value: storedLanguage)
|
|
76
|
+
Button(
|
|
77
|
+
title: "Ghi thẳng UserDefaults = \"en\"",
|
|
78
|
+
action: {
|
|
79
|
+
// Quoted on purpose: proves normalize() strips the JSON quoting
|
|
80
|
+
// RN and KMP persist.
|
|
81
|
+
UserDefaults.standard.set(
|
|
82
|
+
"\"en\"",
|
|
83
|
+
forKey: UserDefaultsLanguageSource.defaultKey
|
|
84
|
+
)
|
|
85
|
+
},
|
|
86
|
+
type: .outline,
|
|
87
|
+
size: .medium,
|
|
88
|
+
isFull: false
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
// AI-GENERATED END: prove the observation loop, not kit-local state, drives updates
|
|
92
|
+
|
|
48
93
|
LocalizeSectionBox(title: "translate(key) — từ điển mặc định của kit") {
|
|
49
94
|
TranslationRow(key: "confirm", value: localize.translate("confirm"))
|
|
50
95
|
TranslationRow(key: "cancel", value: localize.translate("cancel"))
|
|
@@ -179,8 +224,10 @@ private struct TranslationRow: View {
|
|
|
179
224
|
#Preview {
|
|
180
225
|
if #available(iOS 16.0, *) {
|
|
181
226
|
NavigationStack {
|
|
227
|
+
// AI-GENERATED START: preview needs the observing provider or the toggle will not update
|
|
182
228
|
LocalizeDemo()
|
|
183
|
-
.
|
|
229
|
+
.momoLocalize(Localize())
|
|
230
|
+
// AI-GENERATED END: preview needs the observing provider or the toggle will not update
|
|
184
231
|
}
|
|
185
232
|
} else {
|
|
186
233
|
// Fallback on earlier versions
|
|
@@ -101,9 +101,21 @@ private struct NavigationDemoContent: View {
|
|
|
101
101
|
|
|
102
102
|
Divider().padding(.vertical, 4)
|
|
103
103
|
|
|
104
|
+
row("Custom Back Handler") {
|
|
105
|
+
// The screen owns back: the header button and the edge swipe both
|
|
106
|
+
// run this instead of popping (mirrors Compose's onBackHandler).
|
|
107
|
+
navigator.push(
|
|
108
|
+
{ DemoLeafScreen(title: "Back is intercepted — swipe from the edge", color: Colors.blue09) },
|
|
109
|
+
options: NavigationOptions(
|
|
110
|
+
title: "Custom Back",
|
|
111
|
+
onBackHandler: { print("back intercepted") }
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
row("Prevent Back") {
|
|
105
|
-
//
|
|
106
|
-
// leaving (mirrors Compose's headerBackProps.preventBack).
|
|
117
|
+
// The header back button and the edge swipe both show a confirm popup
|
|
118
|
+
// before leaving (mirrors Compose's headerBackProps.preventBack).
|
|
107
119
|
navigator.push(
|
|
108
120
|
{ DemoLeafScreen(title: "Tap the header back button", color: Colors.pink09) },
|
|
109
121
|
options: NavigationOptions(
|
|
@@ -2,71 +2,67 @@
|
|
|
2
2
|
// PaginationDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
// Mirrors shared PaginationUsage.kt: a configurable Data Length plus
|
|
7
|
-
// Prev/Next controls drive PaginationScroll, PaginationNumber,
|
|
8
|
-
// PaginationDot and PaginationWhiteDot.
|
|
5
|
+
// Preview + Playground demo for the pagination variants.
|
|
9
6
|
//
|
|
10
7
|
|
|
11
8
|
import MoMoUIKits
|
|
12
9
|
import SwiftUI
|
|
13
10
|
|
|
14
11
|
struct PaginationDemo: View {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { PaginationPreview() }, playground: { PaginationPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
21
18
|
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MARK: - Preview
|
|
22
22
|
|
|
23
|
+
private struct PaginationPreview: View {
|
|
23
24
|
var body: some View {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.overlay(
|
|
32
|
-
Rectangle().stroke(Colors.black06, lineWidth: 1)
|
|
33
|
-
)
|
|
34
|
-
}
|
|
25
|
+
BasicColumnBox("PaginationScroll", alignment: .leading) {
|
|
26
|
+
PaginationScroll {
|
|
27
|
+
ForEach(0..<10, id: \.self) { i in
|
|
28
|
+
MomoText("\(i)", typography: .bodyDefaultRegular)
|
|
29
|
+
.frame(width: 120, height: 60)
|
|
30
|
+
.background(Colors.blue08)
|
|
31
|
+
.overlay(Rectangle().stroke(Colors.black06, lineWidth: 1))
|
|
35
32
|
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
BasicColumnBox("Number / Dot", alignment: .leading) {
|
|
36
|
+
PaginationNumber(activeIndex: 1, dataLength: 3)
|
|
37
|
+
PaginationDot(activeIndex: 1, dataLength: 3)
|
|
38
|
+
}
|
|
39
|
+
BasicColumnBox("WhiteDot", alignment: .leading, background: Colors.black17) {
|
|
40
|
+
PaginationWhiteDot(activeIndex: 1, dataLength: 3)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
PaginationDot(activeIndex: activeIndex, dataLength: dataLength)
|
|
40
|
-
|
|
41
|
-
PaginationWhiteDot(activeIndex: activeIndex, dataLength: dataLength)
|
|
42
|
-
.padding(Spacing.S)
|
|
43
|
-
.background(Colors.black17) // dark backdrop so white dots are visible
|
|
45
|
+
// MARK: - Playground
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.onChange(of: dataLengthText) { _ in activeIndex = 0 }
|
|
50
|
-
.frame(maxWidth: 200)
|
|
47
|
+
@available(iOS 16.0, *)
|
|
48
|
+
private struct PaginationPlayground: View {
|
|
49
|
+
@State private var dataLength = "5"
|
|
50
|
+
@State private var activeIndex: Double = 0
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
Button("Prev") {
|
|
54
|
-
if activeIndex != 0 { activeIndex -= 1 }
|
|
55
|
-
}
|
|
56
|
-
.frame(maxWidth: .infinity)
|
|
52
|
+
private var length: Int { max(Int(dataLength) ?? 1, 1) }
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
var body: some View {
|
|
55
|
+
PlaygroundTab(
|
|
56
|
+
component: {
|
|
57
|
+
VStack(alignment: .leading, spacing: Spacing.L) {
|
|
58
|
+
PaginationNumber(activeIndex: Int(activeIndex), dataLength: length)
|
|
59
|
+
PaginationDot(activeIndex: Int(activeIndex), dataLength: length)
|
|
62
60
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
},
|
|
62
|
+
params: [
|
|
63
|
+
.number("DataLength", $dataLength),
|
|
64
|
+
.slider("ActiveIndex", $activeIndex, min: 0, max: 9, step: 1),
|
|
65
|
+
]
|
|
66
|
+
)
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
#Preview {
|
|
71
|
-
PaginationDemo()
|
|
72
|
-
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PlaygroundData.swift
|
|
3
|
+
// Example
|
|
4
|
+
//
|
|
5
|
+
// Swift equivalents of the option maps in Compose's DemoScreen.kt (buttonTypeList,
|
|
6
|
+
// sizeList, Icons, Colors.colorList, ...). Each list feeds an OPTION / RADIO / COLOR
|
|
7
|
+
// PlaygroundParams. Extend as more demos are converted.
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
import MoMoUIKits
|
|
11
|
+
import SwiftUI
|
|
12
|
+
|
|
13
|
+
// MARK: - Enum option maps
|
|
14
|
+
|
|
15
|
+
let buttonTypeList: [PlaygroundOption] = [
|
|
16
|
+
.init("primary", ButtonType.primary),
|
|
17
|
+
.init("secondary", ButtonType.secondary),
|
|
18
|
+
.init("tonal", ButtonType.tonal),
|
|
19
|
+
.init("outline", ButtonType.outline),
|
|
20
|
+
.init("danger", ButtonType.danger),
|
|
21
|
+
.init("text", ButtonType.text),
|
|
22
|
+
.init("disabled", ButtonType.disabled),
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
let buttonSizeList: [PlaygroundOption] = [
|
|
26
|
+
.init("large", ButtonSize.large),
|
|
27
|
+
.init("medium", ButtonSize.medium),
|
|
28
|
+
.init("small", ButtonSize.small),
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
let inputSizeList: [PlaygroundOption] = [
|
|
32
|
+
.init("large", InputSize.large),
|
|
33
|
+
.init("small", InputSize.small),
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
let inputFontWeightList: [PlaygroundOption] = [
|
|
37
|
+
.init("regular", InputFontWeight.regular),
|
|
38
|
+
.init("bold", InputFontWeight.bold),
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
let keyboardTypeList: [PlaygroundOption] = [
|
|
42
|
+
.init("default", UIKeyboardType.default),
|
|
43
|
+
.init("asciiCapable", UIKeyboardType.asciiCapable),
|
|
44
|
+
.init("numberPad", UIKeyboardType.numberPad),
|
|
45
|
+
.init("phonePad", UIKeyboardType.phonePad),
|
|
46
|
+
.init("URL", UIKeyboardType.URL),
|
|
47
|
+
.init("emailAddress", UIKeyboardType.emailAddress),
|
|
48
|
+
.init("decimalPad", UIKeyboardType.decimalPad),
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
// MARK: - Icons (curated from icon.json; Compose `Icons`)
|
|
52
|
+
|
|
53
|
+
let playgroundIcons: [PlaygroundOption] = [
|
|
54
|
+
"basic_home", "basic_flag", "basic_filter", "basic_delete", "basic_copy",
|
|
55
|
+
"basic_account", "basic_chart", "basic_setting", "basic_sun", "basic_person",
|
|
56
|
+
"basic_person_add", "basic_person_group", "basic_options", "basic_sorting",
|
|
57
|
+
"arrow_chevron_down", "arrow_chevron_up", "arrow_chevron_left", "arrow_chevron_right",
|
|
58
|
+
"arrow_arrow_forward", "arrow_redo", "arrow_undo", "arrow_refresh_ccw",
|
|
59
|
+
"security_eye_open", "notifications_check_circle", "help_center", "pin_star",
|
|
60
|
+
"navigation_more_icon",
|
|
61
|
+
].map { PlaygroundOption($0, $0) }
|
|
62
|
+
|
|
63
|
+
// MARK: - Colors (Compose `Colors.colorList`)
|
|
64
|
+
|
|
65
|
+
let playgroundColors: [PlaygroundOption] = [
|
|
66
|
+
.init("primary", Colors.primary),
|
|
67
|
+
.init("black17", Colors.black17),
|
|
68
|
+
.init("black13", Colors.black13),
|
|
69
|
+
.init("black10", Colors.black10),
|
|
70
|
+
.init("black05", Colors.black05),
|
|
71
|
+
.init("black01", Colors.black01),
|
|
72
|
+
.init("pink06", Colors.pink06),
|
|
73
|
+
.init("pink03", Colors.pink03),
|
|
74
|
+
.init("blue09", Colors.blue09),
|
|
75
|
+
.init("blue05", Colors.blue05),
|
|
76
|
+
]
|