@momo-kits/native-kits 0.162.30-debug → 0.162.31-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +19 -0
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/gradle.properties +1 -1
- 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,88 +2,100 @@
|
|
|
2
2
|
// ProgressInfoDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
+
// Preview + Playground demo, mirroring Compose's ProgressInfoUsage.kt.
|
|
6
|
+
//
|
|
5
7
|
|
|
6
|
-
import SwiftUI
|
|
7
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ProgressInfoItem(title: "Bước 2", description: "Mô tả bước thứ hai"),
|
|
15
|
-
ProgressInfoItem(title: "Bước 3", description: "Mô tả bước thứ ba"),
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
private let sampleStepsNoDesc = [
|
|
19
|
-
ProgressInfoItem(title: "Đăng ký"),
|
|
20
|
-
ProgressInfoItem(title: "Xác minh"),
|
|
21
|
-
ProgressInfoItem(title: "Hoàn tất"),
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
var body: some View {
|
|
25
|
-
ScrollView {
|
|
26
|
-
VStack(alignment: .leading, spacing: 24) {
|
|
27
|
-
section("Vertical (default)") {
|
|
28
|
-
ProgressInfo(steps: sampleSteps)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
section("Vertical – no description") {
|
|
32
|
-
ProgressInfo(steps: sampleStepsNoDesc, showDescription: false)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
section("Vertical – useNumber") {
|
|
36
|
-
ProgressInfo(steps: sampleSteps, useNumber: true)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
section("Vertical – Small size") {
|
|
40
|
-
ProgressInfo(steps: sampleSteps, size: .small)
|
|
41
|
-
}
|
|
11
|
+
private let piSteps = [
|
|
12
|
+
ProgressInfoItem(title: "Bước 1", description: "Mô tả bước đầu tiên"),
|
|
13
|
+
ProgressInfoItem(title: "Bước 2", description: "Mô tả bước thứ hai"),
|
|
14
|
+
ProgressInfoItem(title: "Bước 3", description: "Mô tả bước thứ ba"),
|
|
15
|
+
]
|
|
42
16
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
17
|
+
private let piStepsNoDesc = [
|
|
18
|
+
ProgressInfoItem(title: "Đăng ký"),
|
|
19
|
+
ProgressInfoItem(title: "Xác minh"),
|
|
20
|
+
ProgressInfoItem(title: "Hoàn tất"),
|
|
21
|
+
]
|
|
46
22
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
23
|
+
private let progressInfoSizeList: [PlaygroundOption] = [
|
|
24
|
+
.init("large", ProgressInfoSize.large),
|
|
25
|
+
.init("small", ProgressInfoSize.small),
|
|
26
|
+
]
|
|
50
27
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
private let progressInfoAlignList: [PlaygroundOption] = [
|
|
29
|
+
.init("center", ProgressInfoAlign.center),
|
|
30
|
+
.init("left", ProgressInfoAlign.left),
|
|
31
|
+
.init("right", ProgressInfoAlign.right),
|
|
32
|
+
.init("stretch", ProgressInfoAlign.stretch),
|
|
33
|
+
]
|
|
54
34
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
struct ProgressInfoDemo: View {
|
|
36
|
+
var body: some View {
|
|
37
|
+
if #available(iOS 16.0, *) {
|
|
38
|
+
DemoScreen(preview: { ProgressInfoPreview() }, playground: { ProgressInfoPlayground() })
|
|
39
|
+
} else {
|
|
40
|
+
Text("Requires iOS 16+").padding()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
58
44
|
|
|
59
|
-
|
|
60
|
-
ProgressInfo(steps: sampleSteps, horizontal: true, useNumber: true)
|
|
61
|
-
}
|
|
45
|
+
// MARK: - Preview
|
|
62
46
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
47
|
+
private struct ProgressInfoPreview: View {
|
|
48
|
+
var body: some View {
|
|
49
|
+
BasicColumnBox("Vertical (default)", alignment: .leading) {
|
|
50
|
+
ProgressInfo(steps: piSteps)
|
|
51
|
+
}
|
|
52
|
+
BasicColumnBox("Vertical – no description", alignment: .leading) {
|
|
53
|
+
ProgressInfo(steps: piStepsNoDesc, showDescription: false)
|
|
54
|
+
}
|
|
55
|
+
BasicColumnBox("Vertical – useNumber", alignment: .leading) {
|
|
56
|
+
ProgressInfo(steps: piSteps, useNumber: true)
|
|
57
|
+
}
|
|
58
|
+
BasicColumnBox("Horizontal – Center", alignment: .leading) {
|
|
59
|
+
ProgressInfo(steps: piSteps, horizontal: true)
|
|
60
|
+
}
|
|
61
|
+
BasicColumnBox("Horizontal – useNumber", alignment: .leading) {
|
|
62
|
+
ProgressInfo(steps: piSteps, horizontal: true, useNumber: true)
|
|
73
63
|
}
|
|
74
64
|
}
|
|
65
|
+
}
|
|
75
66
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
67
|
+
// MARK: - Playground
|
|
68
|
+
|
|
69
|
+
@available(iOS 16.0, *)
|
|
70
|
+
private struct ProgressInfoPlayground: View {
|
|
71
|
+
@State private var size: PlaygroundOption? = progressInfoSizeList.first { $0.key == "large" }
|
|
72
|
+
@State private var align: PlaygroundOption? = progressInfoAlignList.first { $0.key == "center" }
|
|
73
|
+
@State private var horizontal = false
|
|
74
|
+
@State private var useNumber = false
|
|
75
|
+
@State private var showTitle = true
|
|
76
|
+
@State private var showDescription = true
|
|
77
|
+
|
|
78
|
+
var body: some View {
|
|
79
|
+
PlaygroundTab(
|
|
80
|
+
component: {
|
|
81
|
+
ProgressInfo(
|
|
82
|
+
steps: piSteps,
|
|
83
|
+
horizontal: horizontal,
|
|
84
|
+
size: (size?.value as? ProgressInfoSize) ?? .large,
|
|
85
|
+
useNumber: useNumber,
|
|
86
|
+
align: (align?.value as? ProgressInfoAlign) ?? .center,
|
|
87
|
+
showTitle: showTitle,
|
|
88
|
+
showDescription: showDescription
|
|
89
|
+
)
|
|
90
|
+
},
|
|
91
|
+
params: [
|
|
92
|
+
.radio("Size", progressInfoSizeList, $size),
|
|
93
|
+
.radio("Align", progressInfoAlignList, $align),
|
|
94
|
+
.checkbox("Horizontal", $horizontal),
|
|
95
|
+
.checkbox("UseNumber", $useNumber),
|
|
96
|
+
.checkbox("ShowTitle", $showTitle),
|
|
97
|
+
.checkbox("ShowDescription", $showDescription),
|
|
98
|
+
]
|
|
99
|
+
)
|
|
88
100
|
}
|
|
89
101
|
}
|
|
@@ -1,32 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
//
|
|
2
|
+
// RadioDemo.swift
|
|
3
|
+
// Example
|
|
4
|
+
//
|
|
5
|
+
// Preview + Playground demo for Radio.
|
|
6
|
+
//
|
|
7
|
+
|
|
2
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
3
10
|
|
|
4
11
|
struct RadioDemo: View {
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { RadioPreview() }, playground: { RadioPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MARK: - Preview
|
|
22
|
+
|
|
23
|
+
private struct RadioPreview: View {
|
|
5
24
|
@State private var group: AnyHashable = 1
|
|
6
25
|
|
|
7
26
|
var body: some View {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Text("Value").font(.description1)
|
|
12
|
-
Radio(value: 1, groupValue: $group)
|
|
13
|
-
Radio(value: 2, groupValue: $group)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Disabled
|
|
17
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
18
|
-
Text("Disabled").font(.description1)
|
|
19
|
-
Radio(value: 1, groupValue: .constant(1), disabled: true)
|
|
20
|
-
Radio(value: 2, groupValue: .constant(1), disabled: false)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Label
|
|
24
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
25
|
-
Text("Label").font(.description1)
|
|
26
|
-
Radio(value: 1, groupValue: .constant(1), label: "Label")
|
|
27
|
-
Radio(value: 2, groupValue: .constant(1), label: "Label")
|
|
28
|
-
}
|
|
27
|
+
BasicColumnBox("Value", alignment: .leading) {
|
|
28
|
+
Radio(value: 1, groupValue: $group)
|
|
29
|
+
Radio(value: 2, groupValue: $group)
|
|
29
30
|
}
|
|
30
|
-
.
|
|
31
|
+
BasicColumnBox("Disabled", alignment: .leading) {
|
|
32
|
+
Radio(value: 1, groupValue: .constant(1), disabled: true)
|
|
33
|
+
Radio(value: 2, groupValue: .constant(1), disabled: false)
|
|
34
|
+
}
|
|
35
|
+
BasicColumnBox("Label", alignment: .leading) {
|
|
36
|
+
Radio(value: 1, groupValue: .constant(1), label: "Label")
|
|
37
|
+
Radio(value: 2, groupValue: .constant(1), label: "Label")
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// MARK: - Playground
|
|
43
|
+
|
|
44
|
+
@available(iOS 16.0, *)
|
|
45
|
+
private struct RadioPlayground: View {
|
|
46
|
+
@State private var group: AnyHashable = 1
|
|
47
|
+
@State private var label = "Label"
|
|
48
|
+
@State private var disabled = false
|
|
49
|
+
|
|
50
|
+
var body: some View {
|
|
51
|
+
PlaygroundTab(
|
|
52
|
+
component: {
|
|
53
|
+
VStack(alignment: .leading, spacing: Spacing.S) {
|
|
54
|
+
Radio(value: 1, groupValue: $group, disabled: disabled, label: label)
|
|
55
|
+
Radio(value: 2, groupValue: $group, disabled: disabled, label: label)
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
params: [
|
|
59
|
+
.string("Label", $label),
|
|
60
|
+
.checkbox("Disabled", $disabled),
|
|
61
|
+
]
|
|
62
|
+
)
|
|
31
63
|
}
|
|
32
64
|
}
|
|
@@ -1,56 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
//
|
|
2
|
+
// RatingDemo.swift
|
|
3
|
+
// Example
|
|
4
|
+
//
|
|
5
|
+
// Preview + Playground demo for Rating.
|
|
6
|
+
//
|
|
7
|
+
|
|
2
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
private let ratingSizeList: [PlaygroundOption] = [
|
|
12
|
+
.init("small", RatingSize.small),
|
|
13
|
+
.init("medium", RatingSize.medium),
|
|
14
|
+
.init("large", RatingSize.large),
|
|
15
|
+
]
|
|
6
16
|
|
|
17
|
+
struct RatingDemo: View {
|
|
7
18
|
var body: some View {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Rating(numOfStars: 5, rating: 3, size: .medium)
|
|
13
|
-
Rating(numOfStars: 5, rating: 3, size: .large)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
section("Half star") {
|
|
17
|
-
Rating(numOfStars: 5, rating: 3.5)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
section("Full") {
|
|
21
|
-
Rating(numOfStars: 5, rating: 5)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
section("Empty") {
|
|
25
|
-
Rating(numOfStars: 5, rating: 0)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
section("Read-only (no callback)") {
|
|
29
|
-
Rating(numOfStars: 5, rating: 4)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
section("Interactive") {
|
|
33
|
-
Rating(
|
|
34
|
-
numOfStars: 5,
|
|
35
|
-
rating: interactiveRating,
|
|
36
|
-
onRatingChange: { newRating in
|
|
37
|
-
interactiveRating = Float(newRating)
|
|
38
|
-
}
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
.padding()
|
|
19
|
+
if #available(iOS 16.0, *) {
|
|
20
|
+
DemoScreen(preview: { RatingPreview() }, playground: { RatingPlayground() })
|
|
21
|
+
} else {
|
|
22
|
+
Text("Requires iOS 16+").padding()
|
|
43
23
|
}
|
|
44
24
|
}
|
|
25
|
+
}
|
|
45
26
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
// MARK: - Preview
|
|
28
|
+
|
|
29
|
+
private struct RatingPreview: View {
|
|
30
|
+
var body: some View {
|
|
31
|
+
BasicColumnBox("Size", alignment: .leading) {
|
|
32
|
+
Rating(numOfStars: 5, rating: 3, size: .small)
|
|
33
|
+
Rating(numOfStars: 5, rating: 3, size: .medium)
|
|
34
|
+
Rating(numOfStars: 5, rating: 3, size: .large)
|
|
54
35
|
}
|
|
36
|
+
BasicColumnBox("Values", alignment: .leading) {
|
|
37
|
+
Rating(numOfStars: 5, rating: 3.5)
|
|
38
|
+
Rating(numOfStars: 5, rating: 5)
|
|
39
|
+
Rating(numOfStars: 5, rating: 0)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// MARK: - Playground
|
|
45
|
+
|
|
46
|
+
@available(iOS 16.0, *)
|
|
47
|
+
private struct RatingPlayground: View {
|
|
48
|
+
@State private var stars: Double = 5
|
|
49
|
+
@State private var rating: Double = 3
|
|
50
|
+
@State private var size: PlaygroundOption? = ratingSizeList.first { $0.key == "large" }
|
|
51
|
+
|
|
52
|
+
var body: some View {
|
|
53
|
+
PlaygroundTab(
|
|
54
|
+
component: {
|
|
55
|
+
Rating(
|
|
56
|
+
numOfStars: Int(stars),
|
|
57
|
+
rating: Float(rating),
|
|
58
|
+
size: (size?.value as? RatingSize) ?? .large
|
|
59
|
+
)
|
|
60
|
+
},
|
|
61
|
+
params: [
|
|
62
|
+
.slider("NumOfStars", $stars, min: 1, max: 10, step: 1),
|
|
63
|
+
.slider("Rating", $rating, min: 0, max: 10, step: 0.5),
|
|
64
|
+
.radio("Size", ratingSizeList, $size),
|
|
65
|
+
]
|
|
66
|
+
)
|
|
55
67
|
}
|
|
56
68
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// SectionDemo.swift
|
|
3
|
+
// Example
|
|
4
|
+
//
|
|
5
|
+
// Preview + Playground demo for SectionView / ItemView (12-column grid).
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
10
|
+
|
|
11
|
+
struct SectionDemo: View {
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { SectionPreview() }, playground: { SectionPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MARK: - Preview
|
|
22
|
+
|
|
23
|
+
private struct SectionPreview: View {
|
|
24
|
+
var body: some View {
|
|
25
|
+
BasicColumnBox("Full width — span 12", alignment: .leading) {
|
|
26
|
+
SectionView { SectionTile("12") }
|
|
27
|
+
}
|
|
28
|
+
BasicColumnBox("Even splits", alignment: .leading) {
|
|
29
|
+
SectionView {
|
|
30
|
+
ItemView(widthSpan: 6) { SectionTile("6") }
|
|
31
|
+
ItemView(widthSpan: 6) { SectionTile("6") }
|
|
32
|
+
ItemView(widthSpan: 4) { SectionTile("4") }
|
|
33
|
+
ItemView(widthSpan: 4) { SectionTile("4") }
|
|
34
|
+
ItemView(widthSpan: 4) { SectionTile("4") }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
BasicColumnBox("heightSpan — square tiles", alignment: .leading) {
|
|
38
|
+
SectionView {
|
|
39
|
+
ItemView(widthSpan: 3, heightSpan: 3) { SectionTile("3×3") }
|
|
40
|
+
ItemView(widthSpan: 3, heightSpan: 3) { SectionTile("3×3") }
|
|
41
|
+
ItemView(widthSpan: 6, heightSpan: 3) { SectionTile("6×3") }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// MARK: - Playground
|
|
48
|
+
|
|
49
|
+
@available(iOS 16.0, *)
|
|
50
|
+
private struct SectionPlayground: View {
|
|
51
|
+
@State private var span: Double = 6
|
|
52
|
+
@State private var useMargin = true
|
|
53
|
+
|
|
54
|
+
var body: some View {
|
|
55
|
+
PlaygroundTab(
|
|
56
|
+
component: {
|
|
57
|
+
SectionView(useMargin: useMargin) {
|
|
58
|
+
ItemView(widthSpan: Int(span)) { SectionTile("\(Int(span))") }
|
|
59
|
+
ItemView(widthSpan: 12 - Int(span)) { SectionTile("\(12 - Int(span))") }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
params: [
|
|
63
|
+
.slider("Left widthSpan", $span, min: 1, max: 11, step: 1),
|
|
64
|
+
.checkbox("useMargin", $useMargin),
|
|
65
|
+
]
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// Filled placeholder so span widths are visible.
|
|
71
|
+
private struct SectionTile: View {
|
|
72
|
+
let label: String
|
|
73
|
+
init(_ label: String) { self.label = label }
|
|
74
|
+
|
|
75
|
+
var body: some View {
|
|
76
|
+
Text(label)
|
|
77
|
+
.font(.footnote)
|
|
78
|
+
.foregroundColor(Colors.black17)
|
|
79
|
+
.frame(maxWidth: .infinity, minHeight: 44, maxHeight: .infinity)
|
|
80
|
+
.background(Colors.blue08)
|
|
81
|
+
.clipShape(RoundedRectangle(cornerRadius: Radius.S, style: .continuous))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -2,31 +2,60 @@
|
|
|
2
2
|
// SkeletonDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
+
// Preview + Playground demo (DemoScreen pattern).
|
|
6
|
+
//
|
|
5
7
|
|
|
6
|
-
import SwiftUI
|
|
7
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
struct SkeletonDemo: View {
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { SkeletonPreview() }, playground: { SkeletonPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
|
|
12
|
-
|
|
13
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
14
|
-
Spacer().frame(height: 12)
|
|
21
|
+
// MARK: - Preview
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
private struct SkeletonPreview: View {
|
|
24
|
+
var body: some View {
|
|
25
|
+
BasicColumnBox("Square (aspect 1:1)", alignment: .leading) {
|
|
17
26
|
Skeleton()
|
|
18
27
|
.aspectRatio(1, contentMode: .fit)
|
|
19
28
|
.frame(maxWidth: .infinity)
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
}
|
|
30
|
+
BasicColumnBox("Fixed height (32)", alignment: .leading) {
|
|
22
31
|
Skeleton()
|
|
23
32
|
.frame(maxWidth: .infinity)
|
|
24
33
|
.frame(height: 32)
|
|
25
34
|
}
|
|
26
|
-
.
|
|
35
|
+
BasicColumnBox("Lines", alignment: .leading) {
|
|
36
|
+
Skeleton().frame(maxWidth: .infinity).frame(height: 16)
|
|
37
|
+
Skeleton().frame(maxWidth: .infinity).frame(height: 16)
|
|
38
|
+
Skeleton().frame(width: 160).frame(height: 16)
|
|
39
|
+
}
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
// MARK: - Playground
|
|
44
|
+
|
|
45
|
+
@available(iOS 16.0, *)
|
|
46
|
+
private struct SkeletonPlayground: View {
|
|
47
|
+
@State private var height: Double = 32
|
|
48
|
+
|
|
49
|
+
var body: some View {
|
|
50
|
+
PlaygroundTab(
|
|
51
|
+
component: {
|
|
52
|
+
Skeleton()
|
|
53
|
+
.frame(maxWidth: .infinity)
|
|
54
|
+
.frame(height: CGFloat(height))
|
|
55
|
+
},
|
|
56
|
+
params: [
|
|
57
|
+
.slider("Height", $height, min: 16, max: 200, step: 4),
|
|
58
|
+
]
|
|
59
|
+
)
|
|
60
|
+
}
|
|
32
61
|
}
|