@momo-kits/native-kits 0.152.4-beta.3 → 0.152.5
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/package.json +7 -6
- package/shared/build.gradle.kts +74 -0
- package/CODE_OF_CONDUCT.md +0 -133
- package/CONTRIBUTING.md +0 -114
- package/LICENSE +0 -20
- package/README.md +0 -7
- package/build.gradle.kts +0 -32
- package/compose/MoMoComposeKits.podspec +0 -54
- package/compose/build.gradle.kts +0 -149
- package/compose/src/androidMain/AndroidManifest.xml +0 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -105
- package/compose/src/commonMain/composeResources/files/lottie_circle_loader.json +0 -1
- 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 +0 -57
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -306
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -715
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -214
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -77
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -27
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -334
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -345
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -90
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -131
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -69
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -143
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -179
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -111
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -384
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -160
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -234
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -223
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -232
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -228
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -34
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -85
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -95
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -64
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -89
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -84
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -208
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -172
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -199
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -237
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -191
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -258
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -49
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -232
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -111
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -94
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -159
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -232
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScaleSizeScope.kt +0 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -459
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -169
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -216
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -180
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -251
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -31
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -385
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -38
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -88
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -144
- package/gradle.properties +0 -19
- package/gradlew +0 -240
- package/gradlew.bat +0 -91
- package/ios/Application/ApplicationEnvironment.swift +0 -50
- package/ios/Application/Components.swift +0 -263
- package/ios/Application/ComposeApi.swift +0 -22
- package/ios/Application/FloatingButton.swift +0 -172
- package/ios/Application/HeaderRight.swift +0 -271
- package/ios/Application/Screen.swift +0 -249
- package/ios/Badge/BadgeDot.swift +0 -31
- package/ios/Button/Button.swift +0 -211
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +0 -126
- package/ios/Checkbox/Checkbox.swift +0 -81
- package/ios/Chip/Chip.swift +0 -96
- package/ios/Colors+Radius+Spacing/Colors.swift +0 -172
- package/ios/Colors+Radius+Spacing/Radius.swift +0 -22
- package/ios/Colors+Radius+Spacing/Spacing.swift +0 -12
- package/ios/Extensions/Color++.swift +0 -25
- package/ios/Icon/Icon.swift +0 -51
- package/ios/Image/Image.swift +0 -70
- package/ios/Input/Input.swift +0 -207
- package/ios/Input/InputPhoneNumber.swift +0 -176
- package/ios/Input/InputSearch.swift +0 -238
- package/ios/Input/InputTextArea.swift +0 -242
- package/ios/Lottie/LottieView.swift +0 -86
- package/ios/OTPKeyboard/KeyboardButton.swift +0 -41
- package/ios/OTPKeyboard/OTPKeyboard.swift +0 -145
- package/ios/Popup/PopupDisplay.swift +0 -284
- package/ios/Popup/PopupInput.swift +0 -96
- package/ios/Popup/PopupPromotion.swift +0 -73
- package/ios/PopupView/FullscreenPopup.swift +0 -251
- package/ios/PopupView/Modifiers.swift +0 -158
- package/ios/PopupView/PopupView.swift +0 -289
- package/ios/PopupView/Utils++.swift +0 -281
- package/ios/ScrollIndicator/ScrollIndicator.swift +0 -110
- package/ios/Swipeable/SwipeCell.swift +0 -278
- package/ios/Swipeable/SwipeCellModel.swift +0 -86
- package/ios/Switch/Switch.swift +0 -44
- package/ios/Template/Logo/Logo.swift +0 -75
- package/ios/Template/TrustBanner/TrustBanner.swift +0 -120
- package/ios/Theme.md +0 -18
- package/ios/Typography/Text.swift +0 -140
- package/ios/Typography/Typography.swift +0 -95
- package/ios/native-kits.podspec +0 -18
- package/settings.gradle.kts +0 -25
|
@@ -1,238 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,242 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
}
|