@momo-kits/native-kits 0.162.18-debug → 0.162.19-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/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +11 -0
- package/ios/Application/Components.swift +34 -44
- package/ios/Application/FloatingButton.swift +10 -9
- package/ios/Application/HeaderRight.swift +79 -45
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +103 -0
- package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +215 -0
- package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +65 -0
- package/ios/Application/Navigation/HeaderBackProps.swift +66 -0
- package/ios/Application/Navigation/HeaderTitle.swift +57 -0
- package/ios/Application/Navigation/HeaderUser.swift +209 -0
- package/ios/Application/Navigation/NavigationContainer.swift +176 -0
- package/ios/Application/Navigation/NavigationOptions.swift +109 -0
- package/ios/Application/Navigation/Navigator.swift +364 -0
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +188 -0
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +68 -0
- package/ios/Application/Navigation/Overplay/SnackBar.swift +144 -0
- package/ios/Application/Navigation/component/Header.swift +178 -0
- package/ios/Application/Navigation/component/HeaderBackground.swift +83 -0
- package/ios/Application/Navigation/component/HeaderColor.swift +65 -0
- package/ios/Application/Screen.swift +2 -1
- package/ios/Application/StackScreen.swift +453 -0
- package/ios/Avatar/Avatar.swift +193 -0
- package/ios/Badge/Badge.swift +11 -14
- package/ios/Badge/BadgeRibbon.swift +12 -21
- package/ios/BaselineView/BaselineView.swift +163 -0
- package/ios/Button/Button.swift +61 -22
- package/ios/Carousel/Carousel.swift +181 -0
- package/ios/Checkbox/Checkbox.swift +14 -13
- package/ios/Chip/Chip.swift +23 -9
- package/ios/Collapse/Collapse.swift +182 -0
- package/ios/Colors+Radius+Spacing/Colors.swift +12 -12
- package/ios/Colors+Radius+Spacing/Theme.swift +295 -0
- package/ios/DateTimePicker/DateTimePicker.swift +210 -0
- package/ios/DateTimePicker/DateTimePickerTypes.swift +55 -0
- package/ios/DateTimePicker/DateTimePickerUtils.swift +167 -0
- package/ios/DateTimePicker/WheelPicker.swift +161 -0
- package/ios/Divider/Divider.swift +16 -0
- package/ios/Extensions/Color++.swift +32 -0
- package/ios/Icon/Icon.swift +6 -1
- package/ios/IconButton/IconButton.swift +112 -0
- package/ios/Input/Input.swift +41 -25
- package/ios/Input/InputPhoneNumber.swift +20 -19
- package/ios/Input/InputSearch.swift +100 -47
- package/ios/Input/InputTextArea.swift +66 -40
- package/ios/InputDropDown/InputDropDown.swift +198 -0
- package/ios/InputMoney/InputMoney.swift +335 -0
- package/ios/InputOTP/InputOTP.swift +210 -0
- package/ios/Loader/Loader.swift +113 -0
- package/ios/MoMoUIKits.podspec +5 -0
- package/ios/Pagination/PaginationDot.swift +61 -0
- package/ios/Pagination/PaginationNumber.swift +35 -0
- package/ios/Pagination/PaginationScroll.swift +101 -0
- package/ios/Pagination/PaginationWhiteDot.swift +37 -0
- package/ios/Popup/PopupDisplay.swift +8 -16
- package/ios/Popup/PopupInput.swift +2 -8
- package/ios/Popup/PopupNotify.swift +219 -0
- package/ios/ProgressInfo/ProgressInfo.swift +294 -0
- package/ios/Radio/Radio.swift +70 -0
- package/ios/Rating/Rating.swift +82 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +6 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +9 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +38 -0
- package/ios/Skeleton/Skeleton.swift +99 -0
- package/ios/Slider/Slider.swift +237 -0
- package/ios/Stepper/Stepper.swift +220 -0
- package/ios/Steps/Steps.swift +451 -0
- package/ios/SuggestAction/SuggestAction.swift +97 -0
- package/ios/Swipeable/SwipeCell.swift +185 -0
- package/ios/Swipeable/SwipeCellModel.swift +21 -0
- package/ios/TabView/TabView.swift +530 -0
- package/ios/Tag/Tag.swift +98 -0
- package/ios/Title/Title.swift +269 -0
- package/ios/Tooltip/Tooltip.swift +482 -0
- package/ios/Typography/Text.swift +76 -5
- package/ios/Uploader/Uploader.swift +183 -0
- package/ios/native-kits.podspec +61 -8
- package/ios-demo/MoMoUIKitsDemo.podspec +20 -0
- package/ios-demo/README.md +120 -0
- package/ios-demo/Resources/dot_loading.json +558 -0
- package/ios-demo/Resources/icon.json +4052 -0
- package/ios-demo/Resources/lottie_circle_loader.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +48 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +25 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +26 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +19 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +33 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +48 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +21 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +17 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +28 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +31 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +24 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +110 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +93 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +269 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +117 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +89 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +100 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +126 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +63 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +20 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +93 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +107 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +124 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +14 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +49 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +278 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +58 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +78 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +138 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +111 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +136 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +107 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +73 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +100 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +32 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +57 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +70 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +227 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +72 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +175 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +121 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +76 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +89 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +32 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +56 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +32 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +150 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +138 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +103 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +94 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +79 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +152 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +33 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +190 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +34 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +182 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +109 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +187 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +87 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +131 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +51 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +15 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +73 -0
- package/package.json +1 -1
- package/publish.sh +50 -0
- package/scripts/gen-ios-color.mjs +136 -0
|
@@ -12,6 +12,12 @@ public let DEFAULT_HEIGHT: CGFloat = 104
|
|
|
12
12
|
|
|
13
13
|
struct UITextViewWrapper: UIViewRepresentable {
|
|
14
14
|
@Binding var text: String
|
|
15
|
+
var maxLength: Int
|
|
16
|
+
var textColor: Color
|
|
17
|
+
var cursorColor: Color
|
|
18
|
+
var fontWeight: Font.Weight
|
|
19
|
+
var disabled: Bool
|
|
20
|
+
var onChangeText: (String) -> Void
|
|
15
21
|
var onDone: (() -> Void)?
|
|
16
22
|
var onFocus: (() -> Void)?
|
|
17
23
|
var onBlur: (() -> Void)?
|
|
@@ -19,11 +25,20 @@ struct UITextViewWrapper: UIViewRepresentable {
|
|
|
19
25
|
func makeUIView(context: Context) -> UITextView {
|
|
20
26
|
let textView = UITextView()
|
|
21
27
|
textView.delegate = context.coordinator
|
|
28
|
+
textView.backgroundColor = .clear
|
|
29
|
+
textView.textContainerInset = .zero
|
|
30
|
+
textView.textContainer.lineFragmentPadding = 0
|
|
22
31
|
return textView
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
func updateUIView(_ uiView: UITextView, context: Context) {
|
|
26
|
-
uiView.text
|
|
35
|
+
if uiView.text != text {
|
|
36
|
+
uiView.text = text
|
|
37
|
+
}
|
|
38
|
+
uiView.textColor = UIColor(textColor)
|
|
39
|
+
uiView.tintColor = UIColor(cursorColor)
|
|
40
|
+
uiView.font = UIFont.systemFont(ofSize: scaleSize(16), weight: fontWeight == .bold ? .bold : .regular)
|
|
41
|
+
uiView.isEditable = !disabled
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
func makeCoordinator() -> Coordinator {
|
|
@@ -38,7 +53,12 @@ struct UITextViewWrapper: UIViewRepresentable {
|
|
|
38
53
|
}
|
|
39
54
|
|
|
40
55
|
func textViewDidChange(_ textView: UITextView) {
|
|
41
|
-
|
|
56
|
+
let limited = String(textView.text.prefix(parent.maxLength))
|
|
57
|
+
if textView.text != limited {
|
|
58
|
+
textView.text = limited
|
|
59
|
+
}
|
|
60
|
+
parent.text = limited
|
|
61
|
+
parent.onChangeText(limited)
|
|
42
62
|
}
|
|
43
63
|
|
|
44
64
|
func textViewDidBeginEditing(_ textView: UITextView) {
|
|
@@ -54,27 +74,31 @@ struct UITextViewWrapper: UIViewRepresentable {
|
|
|
54
74
|
parent.onDone?()
|
|
55
75
|
return false
|
|
56
76
|
}
|
|
57
|
-
|
|
77
|
+
let current = textView.text ?? ""
|
|
78
|
+
guard let range = Range(range, in: current) else { return false }
|
|
79
|
+
let proposed = current.replacingCharacters(in: range, with: text)
|
|
80
|
+
return proposed.count <= parent.maxLength
|
|
58
81
|
}
|
|
59
82
|
}
|
|
60
83
|
}
|
|
61
84
|
|
|
62
85
|
// Make the struct public
|
|
63
86
|
public struct InputTextArea: View {
|
|
87
|
+
@Environment(\.appTheme) private var theme
|
|
64
88
|
@Binding var text: String
|
|
65
89
|
var maxLength: Int = MAX_LENGTH
|
|
66
90
|
var height: CGFloat = DEFAULT_HEIGHT
|
|
67
91
|
var floatingValue: String = ""
|
|
68
|
-
var floatingValueColor: Color
|
|
92
|
+
var floatingValueColor: Color?
|
|
69
93
|
var floatingIcon: String = ""
|
|
70
|
-
var floatingIconColor: Color
|
|
94
|
+
var floatingIconColor: Color?
|
|
71
95
|
var placeholder: String = ""
|
|
72
96
|
var onChangeText: (String) -> Void = { _ in }
|
|
73
97
|
var error: String = ""
|
|
74
98
|
var errorSpacing: Bool = false
|
|
75
99
|
var disabled: Bool = false
|
|
76
100
|
var icon: String = ""
|
|
77
|
-
var iconColor: Color
|
|
101
|
+
var iconColor: Color?
|
|
78
102
|
var onRightIconPressed: () -> Void = {}
|
|
79
103
|
var onFocus: () -> Void = {}
|
|
80
104
|
var onBlur: () -> Void = {}
|
|
@@ -92,16 +116,16 @@ public struct InputTextArea: View {
|
|
|
92
116
|
maxLength: Int = MAX_LENGTH,
|
|
93
117
|
height: CGFloat = DEFAULT_HEIGHT,
|
|
94
118
|
floatingValue: String = "",
|
|
95
|
-
floatingValueColor: Color =
|
|
119
|
+
floatingValueColor: Color? = nil,
|
|
96
120
|
floatingIcon: String = "",
|
|
97
|
-
floatingIconColor: Color =
|
|
121
|
+
floatingIconColor: Color? = nil,
|
|
98
122
|
placeholder: String = "",
|
|
99
123
|
onChangeText: @escaping (String) -> Void = { _ in },
|
|
100
124
|
error: String = "",
|
|
101
125
|
errorSpacing: Bool = false,
|
|
102
126
|
disabled: Bool = false,
|
|
103
127
|
icon: String = "",
|
|
104
|
-
iconColor: Color =
|
|
128
|
+
iconColor: Color? = nil,
|
|
105
129
|
onRightIconPressed: @escaping () -> Void = {},
|
|
106
130
|
onFocus: @escaping () -> Void = {},
|
|
107
131
|
onBlur: @escaping () -> Void = {},
|
|
@@ -138,24 +162,27 @@ public struct InputTextArea: View {
|
|
|
138
162
|
ZStack(alignment: .topLeading) {
|
|
139
163
|
if !floatingValue.isEmpty || !floatingIcon.isEmpty {
|
|
140
164
|
HStack(spacing: 4) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
165
|
+
MomoText(
|
|
166
|
+
floatingValue,
|
|
167
|
+
typography: .labelSMedium,
|
|
168
|
+
color: disabled ? theme.colors.text.disable : (floatingValueColor ?? theme.colors.text.hint)
|
|
169
|
+
)
|
|
144
170
|
|
|
145
171
|
if required {
|
|
146
|
-
|
|
147
|
-
.font(.caption)
|
|
148
|
-
.foregroundColor(.red)
|
|
172
|
+
MomoText("*", typography: .labelSMedium, color: theme.colors.error.primary)
|
|
149
173
|
}
|
|
150
174
|
|
|
151
175
|
if !floatingIcon.isEmpty {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
176
|
+
Icon(
|
|
177
|
+
source: floatingIcon,
|
|
178
|
+
size: 16,
|
|
179
|
+
color: disabled ? theme.colors.text.disable : (floatingIconColor ?? theme.colors.text.default)
|
|
180
|
+
)
|
|
181
|
+
.padding(.leading, Spacing.XS)
|
|
155
182
|
}
|
|
156
183
|
}
|
|
157
|
-
.padding(.horizontal,
|
|
158
|
-
.background(
|
|
184
|
+
.padding(.horizontal, Spacing.S)
|
|
185
|
+
.background(theme.colors.background.surface)
|
|
159
186
|
.offset(x: Spacing.S, y: -height / 10)
|
|
160
187
|
.zIndex(10)
|
|
161
188
|
}
|
|
@@ -164,13 +191,21 @@ public struct InputTextArea: View {
|
|
|
164
191
|
ZStack(alignment: .topLeading) {
|
|
165
192
|
if text.isEmpty {
|
|
166
193
|
Text(placeholder)
|
|
167
|
-
.foregroundColor(disabled ? .
|
|
194
|
+
.foregroundColor(disabled ? theme.colors.text.disable : theme.colors.text.hint)
|
|
168
195
|
.font(.system(size: 16, weight: fontWeight))
|
|
169
196
|
.padding(.horizontal, 16)
|
|
170
197
|
.padding(.vertical, 12)
|
|
171
198
|
}
|
|
172
199
|
|
|
173
|
-
UITextViewWrapper(
|
|
200
|
+
UITextViewWrapper(
|
|
201
|
+
text: $text,
|
|
202
|
+
maxLength: maxLength,
|
|
203
|
+
textColor: disabled ? theme.colors.text.disable : theme.colors.text.default,
|
|
204
|
+
cursorColor: theme.colors.primary,
|
|
205
|
+
fontWeight: fontWeight,
|
|
206
|
+
disabled: disabled,
|
|
207
|
+
onChangeText: onChangeText,
|
|
208
|
+
onDone: {
|
|
174
209
|
// Handle done action if needed
|
|
175
210
|
},
|
|
176
211
|
onFocus: {
|
|
@@ -188,27 +223,20 @@ public struct InputTextArea: View {
|
|
|
188
223
|
|
|
189
224
|
HStack {
|
|
190
225
|
Spacer()
|
|
191
|
-
|
|
192
|
-
.font(.caption)
|
|
193
|
-
.foregroundColor(.gray)
|
|
226
|
+
MomoText("\(text.count)/\(maxLength)", typography: .descriptionXsRegular, color: theme.colors.text.hint)
|
|
194
227
|
}
|
|
195
228
|
.padding(.horizontal, 16)
|
|
196
229
|
.padding(.bottom, 12)
|
|
197
230
|
}
|
|
198
|
-
.background(
|
|
199
|
-
.cornerRadius(
|
|
231
|
+
.background(theme.colors.background.surface)
|
|
232
|
+
.cornerRadius(Radius.S)
|
|
200
233
|
.overlay(
|
|
201
|
-
RoundedRectangle(cornerRadius:
|
|
234
|
+
RoundedRectangle(cornerRadius: Radius.S)
|
|
202
235
|
.stroke(borderColor, lineWidth: 1)
|
|
203
236
|
)
|
|
204
237
|
}
|
|
205
238
|
|
|
206
|
-
|
|
207
|
-
Text(error)
|
|
208
|
-
.font(.caption)
|
|
209
|
-
.foregroundColor(.red)
|
|
210
|
-
.padding(.top, errorSpacing ? 8 : 4)
|
|
211
|
-
}
|
|
239
|
+
ErrorView(errorMessage: error, errorSpacing: errorSpacing, hintText: "")
|
|
212
240
|
}
|
|
213
241
|
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { _ in
|
|
214
242
|
if !isBlurred {
|
|
@@ -228,16 +256,14 @@ public struct InputTextArea: View {
|
|
|
228
256
|
|
|
229
257
|
private var borderColor: Color {
|
|
230
258
|
if disabled {
|
|
231
|
-
return
|
|
259
|
+
return theme.colors.border.disable
|
|
232
260
|
} else if !error.isEmpty {
|
|
233
|
-
return .
|
|
261
|
+
return theme.colors.error.primary
|
|
234
262
|
} else if isFocused {
|
|
235
|
-
return
|
|
263
|
+
return theme.colors.primary
|
|
236
264
|
} else {
|
|
237
|
-
return
|
|
265
|
+
return theme.colors.border.default
|
|
238
266
|
}
|
|
239
267
|
|
|
240
268
|
}
|
|
241
269
|
}
|
|
242
|
-
|
|
243
|
-
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
//
|
|
2
|
+
// InputDropDown.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Hand-written SwiftUI reimplementation of Compose `InputDropDown`.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import SwiftUI
|
|
9
|
+
|
|
10
|
+
// MARK: - RenderRightIcon (mirrors Compose RenderRightIcon for InputDropDown)
|
|
11
|
+
|
|
12
|
+
private struct RenderRightIcon: View {
|
|
13
|
+
let loading: Bool
|
|
14
|
+
let icon: String
|
|
15
|
+
let color: Color
|
|
16
|
+
let onPressed: () -> Void
|
|
17
|
+
|
|
18
|
+
var body: some View {
|
|
19
|
+
if loading {
|
|
20
|
+
ActivityIndicator(isAnimating: .constant(true), style: .medium)
|
|
21
|
+
.frame(width: 16, height: 16)
|
|
22
|
+
} else if !icon.isEmpty {
|
|
23
|
+
SwiftUI.Button(action: onPressed) {
|
|
24
|
+
Icon(source: icon, size: 24, color: color)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// MARK: - InputDropDown
|
|
31
|
+
|
|
32
|
+
public struct InputDropDown: View {
|
|
33
|
+
@Environment(\.appTheme) private var theme
|
|
34
|
+
@Binding public var value: String
|
|
35
|
+
|
|
36
|
+
public var floatingValue: String
|
|
37
|
+
public var floatingValueColor: Color?
|
|
38
|
+
public var floatingIcon: String
|
|
39
|
+
public var floatingIconColor: Color?
|
|
40
|
+
public var placeholder: String
|
|
41
|
+
public var size: InputSize
|
|
42
|
+
public var onPress: () -> Void
|
|
43
|
+
public var hintText: String
|
|
44
|
+
public var error: String
|
|
45
|
+
public var errorSpacing: Bool
|
|
46
|
+
public var disabled: Bool
|
|
47
|
+
public var icon: String
|
|
48
|
+
public var iconColor: Color?
|
|
49
|
+
public var onRightIconPressed: () -> Void
|
|
50
|
+
public var leadingIcon: String
|
|
51
|
+
public var leadingIconColor: Color?
|
|
52
|
+
public var loading: Bool
|
|
53
|
+
public var required: Bool
|
|
54
|
+
|
|
55
|
+
public init(
|
|
56
|
+
value: Binding<String>,
|
|
57
|
+
floatingValue: String = "",
|
|
58
|
+
floatingValueColor: Color? = nil,
|
|
59
|
+
floatingIcon: String = "",
|
|
60
|
+
floatingIconColor: Color? = nil,
|
|
61
|
+
placeholder: String = "",
|
|
62
|
+
size: InputSize = .small,
|
|
63
|
+
onPress: @escaping () -> Void = {},
|
|
64
|
+
hintText: String = "",
|
|
65
|
+
error: String = "",
|
|
66
|
+
errorSpacing: Bool = false,
|
|
67
|
+
disabled: Bool = false,
|
|
68
|
+
icon: String = "arrow_chevron_down_small",
|
|
69
|
+
iconColor: Color? = nil,
|
|
70
|
+
onRightIconPressed: @escaping () -> Void = {},
|
|
71
|
+
leadingIcon: String = "",
|
|
72
|
+
leadingIconColor: Color? = nil,
|
|
73
|
+
loading: Bool = false,
|
|
74
|
+
required: Bool = false
|
|
75
|
+
) {
|
|
76
|
+
self._value = value
|
|
77
|
+
self.floatingValue = floatingValue
|
|
78
|
+
self.floatingValueColor = floatingValueColor
|
|
79
|
+
self.floatingIcon = floatingIcon
|
|
80
|
+
self.floatingIconColor = floatingIconColor
|
|
81
|
+
self.placeholder = placeholder
|
|
82
|
+
self.size = size
|
|
83
|
+
self.onPress = onPress
|
|
84
|
+
self.hintText = hintText
|
|
85
|
+
self.error = error
|
|
86
|
+
self.errorSpacing = errorSpacing
|
|
87
|
+
self.disabled = disabled
|
|
88
|
+
self.icon = icon
|
|
89
|
+
self.iconColor = iconColor
|
|
90
|
+
self.onRightIconPressed = onRightIconPressed
|
|
91
|
+
self.leadingIcon = leadingIcon
|
|
92
|
+
self.leadingIconColor = leadingIconColor
|
|
93
|
+
self.loading = loading
|
|
94
|
+
self.required = required
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public var body: some View {
|
|
98
|
+
VStack(alignment: .leading, spacing: 4) {
|
|
99
|
+
ZStack(alignment: .topLeading) {
|
|
100
|
+
// Floating label
|
|
101
|
+
if !floatingValue.isEmpty || !floatingIcon.isEmpty {
|
|
102
|
+
HStack(spacing: 0) {
|
|
103
|
+
MomoText(floatingValue, typography: .labelSMedium, color: floatingTitleColor)
|
|
104
|
+
if required {
|
|
105
|
+
MomoText("*", typography: .labelSMedium, color: theme.colors.error.primary)
|
|
106
|
+
}
|
|
107
|
+
if !floatingIcon.isEmpty {
|
|
108
|
+
Icon(source: floatingIcon, size: 16, color: floatingIconTintColor)
|
|
109
|
+
.padding(.leading, Spacing.XS)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
.padding(.horizontal, Spacing.S)
|
|
113
|
+
.background(theme.colors.background.surface)
|
|
114
|
+
.offset(x: Spacing.S, y: -8)
|
|
115
|
+
.zIndex(10)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Input container
|
|
119
|
+
HStack(alignment: .center, spacing: 0) {
|
|
120
|
+
if !leadingIcon.isEmpty {
|
|
121
|
+
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconTintColor)
|
|
122
|
+
.padding(.trailing, Spacing.M)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
MomoText(
|
|
126
|
+
value.isEmpty ? placeholder : value,
|
|
127
|
+
typography: .bodyDefaultRegular,
|
|
128
|
+
color: value.isEmpty ? placeholderColor : textColor
|
|
129
|
+
)
|
|
130
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
131
|
+
|
|
132
|
+
RenderRightIcon(
|
|
133
|
+
loading: loading,
|
|
134
|
+
icon: icon,
|
|
135
|
+
color: iconTintColor,
|
|
136
|
+
onPressed: onRightIconPressed
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
.padding(.horizontal, Spacing.M)
|
|
140
|
+
.frame(height: size == .small ? 48 : 56)
|
|
141
|
+
.overlay(
|
|
142
|
+
RoundedRectangle(cornerRadius: Radius.S)
|
|
143
|
+
.stroke(getBorderColor(isFocused: false, error: error, disabled: disabled), lineWidth: 1)
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
.contentShape(Rectangle())
|
|
147
|
+
.onTapGesture {
|
|
148
|
+
if !disabled { onPress() }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
ErrorView(
|
|
152
|
+
errorMessage: error,
|
|
153
|
+
errorSpacing: errorSpacing,
|
|
154
|
+
hintText: hintText
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
.accessibilityElement(children: .combine)
|
|
158
|
+
.accessibility(label: Text(floatingValue))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// MARK: - Computed colors
|
|
162
|
+
|
|
163
|
+
private var textColor: Color {
|
|
164
|
+
disabled ? theme.colors.text.disable : theme.colors.text.default
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private var placeholderColor: Color {
|
|
168
|
+
disabled ? theme.colors.text.disable : theme.colors.text.hint
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private var iconTintColor: Color {
|
|
172
|
+
disabled ? theme.colors.text.disable : (iconColor ?? theme.colors.text.default)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private var floatingTitleColor: Color {
|
|
176
|
+
disabled ? theme.colors.text.disable : (floatingValueColor ?? theme.colors.text.hint)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private var floatingIconTintColor: Color {
|
|
180
|
+
disabled ? theme.colors.text.disable : (floatingIconColor ?? theme.colors.text.default)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private var leadingIconTintColor: Color {
|
|
184
|
+
disabled ? theme.colors.text.disable : (leadingIconColor ?? theme.colors.text.hint)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private func getBorderColor(isFocused: Bool, error: String, disabled: Bool) -> Color {
|
|
188
|
+
if disabled {
|
|
189
|
+
return theme.colors.border.disable
|
|
190
|
+
} else if !error.isEmpty {
|
|
191
|
+
return theme.colors.error.primary
|
|
192
|
+
} else if isFocused {
|
|
193
|
+
return theme.colors.primary
|
|
194
|
+
} else {
|
|
195
|
+
return theme.colors.border.default
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|