@momo-kits/native-kits 0.162.2-beta.26-debug → 0.162.2-beta.27-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 +1 -1
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +55 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +2 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +75 -93
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +0 -11
- package/ios/Application/Components.swift +44 -34
- package/ios/Application/FloatingButton.swift +9 -10
- package/ios/Application/HeaderRight.swift +45 -79
- package/ios/Application/Screen.swift +1 -2
- package/ios/Badge/Badge.swift +14 -11
- package/ios/Badge/BadgeRibbon.swift +21 -12
- package/ios/Button/Button.swift +22 -61
- package/ios/Checkbox/Checkbox.swift +13 -14
- package/ios/Chip/Chip.swift +9 -23
- package/ios/Colors+Radius+Spacing/Colors.swift +12 -12
- package/ios/Extensions/Color++.swift +0 -32
- package/ios/Icon/Icon.swift +1 -6
- package/ios/Input/Input.swift +25 -41
- package/ios/Input/InputPhoneNumber.swift +19 -20
- package/ios/Input/InputSearch.swift +47 -100
- package/ios/Input/InputTextArea.swift +40 -66
- package/ios/Popup/PopupDisplay.swift +16 -8
- package/ios/Popup/PopupInput.swift +8 -2
- package/ios/Swipeable/SwipeCell.swift +0 -185
- package/ios/Swipeable/SwipeCellModel.swift +0 -21
- package/ios/Typography/Text.swift +5 -79
- package/ios/Typography/Typography.swift +0 -3
- package/ios/native-kits.podspec +8 -61
- package/package.json +1 -1
- package/publish.sh +0 -50
- package/.claude/settings.local.json +0 -39
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +0 -103
- package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +0 -215
- package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +0 -65
- package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
- package/ios/Application/Navigation/HeaderTitle.swift +0 -57
- package/ios/Application/Navigation/HeaderUser.swift +0 -209
- package/ios/Application/Navigation/NavigationContainer.swift +0 -176
- package/ios/Application/Navigation/NavigationOptions.swift +0 -109
- package/ios/Application/Navigation/Navigator.swift +0 -364
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +0 -188
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +0 -68
- package/ios/Application/Navigation/Overplay/SnackBar.swift +0 -144
- package/ios/Application/Navigation/component/Header.swift +0 -178
- package/ios/Application/Navigation/component/HeaderBackground.swift +0 -83
- package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
- package/ios/Application/StackScreen.swift +0 -453
- package/ios/Avatar/Avatar.swift +0 -193
- package/ios/BaselineView/BaselineView.swift +0 -163
- package/ios/Carousel/Carousel.swift +0 -181
- package/ios/Collapse/Collapse.swift +0 -182
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -295
- package/ios/DateTimePicker/DateTimePicker.swift +0 -210
- package/ios/DateTimePicker/DateTimePickerTypes.swift +0 -55
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -167
- package/ios/DateTimePicker/WheelPicker.swift +0 -161
- package/ios/Divider/Divider.swift +0 -16
- package/ios/IconButton/IconButton.swift +0 -112
- package/ios/InputDropDown/InputDropDown.swift +0 -198
- package/ios/InputMoney/InputMoney.swift +0 -335
- package/ios/InputOTP/InputOTP.swift +0 -210
- package/ios/Loader/Loader.swift +0 -113
- package/ios/MoMoUIKits.podspec +0 -5
- package/ios/Pagination/PaginationDot.swift +0 -61
- package/ios/Pagination/PaginationNumber.swift +0 -35
- package/ios/Pagination/PaginationScroll.swift +0 -101
- package/ios/Pagination/PaginationWhiteDot.swift +0 -37
- package/ios/Popup/PopupNotify.swift +0 -219
- package/ios/ProgressInfo/ProgressInfo.swift +0 -294
- package/ios/Radio/Radio.swift +0 -70
- package/ios/Rating/Rating.swift +0 -82
- package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +0 -11
- package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +0 -6
- package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +0 -9
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +0 -38
- package/ios/Skeleton/Skeleton.swift +0 -99
- package/ios/Slider/Slider.swift +0 -237
- package/ios/Stepper/Stepper.swift +0 -220
- package/ios/Steps/Steps.swift +0 -451
- package/ios/SuggestAction/SuggestAction.swift +0 -97
- package/ios/TabView/TabView.swift +0 -530
- package/ios/Tag/Tag.swift +0 -98
- package/ios/Title/Title.swift +0 -269
- package/ios/Tooltip/Tooltip.swift +0 -482
- package/ios/Typography/FontScaleStore.swift +0 -19
- package/ios/Uploader/Uploader.swift +0 -183
- package/ios-demo/MoMoUIKitsDemo.podspec +0 -20
- package/ios-demo/README.md +0 -120
- package/ios-demo/Resources/dot_loading.json +0 -558
- package/ios-demo/Resources/icon.json +0 -4052
- package/ios-demo/Resources/lottie_circle_loader.json +0 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +0 -48
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +0 -25
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +0 -26
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +0 -19
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +0 -33
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +0 -48
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +0 -21
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +0 -17
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +0 -28
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +0 -31
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +0 -24
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +0 -110
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +0 -93
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +0 -269
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +0 -117
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +0 -89
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +0 -100
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +0 -126
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +0 -63
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +0 -20
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +0 -93
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +0 -107
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +0 -124
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +0 -14
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +0 -49
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -278
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +0 -58
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +0 -78
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +0 -138
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +0 -111
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +0 -136
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +0 -107
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +0 -73
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +0 -100
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +0 -32
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +0 -57
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +0 -70
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -227
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +0 -72
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +0 -175
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +0 -121
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +0 -76
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +0 -89
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +0 -32
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +0 -56
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +0 -32
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +0 -150
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +0 -138
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +0 -103
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +0 -94
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +0 -79
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +0 -152
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +0 -33
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +0 -190
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +0 -34
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +0 -182
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +0 -109
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +0 -187
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +0 -87
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +0 -131
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +0 -51
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +0 -15
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +0 -73
- package/local.properties +0 -8
- package/scripts/gen-ios-color.mjs +0 -136
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
import MoMoUIKits
|
|
3
|
-
|
|
4
|
-
struct SuggestActionDemo: View {
|
|
5
|
-
@State private var visible1 = true
|
|
6
|
-
@State private var visible2 = true
|
|
7
|
-
@State private var visible3 = true
|
|
8
|
-
@State private var visible4 = true
|
|
9
|
-
|
|
10
|
-
var body: some View {
|
|
11
|
-
ScrollView {
|
|
12
|
-
VStack(alignment: .leading, spacing: 24) {
|
|
13
|
-
section("Default") {
|
|
14
|
-
SuggestAction(
|
|
15
|
-
message: "You have a new suggestion available for you.",
|
|
16
|
-
buttonTitle: "View",
|
|
17
|
-
visible: visible1,
|
|
18
|
-
onClose: { visible1 = false },
|
|
19
|
-
onPressButton: { visible1 = false }
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
section("With bold message") {
|
|
24
|
-
SuggestAction(
|
|
25
|
-
message: "You have a new suggestion available for you.",
|
|
26
|
-
buttonTitle: "View",
|
|
27
|
-
boldMessage: "new suggestion",
|
|
28
|
-
visible: visible2,
|
|
29
|
-
onClose: { visible2 = false },
|
|
30
|
-
onPressButton: { visible2 = false }
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
section("With image") {
|
|
35
|
-
SuggestAction(
|
|
36
|
-
message: "Complete your profile to unlock more features.",
|
|
37
|
-
buttonTitle: "Go",
|
|
38
|
-
boldMessage: "Complete",
|
|
39
|
-
image: "https://static.momocdn.net/app/img/kits/trustBanner/ic_secu.png",
|
|
40
|
-
visible: visible3,
|
|
41
|
-
onClose: { visible3 = false },
|
|
42
|
-
onPressButton: { visible3 = false }
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
section("Short message") {
|
|
47
|
-
SuggestAction(
|
|
48
|
-
message: "Update available.",
|
|
49
|
-
buttonTitle: "Update",
|
|
50
|
-
visible: visible4,
|
|
51
|
-
onClose: { visible4 = false },
|
|
52
|
-
onPressButton: { visible4 = false }
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
Button(
|
|
57
|
-
title: "Reset all",
|
|
58
|
-
action: {
|
|
59
|
-
visible1 = true
|
|
60
|
-
visible2 = true
|
|
61
|
-
visible3 = true
|
|
62
|
-
visible4 = true
|
|
63
|
-
},
|
|
64
|
-
type: .primary,
|
|
65
|
-
isFull: false
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
.padding()
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@ViewBuilder
|
|
73
|
-
private func section<Content: View>(_ title: String, @ViewBuilder content: () -> Content) -> some View {
|
|
74
|
-
VStack(alignment: .leading, spacing: 8) {
|
|
75
|
-
MomoText(title, typography: .headerSSemibold, color: Colors.textSecondary)
|
|
76
|
-
content()
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import MoMoUIKits
|
|
2
|
-
import SwiftUI
|
|
3
|
-
|
|
4
|
-
struct SwipeDemo: View {
|
|
5
|
-
@State private var showLeftActions = true
|
|
6
|
-
@State private var showRightActions = true
|
|
7
|
-
@State private var heightValue: Double = 56
|
|
8
|
-
@State private var radiusValue: Double = 0
|
|
9
|
-
@State private var lastAction = "No action yet"
|
|
10
|
-
|
|
11
|
-
private var editAction: SwipeAction {
|
|
12
|
-
SwipeAction(
|
|
13
|
-
label: "Edit",
|
|
14
|
-
icon: "24_basic_copy",
|
|
15
|
-
backgroundColor: Colors.blue03,
|
|
16
|
-
onPress: { lastAction = "Edit pressed" }
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private var deleteAction: SwipeAction {
|
|
21
|
-
SwipeAction(
|
|
22
|
-
label: "Delete",
|
|
23
|
-
icon: "24_basic_delete",
|
|
24
|
-
backgroundColor: Colors.red03,
|
|
25
|
-
onPress: { lastAction = "Delete pressed" }
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private var archiveAction: SwipeAction {
|
|
30
|
-
SwipeAction(
|
|
31
|
-
label: "Archive",
|
|
32
|
-
icon: "24_basic_flag",
|
|
33
|
-
backgroundColor: Colors.orange03,
|
|
34
|
-
onPress: { lastAction = "Archive pressed" }
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var body: some View {
|
|
39
|
-
ScrollView {
|
|
40
|
-
VStack(alignment: .leading, spacing: Spacing.XL) {
|
|
41
|
-
preview
|
|
42
|
-
Divider()
|
|
43
|
-
playground
|
|
44
|
-
}
|
|
45
|
-
.padding(.vertical, Spacing.L)
|
|
46
|
-
}
|
|
47
|
-
.background(Colors.background)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private var preview: some View {
|
|
51
|
-
VStack(alignment: .leading, spacing: Spacing.XL) {
|
|
52
|
-
section("Right actions only") {
|
|
53
|
-
Swipe(rightActions: [deleteAction]) {
|
|
54
|
-
swipeContent("Swipe left to delete")
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
section("Left actions only") {
|
|
59
|
-
Swipe(leftActions: [editAction, archiveAction]) {
|
|
60
|
-
swipeContent("Swipe right for actions")
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
section("Both sides") {
|
|
65
|
-
Swipe(leftActions: [editAction], rightActions: [deleteAction]) {
|
|
66
|
-
swipeContent("Swipe both directions")
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
section("Multiple right actions") {
|
|
71
|
-
Swipe(rightActions: [editAction, archiveAction, deleteAction]) {
|
|
72
|
-
swipeContent("3 right actions")
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
section("With itemRadius") {
|
|
77
|
-
Swipe(rightActions: [deleteAction], itemRadius: Radius.S) {
|
|
78
|
-
swipeContent("Rounded corners")
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
section("Custom height") {
|
|
83
|
-
Swipe(rightActions: [deleteAction], height: 80) {
|
|
84
|
-
swipeContent("Taller row (80dp)")
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private var playground: some View {
|
|
91
|
-
section("Playground") {
|
|
92
|
-
Toggle(isOn: $showLeftActions) {
|
|
93
|
-
MomoText("Show Left Actions", typography: .labelSMedium, color: Colors.text)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
Toggle(isOn: $showRightActions) {
|
|
97
|
-
MomoText("Show Right Actions", typography: .labelSMedium, color: Colors.text)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
VStack(alignment: .leading, spacing: Spacing.XS) {
|
|
101
|
-
MomoText("Height: \(Int(heightValue))", typography: .labelSMedium, color: Colors.textSecondary)
|
|
102
|
-
Slider(value: $heightValue, in: 40...100, step: 1)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
VStack(alignment: .leading, spacing: Spacing.XS) {
|
|
106
|
-
MomoText("Item Radius: \(Int(radiusValue))", typography: .labelSMedium, color: Colors.textSecondary)
|
|
107
|
-
Slider(value: $radiusValue, in: 0...24, step: 1)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
Swipe(
|
|
111
|
-
leftActions: showLeftActions ? [editAction, archiveAction] : [],
|
|
112
|
-
rightActions: showRightActions ? [deleteAction] : [],
|
|
113
|
-
height: CGFloat(heightValue),
|
|
114
|
-
itemRadius: CGFloat(radiusValue)
|
|
115
|
-
) {
|
|
116
|
-
swipeContent("Swipe me!")
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
MomoText(lastAction, typography: .descriptionDefaultRegular, color: Colors.textSecondary)
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@ViewBuilder
|
|
124
|
-
private func section<Content: View>(
|
|
125
|
-
_ title: String,
|
|
126
|
-
@ViewBuilder content: () -> Content
|
|
127
|
-
) -> some View {
|
|
128
|
-
VStack(alignment: .leading, spacing: Spacing.M) {
|
|
129
|
-
MomoText(title, typography: .headerSSemibold, color: Colors.text)
|
|
130
|
-
content()
|
|
131
|
-
}
|
|
132
|
-
.padding(.horizontal, Spacing.M)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private func swipeContent(_ text: String) -> some View {
|
|
136
|
-
HStack {
|
|
137
|
-
MomoText(text, typography: .bodyDefaultRegular, color: Colors.text)
|
|
138
|
-
Spacer(minLength: 0)
|
|
139
|
-
}
|
|
140
|
-
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
141
|
-
.padding(.horizontal, Spacing.M)
|
|
142
|
-
.background(Colors.card)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
#if DEBUG
|
|
147
|
-
struct SwipeDemo_Previews: PreviewProvider {
|
|
148
|
-
static var previews: some View {
|
|
149
|
-
SwipeDemo()
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
#endif
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// SwitchDemo.swift
|
|
3
|
-
// Example
|
|
4
|
-
//
|
|
5
|
-
// Created by dung.pham2 on 3/12/24.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import SwiftUI
|
|
9
|
-
import MoMoUIKits
|
|
10
|
-
|
|
11
|
-
struct SwitchDemo: View {
|
|
12
|
-
@State private var checked = false
|
|
13
|
-
|
|
14
|
-
var body: some View {
|
|
15
|
-
VStack(alignment: .leading, spacing: 8) {
|
|
16
|
-
Text("Value")
|
|
17
|
-
Switch($checked, onChange: { newValue in
|
|
18
|
-
checked = newValue
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Text("Disabled")
|
|
23
|
-
Switch( .constant(true), disabled: true, onChange: { _ in
|
|
24
|
-
checked = !checked
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
Switch( .constant(false), disabled: true, onChange: { _ in
|
|
28
|
-
checked = !checked
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
.padding()
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// TabViewDemo.swift
|
|
3
|
-
// Example
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
import Foundation
|
|
7
|
-
import MoMoUIKits
|
|
8
|
-
import SwiftUI
|
|
9
|
-
|
|
10
|
-
// MARK: - TabViewDemo
|
|
11
|
-
|
|
12
|
-
struct TabViewDemo: View {
|
|
13
|
-
var body: some View {
|
|
14
|
-
ScrollView {
|
|
15
|
-
VStack(alignment: .leading, spacing: 24) {
|
|
16
|
-
section("Default (2 tabs)") {
|
|
17
|
-
MomoTabView(
|
|
18
|
-
tabs: [
|
|
19
|
-
TabViewItem(title: "Tab 1") { tabContent("Content 1", Colors.pink09) },
|
|
20
|
-
TabViewItem(title: "Tab 2") { tabContent("Content 2", Colors.blue08) },
|
|
21
|
-
]
|
|
22
|
-
)
|
|
23
|
-
.frame(height: 160)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
section("Default (3 tabs)") {
|
|
27
|
-
MomoTabView(
|
|
28
|
-
tabs: [
|
|
29
|
-
TabViewItem(title: "Overview") { tabContent("Overview", Colors.pink09) },
|
|
30
|
-
TabViewItem(title: "Activity") { tabContent("Activity", Colors.blue08) },
|
|
31
|
-
TabViewItem(title: "Settings") { tabContent("Settings", Colors.green08) },
|
|
32
|
-
]
|
|
33
|
-
)
|
|
34
|
-
.frame(height: 160)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
section("With badge & dot") {
|
|
38
|
-
MomoTabView(
|
|
39
|
-
tabs: [
|
|
40
|
-
TabViewItem(title: "Inbox", badgeValue: "5") { tabContent("Inbox", Colors.orange08) },
|
|
41
|
-
TabViewItem(title: "Alerts", showDot: true, dotSize: .small) { tabContent("Alerts", Colors.red08) },
|
|
42
|
-
TabViewItem(title: "Done") { tabContent("Done", Colors.green08) },
|
|
43
|
-
]
|
|
44
|
-
)
|
|
45
|
-
.frame(height: 160)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
section("Scrollable (many tabs)") {
|
|
49
|
-
MomoTabView(
|
|
50
|
-
tabs: [
|
|
51
|
-
TabViewItem(title: "Monday") { tabContent("Monday", Colors.pink09) },
|
|
52
|
-
TabViewItem(title: "Tuesday") { tabContent("Tuesday", Colors.blue08) },
|
|
53
|
-
TabViewItem(title: "Wednesday") { tabContent("Wednesday", Colors.green08) },
|
|
54
|
-
TabViewItem(title: "Thursday") { tabContent("Thursday", Colors.orange08) },
|
|
55
|
-
TabViewItem(title: "Friday") { tabContent("Friday", Colors.mint08) },
|
|
56
|
-
TabViewItem(title: "Saturday") { tabContent("Saturday", Colors.red08) },
|
|
57
|
-
TabViewItem(title: "Sunday") { tabContent("Sunday", Colors.pink09) },
|
|
58
|
-
],
|
|
59
|
-
scrollable: true,
|
|
60
|
-
selectedColor: Colors.pink01,
|
|
61
|
-
unselectedColor: Colors.blue07
|
|
62
|
-
)
|
|
63
|
-
.frame(height: 160)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
section("Card type") {
|
|
67
|
-
MomoTabView(
|
|
68
|
-
tabs: [
|
|
69
|
-
TabViewItem(title: "Personal") { tabContent("Personal", Colors.pink09) },
|
|
70
|
-
TabViewItem(title: "Business") { tabContent("Business", Colors.blue08) },
|
|
71
|
-
TabViewItem(title: "Savings") { tabContent("Savings", Colors.green08) },
|
|
72
|
-
],
|
|
73
|
-
type: .card
|
|
74
|
-
)
|
|
75
|
-
.frame(height: 160)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
section("Card type with icon") {
|
|
79
|
-
MomoTabView(
|
|
80
|
-
tabs: [
|
|
81
|
-
TabViewItem(title: "Home", icon: "basic_home") { tabContent("Home", Colors.pink09) },
|
|
82
|
-
TabViewItem(title: "Search", icon: "basic_search") { tabContent("Search", Colors.blue08) },
|
|
83
|
-
],
|
|
84
|
-
type: .card
|
|
85
|
-
)
|
|
86
|
-
.frame(height: 160)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
section("Column direction") {
|
|
90
|
-
MomoTabView(
|
|
91
|
-
tabs: [
|
|
92
|
-
TabViewItem(title: "Home", icon: "basic_home") { tabContent("Home", Colors.pink09) },
|
|
93
|
-
TabViewItem(title: "Search", icon: "basic_search") { tabContent("Search", Colors.blue08) },
|
|
94
|
-
TabViewItem(title: "Profile", icon: "basic_user") { tabContent("Profile", Colors.green08) },
|
|
95
|
-
],
|
|
96
|
-
direction: .column
|
|
97
|
-
)
|
|
98
|
-
.frame(height: 200)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
section("Custom renderIcon") {
|
|
102
|
-
MomoTabView(
|
|
103
|
-
tabs: [
|
|
104
|
-
TabViewItem(
|
|
105
|
-
title: "Custom",
|
|
106
|
-
renderIcon: { active in
|
|
107
|
-
AnyView(
|
|
108
|
-
RoundedRectangle(cornerRadius: 12)
|
|
109
|
-
.fill(active ? Colors.pink09 : Colors.black17)
|
|
110
|
-
.frame(width: 24, height: 24)
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
) { tabContent("Custom Icon", Colors.pink09) },
|
|
114
|
-
TabViewItem(title: "Normal", icon: "basic_search") { tabContent("Normal", Colors.blue08) },
|
|
115
|
-
]
|
|
116
|
-
)
|
|
117
|
-
.frame(height: 160)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
section("Swipe enabled") {
|
|
121
|
-
MomoTabView(
|
|
122
|
-
tabs: [
|
|
123
|
-
TabViewItem(title: "Swipe 1") { tabContent("Swipe left/right", Colors.pink09) },
|
|
124
|
-
TabViewItem(title: "Swipe 2") { tabContent("Swipeable!", Colors.blue08) },
|
|
125
|
-
],
|
|
126
|
-
userScrollEnabled: true
|
|
127
|
-
)
|
|
128
|
-
.frame(height: 160)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
section("Column direction card type") {
|
|
132
|
-
MomoTabView(
|
|
133
|
-
tabs: [
|
|
134
|
-
TabViewItem(title: "Personal", icon: "basic_home") { tabContent("Personal", Colors.pink09) },
|
|
135
|
-
TabViewItem(title: "Business", icon: "basic_search") { tabContent("Business", Colors.blue08) },
|
|
136
|
-
],
|
|
137
|
-
type: .card,
|
|
138
|
-
direction: .column
|
|
139
|
-
)
|
|
140
|
-
.frame(height: 200)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
section("fitContent (no pager)") {
|
|
144
|
-
MomoTabView(
|
|
145
|
-
tabs: [
|
|
146
|
-
TabViewItem(title: "Tab A") { tabContent("Tab A content", Colors.pink09) },
|
|
147
|
-
TabViewItem(title: "Tab B") { tabContent("Tab B content", Colors.blue08) },
|
|
148
|
-
TabViewItem(title: "Tab C") { tabContent("Tab C content", Colors.green08) },
|
|
149
|
-
],
|
|
150
|
-
fitContent: true
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
.padding(.vertical, 16)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// MARK: - Helpers
|
|
159
|
-
|
|
160
|
-
@ViewBuilder
|
|
161
|
-
private func section<Content: View>(
|
|
162
|
-
_ title: String,
|
|
163
|
-
@ViewBuilder content: () -> Content
|
|
164
|
-
) -> some View {
|
|
165
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
166
|
-
Text(title)
|
|
167
|
-
.font(.headline)
|
|
168
|
-
content()
|
|
169
|
-
}
|
|
170
|
-
.padding(.horizontal, 16)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@ViewBuilder
|
|
174
|
-
private func tabContent(_ label: String, _ background: Color) -> some View {
|
|
175
|
-
ZStack {
|
|
176
|
-
background
|
|
177
|
-
MomoText(label, typography: .headerSSemibold, color: Colors.text)
|
|
178
|
-
}
|
|
179
|
-
.frame(maxWidth: .infinity)
|
|
180
|
-
.frame(height: 120)
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
#if DEBUG
|
|
185
|
-
struct TabViewDemo_Previews: PreviewProvider {
|
|
186
|
-
static var previews: some View {
|
|
187
|
-
TabViewDemo()
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
#endif
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
import MoMoUIKits
|
|
3
|
-
|
|
4
|
-
struct TagDemo: View {
|
|
5
|
-
var body: some View {
|
|
6
|
-
ScrollView {
|
|
7
|
-
VStack(alignment: .leading, spacing: 24) {
|
|
8
|
-
VStack(alignment: .leading, spacing: 8) {
|
|
9
|
-
Text("Color").font(.headline)
|
|
10
|
-
Tag()
|
|
11
|
-
Tag(color: .red)
|
|
12
|
-
Tag(color: .blue)
|
|
13
|
-
Tag(color: .green)
|
|
14
|
-
Tag(color: .orange)
|
|
15
|
-
Tag(color: .grey)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
VStack(alignment: .leading, spacing: 8) {
|
|
19
|
-
Text("Size").font(.headline)
|
|
20
|
-
Tag(size: .large)
|
|
21
|
-
Tag(size: .medium)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
VStack(alignment: .leading, spacing: 8) {
|
|
25
|
-
Text("With Icon").font(.headline)
|
|
26
|
-
Tag(icon: "ic_momo", color: .grey)
|
|
27
|
-
Tag(icon: "ic_momo", color: .red, size: .medium)
|
|
28
|
-
Tag(icon: "ic_momo", color: .blue, size: .medium)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
.padding()
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// ThemeDemo.swift
|
|
3
|
-
// iosApp
|
|
4
|
-
//
|
|
5
|
-
// Created by sophia on 25/2/26.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import MoMoUIKits
|
|
9
|
-
import SwiftUI
|
|
10
|
-
|
|
11
|
-
// MARK: - ThemeDemo
|
|
12
|
-
|
|
13
|
-
struct ThemeDemo: View {
|
|
14
|
-
@Environment(\.appTheme) private var theme
|
|
15
|
-
@State private var isDarkMode: Bool = false
|
|
16
|
-
|
|
17
|
-
var body: some View {
|
|
18
|
-
ScrollView {
|
|
19
|
-
VStack(alignment: .leading, spacing: 0) {
|
|
20
|
-
|
|
21
|
-
// MARK: Dark Mode Toggle
|
|
22
|
-
Toggle(isOn: $isDarkMode) {
|
|
23
|
-
Text("Dark Mode")
|
|
24
|
-
.font(.headline)
|
|
25
|
-
}
|
|
26
|
-
.padding(.horizontal, 16)
|
|
27
|
-
.padding(.vertical, 12)
|
|
28
|
-
.onChange(of: isDarkMode) { _ in
|
|
29
|
-
// Theme switching is handled via parent environment
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Divider()
|
|
33
|
-
|
|
34
|
-
// MARK: Primary / Secondary
|
|
35
|
-
SectionHeader("Primary & Secondary")
|
|
36
|
-
ThemeColorRow(label: "primary", color: theme.colors.primary)
|
|
37
|
-
ThemeColorRow(label: "secondary", color: theme.colors.secondary)
|
|
38
|
-
|
|
39
|
-
// MARK: Background
|
|
40
|
-
SectionHeader("Background")
|
|
41
|
-
ThemeColorRow(label: "default", color: theme.colors.background.default)
|
|
42
|
-
ThemeColorRow(label: "surface", color: theme.colors.background.surface)
|
|
43
|
-
ThemeColorRow(label: "tonal", color: theme.colors.background.tonal)
|
|
44
|
-
ThemeColorRow(label: "pressed", color: theme.colors.background.pressed)
|
|
45
|
-
ThemeColorRow(label: "selected", color: theme.colors.background.selected)
|
|
46
|
-
ThemeColorRow(label: "disable", color: theme.colors.background.disable)
|
|
47
|
-
|
|
48
|
-
// MARK: Text
|
|
49
|
-
SectionHeader("Text")
|
|
50
|
-
ThemeColorRow(label: "default", color: theme.colors.text.default)
|
|
51
|
-
ThemeColorRow(label: "secondary", color: theme.colors.text.secondary)
|
|
52
|
-
ThemeColorRow(label: "hint", color: theme.colors.text.hint)
|
|
53
|
-
ThemeColorRow(label: "disable", color: theme.colors.text.disable)
|
|
54
|
-
|
|
55
|
-
// MARK: Border
|
|
56
|
-
SectionHeader("Border")
|
|
57
|
-
ThemeColorRow(label: "default", color: theme.colors.border.default)
|
|
58
|
-
ThemeColorRow(label: "disable", color: theme.colors.border.disable)
|
|
59
|
-
|
|
60
|
-
// MARK: Success
|
|
61
|
-
SectionHeader("Success")
|
|
62
|
-
ThemeColorRow(label: "primary", color: theme.colors.success.primary)
|
|
63
|
-
ThemeColorRow(label: "secondary", color: theme.colors.success.secondary)
|
|
64
|
-
ThemeColorRow(label: "container", color: theme.colors.success.container)
|
|
65
|
-
|
|
66
|
-
// MARK: Warning
|
|
67
|
-
SectionHeader("Warning")
|
|
68
|
-
ThemeColorRow(label: "primary", color: theme.colors.warning.primary)
|
|
69
|
-
ThemeColorRow(label: "secondary", color: theme.colors.warning.secondary)
|
|
70
|
-
ThemeColorRow(label: "container", color: theme.colors.warning.container)
|
|
71
|
-
|
|
72
|
-
// MARK: Error
|
|
73
|
-
SectionHeader("Error")
|
|
74
|
-
ThemeColorRow(label: "primary", color: theme.colors.error.primary)
|
|
75
|
-
ThemeColorRow(label: "secondary", color: theme.colors.error.secondary)
|
|
76
|
-
ThemeColorRow(label: "container", color: theme.colors.error.container)
|
|
77
|
-
|
|
78
|
-
// MARK: Highlight
|
|
79
|
-
SectionHeader("Highlight")
|
|
80
|
-
ThemeColorRow(label: "primary", color: theme.colors.highlight.primary)
|
|
81
|
-
ThemeColorRow(label: "secondary", color: theme.colors.highlight.secondary)
|
|
82
|
-
ThemeColorRow(label: "container", color: theme.colors.highlight.container)
|
|
83
|
-
|
|
84
|
-
// MARK: Interactive
|
|
85
|
-
SectionHeader("Interactive")
|
|
86
|
-
ThemeColorRow(label: "primary", color: theme.colors.interactive.primary)
|
|
87
|
-
ThemeColorRow(label: "secondary", color: theme.colors.interactive.secondary)
|
|
88
|
-
ThemeColorRow(label: "container", color: theme.colors.interactive.container)
|
|
89
|
-
|
|
90
|
-
Spacer(minLength: 32)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
.navigationTitle("Theme")
|
|
94
|
-
.background(isDarkMode ? Colors.black10.ignoresSafeArea() : theme.colors.background.default.ignoresSafeArea())
|
|
95
|
-
.environment(\.appTheme, isDarkMode ? darkTheme : defaultTheme)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// MARK: - SectionHeader
|
|
100
|
-
|
|
101
|
-
private struct SectionHeader: View {
|
|
102
|
-
let title: String
|
|
103
|
-
|
|
104
|
-
init(_ title: String) {
|
|
105
|
-
self.title = title
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var body: some View {
|
|
109
|
-
Text(title)
|
|
110
|
-
.font(.headline)
|
|
111
|
-
.fontWeight(.bold)
|
|
112
|
-
.padding(.horizontal, 16)
|
|
113
|
-
.padding(.top, 20)
|
|
114
|
-
.padding(.bottom, 8)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// MARK: - ThemeColorRow
|
|
119
|
-
|
|
120
|
-
private struct ThemeColorRow: View {
|
|
121
|
-
@Environment(\.appTheme) private var theme
|
|
122
|
-
let label: String
|
|
123
|
-
let color: Color
|
|
124
|
-
|
|
125
|
-
var body: some View {
|
|
126
|
-
HStack(spacing: 12) {
|
|
127
|
-
RoundedRectangle(cornerRadius: 8)
|
|
128
|
-
.fill(color)
|
|
129
|
-
.frame(width: 36, height: 36)
|
|
130
|
-
.overlay(
|
|
131
|
-
RoundedRectangle(cornerRadius: 8)
|
|
132
|
-
.stroke(theme.colors.border.default, lineWidth: 1)
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
Text(label)
|
|
136
|
-
.font(.body)
|
|
137
|
-
.foregroundColor(theme.colors.text.default)
|
|
138
|
-
|
|
139
|
-
Spacer()
|
|
140
|
-
|
|
141
|
-
Text(color.toHexString())
|
|
142
|
-
.font(.caption)
|
|
143
|
-
.foregroundColor(theme.colors.text.hint)
|
|
144
|
-
.padding(.horizontal, 8)
|
|
145
|
-
.padding(.vertical, 4)
|
|
146
|
-
.background(theme.colors.background.tonal)
|
|
147
|
-
.clipShape(Capsule())
|
|
148
|
-
}
|
|
149
|
-
.padding(.horizontal, 16)
|
|
150
|
-
.padding(.vertical, 4)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// MARK: - Color+Hex helper
|
|
155
|
-
|
|
156
|
-
extension Color {
|
|
157
|
-
/// Returns a hex string like "#EB2F96" from a SwiftUI Color.
|
|
158
|
-
func toHexString() -> String {
|
|
159
|
-
guard let cgColor = UIColor(self).cgColor.converted(
|
|
160
|
-
to: CGColorSpaceCreateDeviceRGB(),
|
|
161
|
-
intent: .defaultIntent,
|
|
162
|
-
options: nil
|
|
163
|
-
) else { return "#??????" }
|
|
164
|
-
guard let components = cgColor.components, components.count >= 3 else { return "#??????" }
|
|
165
|
-
let r = Int((components[0] * 255).rounded())
|
|
166
|
-
let g = Int((components[1] * 255).rounded())
|
|
167
|
-
let b = Int((components[2] * 255).rounded())
|
|
168
|
-
return String(format: "#%02X%02X%02X", r, g, b)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// MARK: - Preview
|
|
173
|
-
|
|
174
|
-
#Preview {
|
|
175
|
-
if #available(iOS 16.0, *) {
|
|
176
|
-
NavigationStack {
|
|
177
|
-
ThemeDemo()
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
// Fallback on earlier versions
|
|
181
|
-
}
|
|
182
|
-
}
|