@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,163 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
|
|
3
|
-
public struct BaselineView: View {
|
|
4
|
-
private let enabled: Bool
|
|
5
|
-
|
|
6
|
-
public init(enabled: Bool = true) {
|
|
7
|
-
self.enabled = enabled
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public var body: some View {
|
|
11
|
-
if enabled {
|
|
12
|
-
GeometryReader { geometry in
|
|
13
|
-
let topInset = geometry.safeAreaInsets.top
|
|
14
|
-
let bottomInset = min(geometry.safeAreaInsets.bottom, 21)
|
|
15
|
-
|
|
16
|
-
ZStack(alignment: .topLeading) {
|
|
17
|
-
dangerZones(topInset: topInset, bottomInset: bottomInset)
|
|
18
|
-
guideLines(
|
|
19
|
-
topInset: topInset,
|
|
20
|
-
bottomInset: bottomInset,
|
|
21
|
-
width: geometry.size.width
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
25
|
-
.ignoresSafeArea()
|
|
26
|
-
.allowsHitTesting(false)
|
|
27
|
-
.accessibilityHidden(true)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private func dangerZones(topInset: CGFloat, bottomInset: CGFloat) -> some View {
|
|
33
|
-
let safeBackground = Color.red.opacity(0.15)
|
|
34
|
-
|
|
35
|
-
return ZStack(alignment: .topLeading) {
|
|
36
|
-
safeBackground
|
|
37
|
-
.frame(maxWidth: .infinity)
|
|
38
|
-
.frame(height: topInset)
|
|
39
|
-
|
|
40
|
-
HStack(spacing: 0) {
|
|
41
|
-
safeBackground
|
|
42
|
-
.frame(width: 12)
|
|
43
|
-
Spacer(minLength: 0)
|
|
44
|
-
safeBackground
|
|
45
|
-
.frame(width: 12)
|
|
46
|
-
}
|
|
47
|
-
.padding(.top, topInset)
|
|
48
|
-
.padding(.bottom, bottomInset)
|
|
49
|
-
|
|
50
|
-
VStack(spacing: 0) {
|
|
51
|
-
Spacer(minLength: 0)
|
|
52
|
-
safeBackground
|
|
53
|
-
.frame(maxWidth: .infinity)
|
|
54
|
-
.frame(height: bottomInset)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
private func guideLines(topInset: CGFloat, bottomInset: CGFloat, width: CGFloat) -> some View {
|
|
60
|
-
ZStack(alignment: .topLeading) {
|
|
61
|
-
baselineLine(isDotted: false, color: Color(hex: 0xE400FF))
|
|
62
|
-
.offset(y: topInset)
|
|
63
|
-
|
|
64
|
-
baselineLine(color: Color(hex: 0xE400FF))
|
|
65
|
-
.offset(y: topInset + 52)
|
|
66
|
-
|
|
67
|
-
baselineLine(color: Color(hex: 0xE400FF))
|
|
68
|
-
.offset(y: topInset + 104)
|
|
69
|
-
|
|
70
|
-
bottomLine(bottomInset: bottomInset + 64, color: Color(hex: 0xE400FF))
|
|
71
|
-
|
|
72
|
-
bottomLine(bottomInset: bottomInset, isDotted: false, color: Color(hex: 0xE400FF))
|
|
73
|
-
|
|
74
|
-
baselineLine(orientation: .vertical, isDotted: false, color: Color(hex: 0xE400FF))
|
|
75
|
-
.offset(x: 12)
|
|
76
|
-
|
|
77
|
-
baselineLine(orientation: .vertical, isDotted: false, color: Color(hex: 0xE400FF))
|
|
78
|
-
.offset(x: width - 12)
|
|
79
|
-
|
|
80
|
-
baselineLine(color: Color(hex: 0xFF7A00))
|
|
81
|
-
.offset(y: topInset + 26)
|
|
82
|
-
|
|
83
|
-
bottomLine(bottomInset: bottomInset + 56, color: Color(hex: 0xFFCC00))
|
|
84
|
-
|
|
85
|
-
bottomLine(bottomInset: bottomInset + 8, color: Color(hex: 0xFFCC00))
|
|
86
|
-
|
|
87
|
-
baselineLine(orientation: .vertical, color: Color(hex: 0x00C520))
|
|
88
|
-
.frame(height: 52)
|
|
89
|
-
.offset(x: 40, y: topInset)
|
|
90
|
-
|
|
91
|
-
baselineLine(orientation: .vertical, color: Color(hex: 0x00C520))
|
|
92
|
-
.frame(height: 52)
|
|
93
|
-
.offset(x: 48, y: topInset)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private func bottomLine(
|
|
98
|
-
bottomInset: CGFloat,
|
|
99
|
-
isDotted: Bool = true,
|
|
100
|
-
color: Color
|
|
101
|
-
) -> some View {
|
|
102
|
-
VStack(spacing: 0) {
|
|
103
|
-
Spacer(minLength: 0)
|
|
104
|
-
baselineLine(isDotted: isDotted, color: color)
|
|
105
|
-
.padding(.bottom, bottomInset)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private func baselineLine(
|
|
110
|
-
orientation: BaselineOrientation = .horizontal,
|
|
111
|
-
isDotted: Bool = true,
|
|
112
|
-
color: Color
|
|
113
|
-
) -> some View {
|
|
114
|
-
BaselineLineShape(orientation: orientation)
|
|
115
|
-
.stroke(
|
|
116
|
-
color,
|
|
117
|
-
style: StrokeStyle(
|
|
118
|
-
lineWidth: 1,
|
|
119
|
-
lineCap: .round,
|
|
120
|
-
dash: isDotted ? [8, 8] : []
|
|
121
|
-
)
|
|
122
|
-
)
|
|
123
|
-
.frame(
|
|
124
|
-
maxWidth: orientation == .horizontal ? .infinity : 1,
|
|
125
|
-
maxHeight: orientation == .vertical ? .infinity : 1
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public enum BaselineOrientation: Sendable {
|
|
131
|
-
case horizontal
|
|
132
|
-
case vertical
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private struct BaselineLineShape: Shape {
|
|
136
|
-
let orientation: BaselineOrientation
|
|
137
|
-
|
|
138
|
-
func path(in rect: CGRect) -> Path {
|
|
139
|
-
var path = Path()
|
|
140
|
-
|
|
141
|
-
switch orientation {
|
|
142
|
-
case .horizontal:
|
|
143
|
-
path.move(to: CGPoint(x: rect.minX, y: rect.midY))
|
|
144
|
-
path.addLine(to: CGPoint(x: rect.maxX, y: rect.midY))
|
|
145
|
-
case .vertical:
|
|
146
|
-
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
|
|
147
|
-
path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY))
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return path
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
#if DEBUG
|
|
155
|
-
struct BaselineView_Previews: PreviewProvider {
|
|
156
|
-
static var previews: some View {
|
|
157
|
-
ZStack {
|
|
158
|
-
Colors.black01
|
|
159
|
-
BaselineView()
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
#endif
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import Combine
|
|
2
|
-
import SwiftUI
|
|
3
|
-
|
|
4
|
-
/// Native SwiftUI port of the Compose `Carousel` component.
|
|
5
|
-
///
|
|
6
|
-
/// Mirrors the Compose API: a paging horizontal carousel driven by an
|
|
7
|
-
/// `itemCount` and a `content` builder that receives the real (modulo) index.
|
|
8
|
-
/// Supports infinite `loop`, `autoplay` with a configurable interval,
|
|
9
|
-
/// inactive-slide `opacity`/`scale` effects, optional `contentPadding`,
|
|
10
|
-
/// snap behavior, and scroll enable/disable. Snap / scroll-index callbacks
|
|
11
|
-
/// report the real item index.
|
|
12
|
-
///
|
|
13
|
-
/// Available iOS 14+ (uses a custom paging ScrollView so behavior is identical
|
|
14
|
-
/// across versions and supports the loop virtualization + transform effects
|
|
15
|
-
/// that `TabView(.page)` cannot express).
|
|
16
|
-
public struct Carousel<Content: View>: View {
|
|
17
|
-
// MARK: Lifecycle
|
|
18
|
-
|
|
19
|
-
public init(
|
|
20
|
-
itemCount: Int,
|
|
21
|
-
loop: Bool = false,
|
|
22
|
-
autoplay: Bool = false,
|
|
23
|
-
autoplayInterval: TimeInterval = 3.0,
|
|
24
|
-
enableSnap: Bool = true,
|
|
25
|
-
scrollEnabled: Bool = true,
|
|
26
|
-
inactiveSlideOpacity: Double = 1.0,
|
|
27
|
-
inactiveSlideScale: Double = 1.0,
|
|
28
|
-
contentPadding: CGFloat = 0,
|
|
29
|
-
onSnapToItem: @escaping (Int) -> Void = { _ in },
|
|
30
|
-
onScrollIndexChanged: @escaping (Int) -> Void = { _ in },
|
|
31
|
-
@ViewBuilder content: @escaping (_ index: Int) -> Content
|
|
32
|
-
) {
|
|
33
|
-
self.itemCount = itemCount
|
|
34
|
-
self.loop = loop
|
|
35
|
-
self.autoplay = autoplay
|
|
36
|
-
self.autoplayInterval = autoplayInterval
|
|
37
|
-
self.enableSnap = enableSnap
|
|
38
|
-
self.scrollEnabled = scrollEnabled
|
|
39
|
-
self.inactiveSlideOpacity = inactiveSlideOpacity
|
|
40
|
-
self.inactiveSlideScale = inactiveSlideScale
|
|
41
|
-
self.contentPadding = contentPadding
|
|
42
|
-
self.onSnapToItem = onSnapToItem
|
|
43
|
-
self.onScrollIndexChanged = onScrollIndexChanged
|
|
44
|
-
self.content = content
|
|
45
|
-
|
|
46
|
-
let virtual = loop ? itemCount * 1000 : itemCount
|
|
47
|
-
let start = loop ? (virtual / 2) - ((virtual / 2) % max(itemCount, 1)) : 0
|
|
48
|
-
self.virtualPageCount = virtual
|
|
49
|
-
_currentPage = State(initialValue: start)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// MARK: Public
|
|
53
|
-
|
|
54
|
-
public var body: some View {
|
|
55
|
-
if itemCount <= 0 {
|
|
56
|
-
EmptyView()
|
|
57
|
-
} else {
|
|
58
|
-
GeometryReader { geo in
|
|
59
|
-
let pageWidth = max(geo.size.width - contentPadding * 2, 1)
|
|
60
|
-
carouselContent(pageWidth: pageWidth, viewportWidth: geo.size.width)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// MARK: Private
|
|
66
|
-
|
|
67
|
-
private let itemCount: Int
|
|
68
|
-
private let loop: Bool
|
|
69
|
-
private let autoplay: Bool
|
|
70
|
-
private let autoplayInterval: TimeInterval
|
|
71
|
-
private let enableSnap: Bool
|
|
72
|
-
private let scrollEnabled: Bool
|
|
73
|
-
private let inactiveSlideOpacity: Double
|
|
74
|
-
private let inactiveSlideScale: Double
|
|
75
|
-
private let contentPadding: CGFloat
|
|
76
|
-
private let onSnapToItem: (Int) -> Void
|
|
77
|
-
private let onScrollIndexChanged: (Int) -> Void
|
|
78
|
-
private let content: (Int) -> Content
|
|
79
|
-
|
|
80
|
-
private let virtualPageCount: Int
|
|
81
|
-
|
|
82
|
-
@State private var currentPage: Int
|
|
83
|
-
@State private var dragOffset: CGFloat = 0
|
|
84
|
-
@State private var isDragging: Bool = false
|
|
85
|
-
@State private var autoplayTick: Int = 0
|
|
86
|
-
|
|
87
|
-
private func realIndex(_ page: Int) -> Int {
|
|
88
|
-
((page % itemCount) + itemCount) % itemCount
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@ViewBuilder
|
|
92
|
-
private func carouselContent(pageWidth: CGFloat, viewportWidth: CGFloat) -> some View {
|
|
93
|
-
let step = pageWidth
|
|
94
|
-
// Offset so the current page is centered within the viewport padding.
|
|
95
|
-
let baseOffset = -CGFloat(currentPage) * step + contentPadding
|
|
96
|
-
|
|
97
|
-
ZStack {
|
|
98
|
-
HStack(spacing: 0) {
|
|
99
|
-
ForEach(0 ..< virtualPageCount, id: \.self) { page in
|
|
100
|
-
slide(page: page, step: step, viewportWidth: viewportWidth)
|
|
101
|
-
.frame(width: pageWidth)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
.offset(x: baseOffset + dragOffset)
|
|
105
|
-
.animation(isDragging ? nil : .easeInOut(duration: 0.25), value: currentPage)
|
|
106
|
-
.frame(width: viewportWidth, alignment: .leading)
|
|
107
|
-
.contentShape(Rectangle())
|
|
108
|
-
.gesture(scrollEnabled ? dragGesture(step: step) : nil)
|
|
109
|
-
}
|
|
110
|
-
.frame(width: viewportWidth)
|
|
111
|
-
.clipped()
|
|
112
|
-
.onReceive(autoplayTimer) { _ in
|
|
113
|
-
guard autoplay, itemCount > 1, !isDragging else { return }
|
|
114
|
-
advance()
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@ViewBuilder
|
|
119
|
-
private func slide(page: Int, step: CGFloat, viewportWidth: CGFloat) -> some View {
|
|
120
|
-
// Fractional offset of this page from the current page (incl. drag).
|
|
121
|
-
let dragFraction = step > 0 ? -dragOffset / step : 0
|
|
122
|
-
let pageOffset = abs(CGFloat(currentPage - page) + dragFraction)
|
|
123
|
-
let isActive = pageOffset < 0.5
|
|
124
|
-
let scale = isActive ? 1.0 : inactiveSlideScale
|
|
125
|
-
let alpha = isActive ? 1.0 : inactiveSlideOpacity
|
|
126
|
-
|
|
127
|
-
content(realIndex(page))
|
|
128
|
-
.scaleEffect(scale)
|
|
129
|
-
.opacity(alpha)
|
|
130
|
-
.animation(.easeInOut(duration: 0.15), value: isActive)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private func dragGesture(step: CGFloat) -> some Gesture {
|
|
134
|
-
DragGesture(minimumDistance: 5)
|
|
135
|
-
.onChanged { value in
|
|
136
|
-
isDragging = true
|
|
137
|
-
dragOffset = value.translation.width
|
|
138
|
-
}
|
|
139
|
-
.onEnded { value in
|
|
140
|
-
isDragging = false
|
|
141
|
-
let predicted = value.predictedEndTranslation.width
|
|
142
|
-
let threshold = step / 4
|
|
143
|
-
var target = currentPage
|
|
144
|
-
if enableSnap {
|
|
145
|
-
if predicted < -threshold {
|
|
146
|
-
target = min(currentPage + 1, virtualPageCount - 1)
|
|
147
|
-
} else if predicted > threshold {
|
|
148
|
-
target = max(currentPage - 1, 0)
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
// Free scroll still settles to nearest page boundary.
|
|
152
|
-
let moved = step > 0 ? Int((-dragOffset / step).rounded()) : 0
|
|
153
|
-
target = min(max(currentPage + moved, 0), virtualPageCount - 1)
|
|
154
|
-
}
|
|
155
|
-
dragOffset = 0
|
|
156
|
-
setPage(target)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private func advance() {
|
|
161
|
-
let next = currentPage + 1
|
|
162
|
-
if next < virtualPageCount {
|
|
163
|
-
setPage(next)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private func setPage(_ page: Int) {
|
|
168
|
-
let clamped = min(max(page, 0), virtualPageCount - 1)
|
|
169
|
-
let changed = clamped != currentPage
|
|
170
|
-
currentPage = clamped
|
|
171
|
-
if changed {
|
|
172
|
-
let real = realIndex(clamped)
|
|
173
|
-
onSnapToItem(real)
|
|
174
|
-
onScrollIndexChanged(real)
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private var autoplayTimer: Publishers.Autoconnect<Timer.TimerPublisher> {
|
|
179
|
-
Timer.publish(every: autoplayInterval, on: .main, in: .common).autoconnect()
|
|
180
|
-
}
|
|
181
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
|
|
3
|
-
public enum CollapseTitleSize {
|
|
4
|
-
case small
|
|
5
|
-
case medium
|
|
6
|
-
case large
|
|
7
|
-
|
|
8
|
-
var typography: TypographyStyle {
|
|
9
|
-
switch self {
|
|
10
|
-
case .small: return .headerSSemibold
|
|
11
|
-
case .medium: return .headerDefaultBold
|
|
12
|
-
case .large: return .headerMBold
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public struct Collapse<Content: View>: View {
|
|
18
|
-
@Environment(\.appTheme) private var theme
|
|
19
|
-
|
|
20
|
-
private let title: String
|
|
21
|
-
private let description: String?
|
|
22
|
-
private let image: String?
|
|
23
|
-
private let imageSize: CGFloat
|
|
24
|
-
private let subTitle: String?
|
|
25
|
-
private let tagLabel: String?
|
|
26
|
-
private let tagColor: Tag.TagColor
|
|
27
|
-
private let showBorder: Bool
|
|
28
|
-
private let expandDefault: Bool
|
|
29
|
-
private let titleSize: CollapseTitleSize
|
|
30
|
-
private let useBackgroundCollapseButton: Bool
|
|
31
|
-
private let backgroundColor: Color?
|
|
32
|
-
private let titleColor: Color?
|
|
33
|
-
private let onPress: ((Bool) -> Void)?
|
|
34
|
-
private let content: (() -> Content)?
|
|
35
|
-
|
|
36
|
-
@State private var expanded: Bool
|
|
37
|
-
|
|
38
|
-
public init(
|
|
39
|
-
title: String,
|
|
40
|
-
description: String? = nil,
|
|
41
|
-
image: String? = nil,
|
|
42
|
-
imageSize: CGFloat = 24,
|
|
43
|
-
subTitle: String? = nil,
|
|
44
|
-
tagLabel: String? = nil,
|
|
45
|
-
tagColor: Tag.TagColor = .default,
|
|
46
|
-
showBorder: Bool = false,
|
|
47
|
-
expandDefault: Bool = false,
|
|
48
|
-
titleSize: CollapseTitleSize = .medium,
|
|
49
|
-
useBackgroundCollapseButton: Bool = false,
|
|
50
|
-
backgroundColor: Color? = nil,
|
|
51
|
-
titleColor: Color? = nil,
|
|
52
|
-
onPress: ((Bool) -> Void)? = nil,
|
|
53
|
-
@ViewBuilder content: @escaping () -> Content
|
|
54
|
-
) {
|
|
55
|
-
self.title = title
|
|
56
|
-
self.description = description
|
|
57
|
-
self.image = image
|
|
58
|
-
self.imageSize = imageSize
|
|
59
|
-
self.subTitle = subTitle
|
|
60
|
-
self.tagLabel = tagLabel
|
|
61
|
-
self.tagColor = tagColor
|
|
62
|
-
self.showBorder = showBorder
|
|
63
|
-
self.expandDefault = expandDefault
|
|
64
|
-
self.titleSize = titleSize
|
|
65
|
-
self.useBackgroundCollapseButton = useBackgroundCollapseButton
|
|
66
|
-
self.backgroundColor = backgroundColor
|
|
67
|
-
self.titleColor = titleColor
|
|
68
|
-
self.onPress = onPress
|
|
69
|
-
self.content = content
|
|
70
|
-
_expanded = State(initialValue: expandDefault)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private var resolvedBackgroundColor: Color {
|
|
74
|
-
backgroundColor ?? theme.colors.background.surface
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public var body: some View {
|
|
78
|
-
VStack(spacing: 0) {
|
|
79
|
-
header
|
|
80
|
-
|
|
81
|
-
if let content {
|
|
82
|
-
if expanded {
|
|
83
|
-
VStack(spacing: 0) {
|
|
84
|
-
content()
|
|
85
|
-
}
|
|
86
|
-
.frame(maxWidth: .infinity)
|
|
87
|
-
.overlay(
|
|
88
|
-
showBorder
|
|
89
|
-
? RoundedRectangle(cornerRadius: 0)
|
|
90
|
-
.stroke(theme.colors.border.default, lineWidth: 1)
|
|
91
|
-
: nil
|
|
92
|
-
)
|
|
93
|
-
.transition(.move(edge: .top).combined(with: .opacity))
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
.frame(maxWidth: .infinity)
|
|
98
|
-
.background(resolvedBackgroundColor)
|
|
99
|
-
.clipShape(RoundedRectangle(cornerRadius: Radius.S, style: .continuous))
|
|
100
|
-
.overlay(
|
|
101
|
-
showBorder
|
|
102
|
-
? RoundedRectangle(cornerRadius: Radius.S, style: .continuous)
|
|
103
|
-
.stroke(theme.colors.border.default, lineWidth: 1)
|
|
104
|
-
: nil
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private var header: some View {
|
|
109
|
-
SwiftUI.Button(action: {
|
|
110
|
-
onPress?(expanded)
|
|
111
|
-
withAnimation(.easeInOut(duration: 0.3)) {
|
|
112
|
-
expanded.toggle()
|
|
113
|
-
}
|
|
114
|
-
}) {
|
|
115
|
-
HStack(alignment: .top, spacing: 0) {
|
|
116
|
-
if let image {
|
|
117
|
-
ImageView(image, contentMode: .fill)
|
|
118
|
-
.frame(width: imageSize, height: imageSize)
|
|
119
|
-
.clipShape(RoundedRectangle(cornerRadius: Radius.XS, style: .continuous))
|
|
120
|
-
Spacer().frame(width: Spacing.S)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
VStack(alignment: .leading, spacing: 0) {
|
|
124
|
-
MomoText(
|
|
125
|
-
title,
|
|
126
|
-
typography: titleSize.typography,
|
|
127
|
-
color: titleColor ?? theme.colors.text.default
|
|
128
|
-
)
|
|
129
|
-
if let description {
|
|
130
|
-
MomoText(
|
|
131
|
-
description,
|
|
132
|
-
typography: .bodyDefaultRegular,
|
|
133
|
-
color: theme.colors.text.secondary
|
|
134
|
-
)
|
|
135
|
-
.lineLimit(2)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
.frame(maxWidth: .infinity, alignment: .leading)
|
|
139
|
-
|
|
140
|
-
if subTitle != nil || tagLabel != nil {
|
|
141
|
-
Spacer().frame(width: Spacing.S)
|
|
142
|
-
if let subTitle {
|
|
143
|
-
MomoText(
|
|
144
|
-
subTitle,
|
|
145
|
-
typography: .bodyDefaultRegular,
|
|
146
|
-
color: theme.colors.text.secondary
|
|
147
|
-
)
|
|
148
|
-
.lineLimit(1)
|
|
149
|
-
} else if let tagLabel {
|
|
150
|
-
Tag(label: tagLabel, color: tagColor)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
Spacer().frame(width: Spacing.S)
|
|
155
|
-
chevron
|
|
156
|
-
}
|
|
157
|
-
.padding(.horizontal, Spacing.M)
|
|
158
|
-
.padding(.vertical, Spacing.S)
|
|
159
|
-
.frame(maxWidth: .infinity)
|
|
160
|
-
.contentShape(Rectangle())
|
|
161
|
-
}
|
|
162
|
-
.buttonStyle(.plain)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
private var chevron: some View {
|
|
166
|
-
Group {
|
|
167
|
-
if useBackgroundCollapseButton {
|
|
168
|
-
Icon(source: "arrow_chevron_down_small", size: 16, color: theme.colors.primary)
|
|
169
|
-
.rotationEffect(.degrees(expanded ? 180 : 0))
|
|
170
|
-
.frame(width: 24, height: 24)
|
|
171
|
-
.background(
|
|
172
|
-
RoundedRectangle(cornerRadius: Radius.M, style: .continuous)
|
|
173
|
-
.fill(theme.colors.background.tonal)
|
|
174
|
-
)
|
|
175
|
-
} else {
|
|
176
|
-
Icon(source: "arrow_chevron_down_small", size: 24, color: theme.colors.text.default)
|
|
177
|
-
.rotationEffect(.degrees(expanded ? 180 : 0))
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
.animation(.easeInOut(duration: 0.3), value: expanded)
|
|
181
|
-
}
|
|
182
|
-
}
|