@momo-kits/native-kits 0.152.4-beta.6 → 0.152.4-maxapi
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/CODE_OF_CONDUCT.md +133 -0
- package/CONTRIBUTING.md +114 -0
- package/LICENSE +20 -0
- package/README.md +7 -0
- package/build.gradle.kts +32 -0
- package/compose/MoMoComposeKits.podspec +54 -0
- package/compose/build.gradle.kts +149 -0
- package/compose/src/androidMain/AndroidManifest.xml +2 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +105 -0
- package/compose/src/commonMain/composeResources/files/lottie_circle_loader.json +1 -0
- package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +715 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +77 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +27 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +334 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +345 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +131 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +143 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +179 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +111 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +384 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +160 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +234 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +34 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +85 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +95 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +64 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +84 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +208 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +199 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +237 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +258 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +111 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +94 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +159 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScaleSizeScope.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +459 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +216 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +251 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +385 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +38 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +144 -0
- package/gradle.properties +19 -0
- package/gradlew +240 -0
- package/gradlew.bat +91 -0
- package/ios/Application/ApplicationEnvironment.swift +50 -0
- package/ios/Application/Components.swift +263 -0
- package/ios/Application/ComposeApi.swift +22 -0
- package/ios/Application/FloatingButton.swift +172 -0
- package/ios/Application/HeaderRight.swift +271 -0
- package/ios/Application/Screen.swift +249 -0
- package/ios/Badge/BadgeDot.swift +31 -0
- package/ios/Button/Button.swift +211 -0
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
- package/ios/Checkbox/Checkbox.swift +81 -0
- package/ios/Chip/Chip.swift +96 -0
- package/ios/Colors+Radius+Spacing/Colors.swift +172 -0
- package/ios/Colors+Radius+Spacing/Radius.swift +22 -0
- package/ios/Colors+Radius+Spacing/Spacing.swift +12 -0
- package/ios/Extensions/Color++.swift +25 -0
- package/ios/Icon/Icon.swift +51 -0
- package/ios/Image/Image.swift +70 -0
- package/ios/Input/Input.swift +207 -0
- package/ios/Input/InputPhoneNumber.swift +176 -0
- package/ios/Input/InputSearch.swift +238 -0
- package/ios/Input/InputTextArea.swift +242 -0
- package/ios/Lottie/LottieView.swift +86 -0
- package/ios/OTPKeyboard/KeyboardButton.swift +41 -0
- package/ios/OTPKeyboard/OTPKeyboard.swift +145 -0
- package/ios/Popup/PopupDisplay.swift +284 -0
- package/ios/Popup/PopupInput.swift +96 -0
- package/ios/Popup/PopupPromotion.swift +73 -0
- package/ios/PopupView/FullscreenPopup.swift +251 -0
- package/ios/PopupView/Modifiers.swift +158 -0
- package/ios/PopupView/PopupView.swift +289 -0
- package/ios/PopupView/Utils++.swift +281 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +110 -0
- package/ios/Swipeable/SwipeCell.swift +278 -0
- package/ios/Swipeable/SwipeCellModel.swift +86 -0
- package/ios/Switch/Switch.swift +44 -0
- package/ios/Template/Logo/Logo.swift +75 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +120 -0
- package/ios/Theme.md +18 -0
- package/ios/Typography/Text.swift +140 -0
- package/ios/Typography/Typography.swift +95 -0
- package/ios/native-kits.podspec +18 -0
- package/package.json +6 -7
- package/settings.gradle.kts +25 -0
- package/shared/build.gradle.kts +0 -74
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
//
|
|
2
|
+
// InputSearch.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by dung.pham2 on 3/12/24.
|
|
6
|
+
//
|
|
7
|
+
import SwiftUI
|
|
8
|
+
|
|
9
|
+
// MARK: - RenderRightIconSearch
|
|
10
|
+
|
|
11
|
+
struct RenderRightIconSearch: View {
|
|
12
|
+
let loading: Bool
|
|
13
|
+
let icon: String
|
|
14
|
+
let color: Color
|
|
15
|
+
let onClick: () -> Void
|
|
16
|
+
|
|
17
|
+
var body: some View {
|
|
18
|
+
HStack(spacing: 0) {
|
|
19
|
+
if loading {
|
|
20
|
+
ActivityIndicator(isAnimating: .constant(true), style: .medium)
|
|
21
|
+
.frame(width: 16, height: 16)
|
|
22
|
+
.padding(.horizontal, Spacing.S)
|
|
23
|
+
}
|
|
24
|
+
if !icon.isEmpty {
|
|
25
|
+
Divider()
|
|
26
|
+
.frame(width: 1)
|
|
27
|
+
.background(Colors.primary)
|
|
28
|
+
.padding(.leading, Spacing.S)
|
|
29
|
+
|
|
30
|
+
Image(systemName: icon)
|
|
31
|
+
.foregroundColor(color)
|
|
32
|
+
.frame(width: 24, height: 24)
|
|
33
|
+
.padding(.leading, Spacing.S)
|
|
34
|
+
.onTapGesture(perform: onClick)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public struct InputSearchProps {
|
|
41
|
+
@Binding var text: String
|
|
42
|
+
var buttonText: String = ""
|
|
43
|
+
var showButtonText: Bool = false
|
|
44
|
+
var showBorder: Bool = true
|
|
45
|
+
var placeholder: String = ""
|
|
46
|
+
var onChangeText: (String) -> Void = { _ in }
|
|
47
|
+
var onPressButtonText: () -> Void = {}
|
|
48
|
+
var error: String = ""
|
|
49
|
+
var disabled: Bool = false
|
|
50
|
+
var icon: String = ""
|
|
51
|
+
var iconColor: Color = Colors.text
|
|
52
|
+
var onRightIconPressed: () -> Void = {}
|
|
53
|
+
var onFocus: () -> Void = {}
|
|
54
|
+
var onBlur: () -> Void = {}
|
|
55
|
+
var loading: Bool = false
|
|
56
|
+
var fontWeight: Font.Weight = .regular
|
|
57
|
+
var keyboardType: UIKeyboardType = .default
|
|
58
|
+
|
|
59
|
+
public init(text: Binding<String>,
|
|
60
|
+
buttonText: String = "",
|
|
61
|
+
showButtonText: Bool = false,
|
|
62
|
+
showBorder: Bool = true,
|
|
63
|
+
placeholder: String = "",
|
|
64
|
+
onChangeText: @escaping (String) -> Void = { _ in },
|
|
65
|
+
onPressButtonText: @escaping () -> Void = {},
|
|
66
|
+
error: String = "",
|
|
67
|
+
disabled: Bool = false,
|
|
68
|
+
icon: String = "",
|
|
69
|
+
iconColor: Color = Colors.text,
|
|
70
|
+
onRightIconPressed: @escaping () -> Void = {},
|
|
71
|
+
onFocus: @escaping () -> Void = {},
|
|
72
|
+
onBlur: @escaping () -> Void = {},
|
|
73
|
+
loading: Bool = false,
|
|
74
|
+
fontWeight: Font.Weight = .regular,
|
|
75
|
+
keyboardType: UIKeyboardType = .default) {
|
|
76
|
+
self._text = text
|
|
77
|
+
self.buttonText = buttonText
|
|
78
|
+
self.showButtonText = showButtonText
|
|
79
|
+
self.showBorder = showBorder
|
|
80
|
+
self.placeholder = placeholder
|
|
81
|
+
self.onChangeText = onChangeText
|
|
82
|
+
self.onPressButtonText = onPressButtonText
|
|
83
|
+
self.error = error
|
|
84
|
+
self.disabled = disabled
|
|
85
|
+
self.icon = icon
|
|
86
|
+
self.iconColor = iconColor
|
|
87
|
+
self.onRightIconPressed = onRightIconPressed
|
|
88
|
+
self.onFocus = onFocus
|
|
89
|
+
self.onBlur = onBlur
|
|
90
|
+
self.loading = loading
|
|
91
|
+
self.fontWeight = fontWeight
|
|
92
|
+
self.keyboardType = keyboardType
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// MARK: - InputSearch
|
|
97
|
+
|
|
98
|
+
public struct InputSearch: View {
|
|
99
|
+
@Binding var text: String
|
|
100
|
+
var buttonText: String = ""
|
|
101
|
+
var showButtonText: Bool = false
|
|
102
|
+
var showBorder: Bool = true
|
|
103
|
+
var placeholder: String = ""
|
|
104
|
+
var onChangeText: (String) -> Void = { _ in }
|
|
105
|
+
var onPressButtonText: () -> Void = {}
|
|
106
|
+
var error: String = ""
|
|
107
|
+
var disabled: Bool = false
|
|
108
|
+
var icon: String = ""
|
|
109
|
+
var iconColor: Color = Colors.text
|
|
110
|
+
var onRightIconPressed: () -> Void = {}
|
|
111
|
+
var onFocus: () -> Void = {}
|
|
112
|
+
var onBlur: () -> Void = {}
|
|
113
|
+
var loading: Bool = false
|
|
114
|
+
var fontWeight: Font.Weight = .regular
|
|
115
|
+
var keyboardType: UIKeyboardType = .default
|
|
116
|
+
|
|
117
|
+
@State private var isFocused = false
|
|
118
|
+
@State private var isBlurred = false
|
|
119
|
+
|
|
120
|
+
public init(text: Binding<String>,
|
|
121
|
+
buttonText: String = "",
|
|
122
|
+
showButtonText: Bool = false,
|
|
123
|
+
showBorder: Bool = true,
|
|
124
|
+
placeholder: String = "",
|
|
125
|
+
onChangeText: @escaping (String) -> Void = { _ in },
|
|
126
|
+
onPressButtonText: @escaping () -> Void = {},
|
|
127
|
+
error: String = "",
|
|
128
|
+
disabled: Bool = false,
|
|
129
|
+
icon: String = "",
|
|
130
|
+
iconColor: Color = Colors.text,
|
|
131
|
+
onRightIconPressed: @escaping () -> Void = {},
|
|
132
|
+
onFocus: @escaping () -> Void = {},
|
|
133
|
+
onBlur: @escaping () -> Void = {},
|
|
134
|
+
loading: Bool = false,
|
|
135
|
+
fontWeight: Font.Weight = .regular,
|
|
136
|
+
keyboardType: UIKeyboardType = .default) {
|
|
137
|
+
self._text = text
|
|
138
|
+
self.buttonText = buttonText
|
|
139
|
+
self.showButtonText = showButtonText
|
|
140
|
+
self.showBorder = showBorder
|
|
141
|
+
self.placeholder = placeholder
|
|
142
|
+
self.onChangeText = onChangeText
|
|
143
|
+
self.onPressButtonText = onPressButtonText
|
|
144
|
+
self.error = error
|
|
145
|
+
self.disabled = disabled
|
|
146
|
+
self.icon = icon
|
|
147
|
+
self.iconColor = iconColor
|
|
148
|
+
self.onRightIconPressed = onRightIconPressed
|
|
149
|
+
self.onFocus = onFocus
|
|
150
|
+
self.onBlur = onBlur
|
|
151
|
+
self.loading = loading
|
|
152
|
+
self.fontWeight = fontWeight
|
|
153
|
+
self.keyboardType = keyboardType
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
public var body: some View {
|
|
158
|
+
VStack(alignment: .leading, spacing: 0) {
|
|
159
|
+
HStack(spacing: 0) {
|
|
160
|
+
HStack {
|
|
161
|
+
Image(systemName: "magnifyingglass")
|
|
162
|
+
.foregroundColor(Colors.black12)
|
|
163
|
+
.frame(width: 24, height: 24)
|
|
164
|
+
.padding(.trailing, Spacing.XS)
|
|
165
|
+
|
|
166
|
+
ZStack(alignment: .leading) {
|
|
167
|
+
if text.isEmpty {
|
|
168
|
+
Text(placeholder)
|
|
169
|
+
.foregroundColor(disabled ? Colors.black08 : Colors.black12)
|
|
170
|
+
.font(.system(size: 16, weight: fontWeight))
|
|
171
|
+
}
|
|
172
|
+
TextField("", text: $text, onEditingChanged: { editing in
|
|
173
|
+
isFocused = editing
|
|
174
|
+
if editing {
|
|
175
|
+
onFocus()
|
|
176
|
+
} else if isBlurred {
|
|
177
|
+
onBlur()
|
|
178
|
+
}
|
|
179
|
+
if editing && !isBlurred {
|
|
180
|
+
isBlurred = true
|
|
181
|
+
}
|
|
182
|
+
}, onCommit: {})
|
|
183
|
+
.disabled(disabled)
|
|
184
|
+
.foregroundColor(disabled ? Colors.black08 : Colors.black17)
|
|
185
|
+
.font(.system(size: 15, weight: fontWeight))
|
|
186
|
+
.keyboardType(keyboardType)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if isFocused && !text.isEmpty {
|
|
190
|
+
SwiftButton(action: { text = "" }) {
|
|
191
|
+
Image(systemName: "xmark.circle.fill")
|
|
192
|
+
.foregroundColor(Colors.black12)
|
|
193
|
+
.frame(width: 16, height: 16)
|
|
194
|
+
}
|
|
195
|
+
.padding(.leading, Spacing.S)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
RenderRightIconSearch(loading: loading, icon: icon, color: disabled ? Colors.black08 : iconColor, onClick: onRightIconPressed)
|
|
199
|
+
}
|
|
200
|
+
.padding(.horizontal, Spacing.M)
|
|
201
|
+
.padding(.vertical, Spacing.S)
|
|
202
|
+
.background(Colors.black01)
|
|
203
|
+
.cornerRadius(Radius.XL)
|
|
204
|
+
.overlay(
|
|
205
|
+
RoundedRectangle(cornerRadius: Radius.XL)
|
|
206
|
+
.stroke(getBorderColor(isFocused: isFocused, error: error, disabled: disabled), lineWidth: showBorder ? 1 : 0)
|
|
207
|
+
)
|
|
208
|
+
.frame(maxWidth: showButtonText ? .infinity : nil, alignment: .leading)
|
|
209
|
+
|
|
210
|
+
if showButtonText {
|
|
211
|
+
SwiftButton(action: onPressButtonText) {
|
|
212
|
+
Text(buttonText)
|
|
213
|
+
.foregroundColor(Colors.black17)
|
|
214
|
+
.font(.system(size: 14, weight: .medium))
|
|
215
|
+
}
|
|
216
|
+
.padding(.leading, Spacing.L)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// MARK: - Helper Functions
|
|
224
|
+
|
|
225
|
+
func getBorderColor(isFocused: Bool, error: String, disabled: Bool) -> Color {
|
|
226
|
+
if disabled {
|
|
227
|
+
return Colors.black08
|
|
228
|
+
} else if !error.isEmpty {
|
|
229
|
+
return Colors.red03
|
|
230
|
+
} else if isFocused {
|
|
231
|
+
return Colors.primary
|
|
232
|
+
} else {
|
|
233
|
+
return Colors.black04
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
//
|
|
2
|
+
// InputTextArea.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by dung.pham2 on 2/12/24.
|
|
6
|
+
//
|
|
7
|
+
import SwiftUI
|
|
8
|
+
|
|
9
|
+
// Make these constants public
|
|
10
|
+
public let MAX_LENGTH = 300
|
|
11
|
+
public let DEFAULT_HEIGHT: CGFloat = 104
|
|
12
|
+
|
|
13
|
+
struct UITextViewWrapper: UIViewRepresentable {
|
|
14
|
+
@Binding var text: String
|
|
15
|
+
var onDone: (() -> Void)?
|
|
16
|
+
var onFocus: (() -> Void)?
|
|
17
|
+
var onBlur: (() -> Void)?
|
|
18
|
+
|
|
19
|
+
func makeUIView(context: Context) -> UITextView {
|
|
20
|
+
let textView = UITextView()
|
|
21
|
+
textView.delegate = context.coordinator
|
|
22
|
+
return textView
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
func updateUIView(_ uiView: UITextView, context: Context) {
|
|
26
|
+
uiView.text = text
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
func makeCoordinator() -> Coordinator {
|
|
30
|
+
Coordinator(self)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Coordinator: NSObject, UITextViewDelegate {
|
|
34
|
+
var parent: UITextViewWrapper
|
|
35
|
+
|
|
36
|
+
init(_ parent: UITextViewWrapper) {
|
|
37
|
+
self.parent = parent
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
func textViewDidChange(_ textView: UITextView) {
|
|
41
|
+
parent.text = textView.text
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func textViewDidBeginEditing(_ textView: UITextView) {
|
|
45
|
+
parent.onFocus?()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
func textViewDidEndEditing(_ textView: UITextView) {
|
|
49
|
+
parent.onBlur?()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
|
|
53
|
+
if text == "\n" {
|
|
54
|
+
parent.onDone?()
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Make the struct public
|
|
63
|
+
public struct InputTextArea: View {
|
|
64
|
+
@Binding var text: String
|
|
65
|
+
var maxLength: Int = MAX_LENGTH
|
|
66
|
+
var height: CGFloat = DEFAULT_HEIGHT
|
|
67
|
+
var floatingValue: String = ""
|
|
68
|
+
var floatingValueColor: Color = .gray
|
|
69
|
+
var floatingIcon: String = ""
|
|
70
|
+
var floatingIconColor: Color = .black
|
|
71
|
+
var placeholder: String = ""
|
|
72
|
+
var onChangeText: (String) -> Void = { _ in }
|
|
73
|
+
var error: String = ""
|
|
74
|
+
var errorSpacing: Bool = false
|
|
75
|
+
var disabled: Bool = false
|
|
76
|
+
var icon: String = ""
|
|
77
|
+
var iconColor: Color = .black
|
|
78
|
+
var onRightIconPressed: () -> Void = {}
|
|
79
|
+
var onFocus: () -> Void = {}
|
|
80
|
+
var onBlur: () -> Void = {}
|
|
81
|
+
var loading: Bool = false
|
|
82
|
+
var required: Bool = false
|
|
83
|
+
var fontWeight: Font.Weight = .regular
|
|
84
|
+
var keyboardType: UIKeyboardType = .default
|
|
85
|
+
|
|
86
|
+
@State private var isFocused = false
|
|
87
|
+
@State private var isBlurred = false
|
|
88
|
+
|
|
89
|
+
// Make the initializer public
|
|
90
|
+
public init(
|
|
91
|
+
text: Binding<String>,
|
|
92
|
+
maxLength: Int = MAX_LENGTH,
|
|
93
|
+
height: CGFloat = DEFAULT_HEIGHT,
|
|
94
|
+
floatingValue: String = "",
|
|
95
|
+
floatingValueColor: Color = .gray,
|
|
96
|
+
floatingIcon: String = "",
|
|
97
|
+
floatingIconColor: Color = .black,
|
|
98
|
+
placeholder: String = "",
|
|
99
|
+
onChangeText: @escaping (String) -> Void = { _ in },
|
|
100
|
+
error: String = "",
|
|
101
|
+
errorSpacing: Bool = false,
|
|
102
|
+
disabled: Bool = false,
|
|
103
|
+
icon: String = "",
|
|
104
|
+
iconColor: Color = Colors.pink03,
|
|
105
|
+
onRightIconPressed: @escaping () -> Void = {},
|
|
106
|
+
onFocus: @escaping () -> Void = {},
|
|
107
|
+
onBlur: @escaping () -> Void = {},
|
|
108
|
+
loading: Bool = false,
|
|
109
|
+
required: Bool = false,
|
|
110
|
+
fontWeight: Font.Weight = .regular,
|
|
111
|
+
keyboardType: UIKeyboardType = .default
|
|
112
|
+
) {
|
|
113
|
+
self._text = text
|
|
114
|
+
self.maxLength = maxLength
|
|
115
|
+
self.height = height
|
|
116
|
+
self.floatingValue = floatingValue
|
|
117
|
+
self.floatingValueColor = floatingValueColor
|
|
118
|
+
self.floatingIcon = floatingIcon
|
|
119
|
+
self.floatingIconColor = floatingIconColor
|
|
120
|
+
self.placeholder = placeholder
|
|
121
|
+
self.onChangeText = onChangeText
|
|
122
|
+
self.error = error
|
|
123
|
+
self.errorSpacing = errorSpacing
|
|
124
|
+
self.disabled = disabled
|
|
125
|
+
self.icon = icon
|
|
126
|
+
self.iconColor = iconColor
|
|
127
|
+
self.onRightIconPressed = onRightIconPressed
|
|
128
|
+
self.onFocus = onFocus
|
|
129
|
+
self.onBlur = onBlur
|
|
130
|
+
self.loading = loading
|
|
131
|
+
self.required = required
|
|
132
|
+
self.fontWeight = fontWeight
|
|
133
|
+
self.keyboardType = keyboardType
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public var body: some View {
|
|
137
|
+
VStack(alignment: .leading, spacing: 0) {
|
|
138
|
+
ZStack(alignment: .topLeading) {
|
|
139
|
+
if !floatingValue.isEmpty || !floatingIcon.isEmpty {
|
|
140
|
+
HStack(spacing: 4) {
|
|
141
|
+
Text(floatingValue)
|
|
142
|
+
.font(.caption)
|
|
143
|
+
.foregroundColor(disabled ? .gray : floatingValueColor)
|
|
144
|
+
|
|
145
|
+
if required {
|
|
146
|
+
Text("*")
|
|
147
|
+
.font(.caption)
|
|
148
|
+
.foregroundColor(.red)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if !floatingIcon.isEmpty {
|
|
152
|
+
Image(systemName: floatingIcon)
|
|
153
|
+
.font(.caption)
|
|
154
|
+
.foregroundColor(disabled ? .gray : floatingIconColor)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
.padding(.horizontal, 8)
|
|
158
|
+
.background(Colors.black01)
|
|
159
|
+
.offset(x: Spacing.S, y: -height / 10)
|
|
160
|
+
.zIndex(10)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
VStack {
|
|
164
|
+
ZStack(alignment: .topLeading) {
|
|
165
|
+
if text.isEmpty {
|
|
166
|
+
Text(placeholder)
|
|
167
|
+
.foregroundColor(disabled ? .gray : .gray)
|
|
168
|
+
.font(.system(size: 16, weight: fontWeight))
|
|
169
|
+
.padding(.horizontal, 16)
|
|
170
|
+
.padding(.vertical, 12)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
UITextViewWrapper(text: $text, onDone: {
|
|
174
|
+
// Handle done action if needed
|
|
175
|
+
},
|
|
176
|
+
onFocus: {
|
|
177
|
+
isFocused = true
|
|
178
|
+
onFocus()
|
|
179
|
+
}, onBlur: {
|
|
180
|
+
isFocused = false
|
|
181
|
+
isBlurred = true
|
|
182
|
+
onBlur()
|
|
183
|
+
})
|
|
184
|
+
.frame(height: height)
|
|
185
|
+
.padding(.horizontal, 12)
|
|
186
|
+
.padding(.vertical, 8)
|
|
187
|
+
.disabled(disabled) }
|
|
188
|
+
|
|
189
|
+
HStack {
|
|
190
|
+
Spacer()
|
|
191
|
+
Text("\(text.count)/\(maxLength)")
|
|
192
|
+
.font(.caption)
|
|
193
|
+
.foregroundColor(.gray)
|
|
194
|
+
}
|
|
195
|
+
.padding(.horizontal, 16)
|
|
196
|
+
.padding(.bottom, 12)
|
|
197
|
+
}
|
|
198
|
+
.background(Color.white)
|
|
199
|
+
.cornerRadius(8)
|
|
200
|
+
.overlay(
|
|
201
|
+
RoundedRectangle(cornerRadius: 8)
|
|
202
|
+
.stroke(borderColor, lineWidth: 1)
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if !error.isEmpty {
|
|
207
|
+
Text(error)
|
|
208
|
+
.font(.caption)
|
|
209
|
+
.foregroundColor(.red)
|
|
210
|
+
.padding(.top, errorSpacing ? 8 : 4)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { _ in
|
|
214
|
+
if !isBlurred {
|
|
215
|
+
isFocused = true
|
|
216
|
+
onFocus()
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification)) { _ in
|
|
220
|
+
if isFocused {
|
|
221
|
+
isFocused = false
|
|
222
|
+
isBlurred = true
|
|
223
|
+
onBlur()
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private var borderColor: Color {
|
|
229
|
+
if disabled {
|
|
230
|
+
return Colors.black03
|
|
231
|
+
} else if !error.isEmpty {
|
|
232
|
+
return .red
|
|
233
|
+
} else if isFocused {
|
|
234
|
+
return Colors.pink03
|
|
235
|
+
} else {
|
|
236
|
+
return Colors.border
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LottieView.swift
|
|
3
|
+
// MoMoPlatform
|
|
4
|
+
//
|
|
5
|
+
// Created by thanhdat on 16/01/2023.
|
|
6
|
+
// Copyright © 2023 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import SwiftUI
|
|
10
|
+
import Lottie
|
|
11
|
+
|
|
12
|
+
struct LottieView: UIViewRepresentable {
|
|
13
|
+
var name: String = ""
|
|
14
|
+
var url: String?
|
|
15
|
+
var loopMode: LottieLoopMode = .playOnce
|
|
16
|
+
var contentMode : UIView.ContentMode = .scaleAspectFit
|
|
17
|
+
var onDone: (() -> Void)?
|
|
18
|
+
|
|
19
|
+
// Add static cache for animations
|
|
20
|
+
private static var animationCache = NSCache<NSString, LottieAnimation>()
|
|
21
|
+
|
|
22
|
+
func makeUIView(context: UIViewRepresentableContext<LottieView>) -> UIView {
|
|
23
|
+
let view = UIView(frame: .zero)
|
|
24
|
+
|
|
25
|
+
// Configure Lottie with optimized settings
|
|
26
|
+
let configuration = LottieConfiguration(
|
|
27
|
+
renderingEngine: .coreAnimation,
|
|
28
|
+
decodingStrategy: .dictionaryBased
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
let animationView = LottieAnimationView(configuration: configuration)
|
|
32
|
+
|
|
33
|
+
if let url = url {
|
|
34
|
+
// Use cached animation if available
|
|
35
|
+
if let cachedAnimation = Self.animationCache.object(forKey: url as NSString) {
|
|
36
|
+
animationView.animation = cachedAnimation
|
|
37
|
+
setupAnimationView(animationView, view)
|
|
38
|
+
} else {
|
|
39
|
+
LottieAnimation.loadedFrom(url: URL(string: url)!, closure: { animation in
|
|
40
|
+
if let animation = animation {
|
|
41
|
+
Self.animationCache.setObject(animation, forKey: url as NSString)
|
|
42
|
+
animationView.animation = animation
|
|
43
|
+
setupAnimationView(animationView, view)
|
|
44
|
+
}
|
|
45
|
+
}, animationCache: nil)
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
// Use cached animation if available
|
|
49
|
+
if let cachedAnimation = Self.animationCache.object(forKey: name as NSString) {
|
|
50
|
+
animationView.animation = cachedAnimation
|
|
51
|
+
setupAnimationView(animationView, view)
|
|
52
|
+
} else if let animation = LottieAnimation.named(name) {
|
|
53
|
+
Self.animationCache.setObject(animation, forKey: name as NSString)
|
|
54
|
+
animationView.animation = animation
|
|
55
|
+
setupAnimationView(animationView, view)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return view
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private func setupAnimationView(_ animationView: LottieAnimationView, _ containerView: UIView) {
|
|
63
|
+
animationView.contentMode = contentMode
|
|
64
|
+
animationView.loopMode = loopMode
|
|
65
|
+
animationView.backgroundBehavior = loopMode == .loop ? .pauseAndRestore : .pause
|
|
66
|
+
|
|
67
|
+
// Optimize rendering
|
|
68
|
+
animationView.shouldRasterizeWhenIdle = true
|
|
69
|
+
|
|
70
|
+
animationView.translatesAutoresizingMaskIntoConstraints = false
|
|
71
|
+
containerView.addSubview(animationView)
|
|
72
|
+
|
|
73
|
+
NSLayoutConstraint.activate([
|
|
74
|
+
animationView.widthAnchor.constraint(equalTo: containerView.widthAnchor),
|
|
75
|
+
animationView.heightAnchor.constraint(equalTo: containerView.heightAnchor)
|
|
76
|
+
])
|
|
77
|
+
|
|
78
|
+
animationView.play { finished in
|
|
79
|
+
if finished {
|
|
80
|
+
onDone?()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieView>) {}
|
|
86
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import SwiftUI
|
|
3
|
+
|
|
4
|
+
typealias SwiftButton = SwiftUI.Button
|
|
5
|
+
|
|
6
|
+
// MARK: - KeyboardButton
|
|
7
|
+
|
|
8
|
+
public struct KeyboardButton: View {
|
|
9
|
+
// MARK: Lifecycle
|
|
10
|
+
|
|
11
|
+
public init(_ key: String, action: @escaping (_ key: String)->Void, width: CGFloat = .infinity, height: CGFloat = 48, color: Color = Colors.card, textColor: Color = Colors.text) {
|
|
12
|
+
self.key = key
|
|
13
|
+
self.action = action
|
|
14
|
+
self.width = width
|
|
15
|
+
self.height = height
|
|
16
|
+
self.color = color
|
|
17
|
+
self.textColor = textColor
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// MARK: Public
|
|
21
|
+
|
|
22
|
+
public var body: some View {
|
|
23
|
+
SwiftUI.Button(action: { self.action(key) }) {
|
|
24
|
+
HStack {
|
|
25
|
+
Text(key).font(.system(size: 24, weight: .bold))
|
|
26
|
+
}.frame(maxWidth: CGFloat(width), minHeight: height)
|
|
27
|
+
.background(color)
|
|
28
|
+
.foregroundColor(textColor)
|
|
29
|
+
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// MARK: Internal
|
|
34
|
+
|
|
35
|
+
var key: String = ""
|
|
36
|
+
var action: (_ key: String)->Void
|
|
37
|
+
var width: CGFloat
|
|
38
|
+
var height: CGFloat
|
|
39
|
+
var color: Color
|
|
40
|
+
var textColor: Color
|
|
41
|
+
}
|