@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
package/ios/Tag/Tag.swift
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
|
|
3
|
-
public struct Tag: View {
|
|
4
|
-
public enum TagSize {
|
|
5
|
-
case large
|
|
6
|
-
case medium
|
|
7
|
-
|
|
8
|
-
var height: CGFloat {
|
|
9
|
-
switch self {
|
|
10
|
-
case .large: return 24
|
|
11
|
-
case .medium: return 18
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public enum TagColor {
|
|
17
|
-
case `default`
|
|
18
|
-
case orange
|
|
19
|
-
case green
|
|
20
|
-
case red
|
|
21
|
-
case blue
|
|
22
|
-
case grey
|
|
23
|
-
|
|
24
|
-
var backgroundColor: Color {
|
|
25
|
-
switch self {
|
|
26
|
-
case .default: return Colors.black04
|
|
27
|
-
case .orange: return Colors.orange08
|
|
28
|
-
case .green: return Colors.green08
|
|
29
|
-
case .red: return Colors.red08
|
|
30
|
-
case .blue: return Colors.blue08
|
|
31
|
-
case .grey: return Colors.black04
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var textColor: Color {
|
|
36
|
-
switch self {
|
|
37
|
-
case .default: return Colors.black17
|
|
38
|
-
case .orange: return Colors.orange03
|
|
39
|
-
case .green: return Colors.green03
|
|
40
|
-
case .red: return Colors.red03
|
|
41
|
-
case .blue: return Colors.blue03
|
|
42
|
-
case .grey: return Colors.black12
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private let label: String
|
|
48
|
-
private let icon: String?
|
|
49
|
-
private let color: TagColor
|
|
50
|
-
private let size: TagSize
|
|
51
|
-
|
|
52
|
-
public init(
|
|
53
|
-
label: String = "Label",
|
|
54
|
-
icon: String? = nil,
|
|
55
|
-
color: TagColor = .default,
|
|
56
|
-
size: TagSize = .large
|
|
57
|
-
) {
|
|
58
|
-
self.label = label
|
|
59
|
-
self.icon = icon
|
|
60
|
-
self.color = color
|
|
61
|
-
self.size = size
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public var body: some View {
|
|
65
|
-
let tagColor = color.backgroundColor
|
|
66
|
-
let labelColor = color.textColor
|
|
67
|
-
|
|
68
|
-
HStack(spacing: 0) {
|
|
69
|
-
if let icon {
|
|
70
|
-
Icon(source: icon, size: 16, color: labelColor)
|
|
71
|
-
}
|
|
72
|
-
MomoText(label, typography: .labelSMedium, color: labelColor)
|
|
73
|
-
}
|
|
74
|
-
.frame(height: scaleSize(size.height))
|
|
75
|
-
.padding(.horizontal, Spacing.S)
|
|
76
|
-
.background(
|
|
77
|
-
RoundedRectangle(cornerRadius: Radius.S, style: .continuous)
|
|
78
|
-
.fill(tagColor)
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// MARK: - Preview
|
|
84
|
-
#if DEBUG
|
|
85
|
-
struct Tag_Previews: PreviewProvider {
|
|
86
|
-
static var previews: some View {
|
|
87
|
-
VStack(spacing: 12) {
|
|
88
|
-
Tag()
|
|
89
|
-
Tag(color: .red)
|
|
90
|
-
Tag(color: .blue)
|
|
91
|
-
Tag(icon: "ic_momo", color: .grey)
|
|
92
|
-
Tag(label: "Medium", color: .green, size: .medium)
|
|
93
|
-
}
|
|
94
|
-
.padding()
|
|
95
|
-
.previewLayout(.sizeThatFits)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
#endif
|
package/ios/Title/Title.swift
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
|
|
3
|
-
// MARK: - Enums
|
|
4
|
-
|
|
5
|
-
public enum TitleType {
|
|
6
|
-
case card
|
|
7
|
-
case section
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public enum TitleSize {
|
|
11
|
-
case small
|
|
12
|
-
case medium
|
|
13
|
-
case large
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public enum IconAlign {
|
|
17
|
-
case top
|
|
18
|
-
case center
|
|
19
|
-
case bottom
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public enum TitleButtonSize {
|
|
23
|
-
case small
|
|
24
|
-
case large
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// MARK: - Title
|
|
28
|
-
|
|
29
|
-
public struct Title: View {
|
|
30
|
-
@Environment(\.appTheme) private var theme
|
|
31
|
-
|
|
32
|
-
private let title: String
|
|
33
|
-
private let type: TitleType
|
|
34
|
-
private let size: TitleSize
|
|
35
|
-
private let icon: String?
|
|
36
|
-
private let iconColor: Color?
|
|
37
|
-
private let iconAlign: IconAlign
|
|
38
|
-
private let showRightAction: Bool
|
|
39
|
-
private let showTrailingAction: Bool
|
|
40
|
-
private let badgeLabel: String?
|
|
41
|
-
private let buttonTitle: String?
|
|
42
|
-
private let buttonSize: TitleButtonSize
|
|
43
|
-
private let onPressRightAction: () -> Void
|
|
44
|
-
private let onPressTrailingAction: () -> Void
|
|
45
|
-
private let textOnly: Bool
|
|
46
|
-
private let description: String?
|
|
47
|
-
|
|
48
|
-
public init(
|
|
49
|
-
title: String,
|
|
50
|
-
type: TitleType = .section,
|
|
51
|
-
size: TitleSize = .medium,
|
|
52
|
-
icon: String? = nil,
|
|
53
|
-
iconColor: Color? = nil,
|
|
54
|
-
iconAlign: IconAlign = .top,
|
|
55
|
-
showRightAction: Bool = false,
|
|
56
|
-
showTrailingAction: Bool = false,
|
|
57
|
-
badgeLabel: String? = nil,
|
|
58
|
-
buttonTitle: String? = nil,
|
|
59
|
-
buttonSize: TitleButtonSize = .small,
|
|
60
|
-
onPressRightAction: @escaping () -> Void = {},
|
|
61
|
-
onPressTrailingAction: @escaping () -> Void = {},
|
|
62
|
-
textOnly: Bool = false,
|
|
63
|
-
description: String? = nil
|
|
64
|
-
) {
|
|
65
|
-
self.title = title
|
|
66
|
-
self.type = type
|
|
67
|
-
self.size = size
|
|
68
|
-
self.icon = icon
|
|
69
|
-
self.iconColor = iconColor
|
|
70
|
-
self.iconAlign = iconAlign
|
|
71
|
-
self.showRightAction = showRightAction
|
|
72
|
-
self.showTrailingAction = showTrailingAction
|
|
73
|
-
self.badgeLabel = badgeLabel
|
|
74
|
-
self.buttonTitle = buttonTitle
|
|
75
|
-
self.buttonSize = buttonSize
|
|
76
|
-
self.onPressRightAction = onPressRightAction
|
|
77
|
-
self.onPressTrailingAction = onPressTrailingAction
|
|
78
|
-
self.textOnly = textOnly
|
|
79
|
-
self.description = description
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// MARK: - Title text style
|
|
83
|
-
|
|
84
|
-
private var titleFontSize: CGFloat {
|
|
85
|
-
switch type {
|
|
86
|
-
case .card:
|
|
87
|
-
switch size {
|
|
88
|
-
case .small: return 14
|
|
89
|
-
case .medium: return 16
|
|
90
|
-
case .large: return 18
|
|
91
|
-
}
|
|
92
|
-
case .section:
|
|
93
|
-
switch size {
|
|
94
|
-
case .small: return 16
|
|
95
|
-
case .medium: return 18
|
|
96
|
-
case .large: return 20
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private var titleLineHeight: CGFloat {
|
|
102
|
-
switch type {
|
|
103
|
-
case .card:
|
|
104
|
-
switch size {
|
|
105
|
-
case .small: return 20
|
|
106
|
-
case .medium: return 22
|
|
107
|
-
case .large: return 26
|
|
108
|
-
}
|
|
109
|
-
case .section:
|
|
110
|
-
switch size {
|
|
111
|
-
case .small: return 24
|
|
112
|
-
case .medium: return 26
|
|
113
|
-
case .large: return 28
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private var titleFontWeight: Font.Weight {
|
|
119
|
-
switch type {
|
|
120
|
-
case .card: return .regular
|
|
121
|
-
case .section: return .bold
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private var titleMaxLines: Int {
|
|
126
|
-
(showTrailingAction || badgeLabel != nil) ? 1 : 2
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
private var iconVerticalAlignment: VerticalAlignment {
|
|
130
|
-
switch iconAlign {
|
|
131
|
-
case .top: return .top
|
|
132
|
-
case .center: return .center
|
|
133
|
-
case .bottom: return .bottom
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private var trailingBackground: Color {
|
|
138
|
-
type == .section
|
|
139
|
-
? Colors.black06.opacity(0.6)
|
|
140
|
-
: Colors.black06.opacity(0.3)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// MARK: - Body
|
|
144
|
-
|
|
145
|
-
public var body: some View {
|
|
146
|
-
if textOnly {
|
|
147
|
-
titleText
|
|
148
|
-
} else {
|
|
149
|
-
fullLayout
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private var titleText: some View {
|
|
154
|
-
SwiftUI.Text(title)
|
|
155
|
-
.font(.system(size: scaleSize(titleFontSize), weight: titleFontWeight))
|
|
156
|
-
.ignoreBoldTextSetting()
|
|
157
|
-
.foregroundColor(theme.colors.text.default)
|
|
158
|
-
.lineSpacing(scaleSize(titleLineHeight) - scaleSize(titleFontSize))
|
|
159
|
-
.lineLimit(titleMaxLines)
|
|
160
|
-
.truncationMode(.tail)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
private var fullLayout: some View {
|
|
164
|
-
HStack(alignment: .center, spacing: 0) {
|
|
165
|
-
HStack(alignment: iconVerticalAlignment, spacing: 0) {
|
|
166
|
-
if let icon = icon {
|
|
167
|
-
Icon(
|
|
168
|
-
source: icon,
|
|
169
|
-
size: 24,
|
|
170
|
-
color: iconColor ?? theme.colors.text.default
|
|
171
|
-
)
|
|
172
|
-
.padding(.trailing, Spacing.S)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
VStack(alignment: .leading, spacing: 0) {
|
|
176
|
-
HStack(alignment: .center, spacing: 0) {
|
|
177
|
-
HStack(alignment: .center, spacing: 0) {
|
|
178
|
-
titleText
|
|
179
|
-
|
|
180
|
-
if let badgeLabel = badgeLabel {
|
|
181
|
-
Spacer().frame(width: 4)
|
|
182
|
-
Badge(label: badgeLabel)
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if showTrailingAction != true {
|
|
186
|
-
Spacer(minLength: 0)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if showTrailingAction && !showRightAction {
|
|
190
|
-
Spacer().frame(width: 8)
|
|
191
|
-
SwiftUI.Button(action: onPressTrailingAction) {
|
|
192
|
-
Icon(source: "arrow_chevron_right_small", size: 18)
|
|
193
|
-
.frame(width: 24, height: 24)
|
|
194
|
-
.background(trailingBackground)
|
|
195
|
-
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
196
|
-
}
|
|
197
|
-
.buttonStyle(.plain)
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if let description = description {
|
|
202
|
-
Spacer().frame(height: 4)
|
|
203
|
-
MomoText(
|
|
204
|
-
description,
|
|
205
|
-
typography: .descriptionDefaultRegular,
|
|
206
|
-
color: theme.colors.text.secondary
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if showRightAction && !showTrailingAction {
|
|
213
|
-
Spacer().frame(width: 8)
|
|
214
|
-
if let buttonTitle = buttonTitle {
|
|
215
|
-
SwiftUI.Button(action: onPressRightAction) {
|
|
216
|
-
MomoText(
|
|
217
|
-
buttonTitle,
|
|
218
|
-
typography: buttonSize == .small ? .actionXsBold : .actionSBold,
|
|
219
|
-
color: theme.colors.primary
|
|
220
|
-
)
|
|
221
|
-
}
|
|
222
|
-
.buttonStyle(.plain)
|
|
223
|
-
} else {
|
|
224
|
-
SwiftUI.Button(action: onPressRightAction) {
|
|
225
|
-
Icon(
|
|
226
|
-
source: "arrow_chevron_right_small",
|
|
227
|
-
size: 22,
|
|
228
|
-
color: theme.colors.primary
|
|
229
|
-
)
|
|
230
|
-
.frame(width: 24, height: 24)
|
|
231
|
-
.background(Colors.pink03.opacity(0.1))
|
|
232
|
-
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
233
|
-
}
|
|
234
|
-
.buttonStyle(.plain)
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
.frame(maxWidth: .infinity, alignment: .leading)
|
|
239
|
-
.padding(8)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// MARK: - Preview
|
|
244
|
-
|
|
245
|
-
#if DEBUG
|
|
246
|
-
struct Title_Previews: PreviewProvider {
|
|
247
|
-
static var previews: some View {
|
|
248
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
249
|
-
Title(title: "Section Small", type: .section, size: .small)
|
|
250
|
-
Title(
|
|
251
|
-
title: "Section Medium",
|
|
252
|
-
type: .section,
|
|
253
|
-
size: .medium,
|
|
254
|
-
icon: "basic_home",
|
|
255
|
-
description: "This is a medium section with icon."
|
|
256
|
-
)
|
|
257
|
-
Title(
|
|
258
|
-
title: "Section Large",
|
|
259
|
-
type: .section,
|
|
260
|
-
size: .large,
|
|
261
|
-
showTrailingAction: true,
|
|
262
|
-
badgeLabel: "NEW"
|
|
263
|
-
)
|
|
264
|
-
}
|
|
265
|
-
.padding()
|
|
266
|
-
.previewLayout(.sizeThatFits)
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
#endif
|