@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,263 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Components.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by sophia on 24/1/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import SwiftUI
|
|
9
|
+
|
|
10
|
+
// MARK: - Enums
|
|
11
|
+
|
|
12
|
+
public enum TitlePosition {
|
|
13
|
+
case left, center
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public enum HeaderType {
|
|
17
|
+
case `default`, extended, none
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public enum AnimatedHeaderRatio {
|
|
21
|
+
case ratio16_9
|
|
22
|
+
case ratio1_1
|
|
23
|
+
case ratio3_2
|
|
24
|
+
|
|
25
|
+
var value: CGFloat {
|
|
26
|
+
switch self {
|
|
27
|
+
case .ratio16_9: return 16.0 / 9.0
|
|
28
|
+
case .ratio1_1: return 1.0
|
|
29
|
+
case .ratio3_2: return 3.0 / 2.0
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// MARK: - Animated Header Config
|
|
36
|
+
|
|
37
|
+
public struct AnimatedHeader {
|
|
38
|
+
public var aspectRatio: AnimatedHeaderRatio = .ratio16_9
|
|
39
|
+
public var isSurface: Bool = true
|
|
40
|
+
public var composable: (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
|
|
41
|
+
|
|
42
|
+
public init(
|
|
43
|
+
aspectRatio: AnimatedHeaderRatio = .ratio16_9,
|
|
44
|
+
isSurface: Bool = true,
|
|
45
|
+
composable: @escaping (_ scrollState: CGFloat) -> AnyView = { _ in AnyView(EmptyView()) }
|
|
46
|
+
) {
|
|
47
|
+
self.aspectRatio = aspectRatio
|
|
48
|
+
self.isSurface = isSurface
|
|
49
|
+
self.composable = composable
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: - Utils
|
|
54
|
+
|
|
55
|
+
func safeAreaTopInset() -> CGFloat {
|
|
56
|
+
if #available(iOS 15.0, *) {
|
|
57
|
+
return UIApplication.shared.connectedScenes
|
|
58
|
+
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.top }
|
|
59
|
+
.first ?? 0
|
|
60
|
+
} else {
|
|
61
|
+
return UIApplication.shared.connectedScenes
|
|
62
|
+
.compactMap { ($0 as? UIWindowScene)?.windows.first?.safeAreaInsets.top }
|
|
63
|
+
.first ?? 0
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// MARK: - Header Background
|
|
68
|
+
|
|
69
|
+
public struct HeaderBackground: View {
|
|
70
|
+
var headerType: HeaderType = .default
|
|
71
|
+
var scrollState: CGFloat
|
|
72
|
+
var headerTransparent: Bool = false
|
|
73
|
+
var fullScreenContent: Bool = false
|
|
74
|
+
|
|
75
|
+
public init(
|
|
76
|
+
headerType: HeaderType = .default,
|
|
77
|
+
scrollState: CGFloat = 0,
|
|
78
|
+
headerTransparent: Bool = false,
|
|
79
|
+
fullScreenContent: Bool = false
|
|
80
|
+
) {
|
|
81
|
+
self.headerType = headerType
|
|
82
|
+
self.scrollState = scrollState
|
|
83
|
+
self.headerTransparent = headerTransparent
|
|
84
|
+
self.fullScreenContent = fullScreenContent
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public var body: some View {
|
|
88
|
+
|
|
89
|
+
let statusBarHeight = safeAreaTopInset()
|
|
90
|
+
let opacity = max(0, 1 - scrollState / 200)
|
|
91
|
+
let height = fullScreenContent ? 0 : statusBarHeight + 52
|
|
92
|
+
let backgroundColor = headerTransparent ? Color.clear : Colors.black01
|
|
93
|
+
|
|
94
|
+
Group {
|
|
95
|
+
switch headerType {
|
|
96
|
+
case .default:
|
|
97
|
+
ZStack(alignment: .bottom) {
|
|
98
|
+
Rectangle()
|
|
99
|
+
.fill(backgroundColor)
|
|
100
|
+
.opacity(headerTransparent ? 0 : opacity)
|
|
101
|
+
.frame(height: height)
|
|
102
|
+
.shadow(color: Colors.black20.opacity(0.2), radius: 10, x: 0, y: -2)
|
|
103
|
+
.background(backgroundColor)
|
|
104
|
+
.overlay(
|
|
105
|
+
headerTransparent ? AnyView(EmptyView()) :
|
|
106
|
+
AnyView(
|
|
107
|
+
Rectangle()
|
|
108
|
+
.fill(LinearGradient(
|
|
109
|
+
gradient: Gradient(colors: [
|
|
110
|
+
Color(red: 1, green: 0.8, blue: 0.87),
|
|
111
|
+
Color(red: 1, green: 0.8, blue: 0.87).opacity(0.5)
|
|
112
|
+
]),
|
|
113
|
+
startPoint: .top,
|
|
114
|
+
endPoint: .bottom))
|
|
115
|
+
.opacity(opacity)
|
|
116
|
+
.frame(height: height))
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
if !headerTransparent {
|
|
120
|
+
Rectangle()
|
|
121
|
+
.fill(Color.black.opacity(0.1))
|
|
122
|
+
.frame(height: 1)
|
|
123
|
+
.frame(maxWidth: .infinity)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case .extended:
|
|
128
|
+
ZStack {
|
|
129
|
+
if !headerTransparent {
|
|
130
|
+
Colors.black01
|
|
131
|
+
LinearGradient(
|
|
132
|
+
gradient: Gradient(colors: [
|
|
133
|
+
Color(red: 1, green: 0.8, blue: 0.87),
|
|
134
|
+
Color(red: 1, green: 0.8, blue: 0.87).opacity(0)
|
|
135
|
+
]),
|
|
136
|
+
startPoint: .top,
|
|
137
|
+
endPoint: .bottom
|
|
138
|
+
)
|
|
139
|
+
.opacity(opacity)
|
|
140
|
+
.frame(height: 154)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
case .none:
|
|
145
|
+
EmptyView()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// MARK: - Header View
|
|
152
|
+
|
|
153
|
+
public struct Header: View {
|
|
154
|
+
var headerType: HeaderType = .default
|
|
155
|
+
var titlePosition: TitlePosition
|
|
156
|
+
var title: String
|
|
157
|
+
var headerRight: (()->any View)? = {HeaderRight()}
|
|
158
|
+
var goBack: (() -> Void)?
|
|
159
|
+
var opacity: CGFloat = 1
|
|
160
|
+
var animatedHeader: AnimatedHeader?
|
|
161
|
+
var scrollState: CGFloat = 0
|
|
162
|
+
var inputSearchProps: InputSearchProps?
|
|
163
|
+
var tintColor: Color?
|
|
164
|
+
|
|
165
|
+
public init(
|
|
166
|
+
headerType: HeaderType = .default,
|
|
167
|
+
titlePosition: TitlePosition,
|
|
168
|
+
title: String,
|
|
169
|
+
headerRight: (()->any View)? = {HeaderRight()},
|
|
170
|
+
goBack: (() -> Void)? = nil,
|
|
171
|
+
opacity: CGFloat = 1,
|
|
172
|
+
animatedHeader: AnimatedHeader? = nil,
|
|
173
|
+
scrollState: CGFloat = 0,
|
|
174
|
+
inputSearchProps: InputSearchProps? = nil,
|
|
175
|
+
tintColor: Color? = nil
|
|
176
|
+
) {
|
|
177
|
+
self.headerType = headerType
|
|
178
|
+
self.titlePosition = titlePosition
|
|
179
|
+
self.title = title
|
|
180
|
+
self.headerRight = headerRight
|
|
181
|
+
self.goBack = goBack
|
|
182
|
+
self.opacity = opacity
|
|
183
|
+
self.animatedHeader = animatedHeader
|
|
184
|
+
self.scrollState = scrollState
|
|
185
|
+
self.inputSearchProps = inputSearchProps
|
|
186
|
+
self.tintColor = tintColor
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public var body: some View {
|
|
190
|
+
|
|
191
|
+
let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
|
|
192
|
+
let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
|
|
193
|
+
|
|
194
|
+
if headerType != .none {
|
|
195
|
+
VStack(spacing: 0) {
|
|
196
|
+
ZStack {
|
|
197
|
+
// MARK: - Left and Right Controls
|
|
198
|
+
HStack {
|
|
199
|
+
if let goBack = goBack {
|
|
200
|
+
SwiftUI.Button(action: goBack) {
|
|
201
|
+
Circle()
|
|
202
|
+
.stroke(borderColor, lineWidth: 0.2)
|
|
203
|
+
.background(Circle().fill(backgroundButtonColor))
|
|
204
|
+
.frame(width: 28, height: 28)
|
|
205
|
+
.overlay(
|
|
206
|
+
Icon(source: "arrow-back", size: 20, color: tintColor ?? Colors.black17)
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
Spacer()
|
|
212
|
+
|
|
213
|
+
if let headerRight = headerRight {
|
|
214
|
+
AnyView(headerRight())
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
.padding(.horizontal, 12)
|
|
218
|
+
|
|
219
|
+
// MARK: - Title or Search
|
|
220
|
+
HStack {
|
|
221
|
+
if titlePosition == .left && goBack != nil {
|
|
222
|
+
Spacer().frame(width: 38)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if let inputProps = inputSearchProps {
|
|
226
|
+
InputSearch(
|
|
227
|
+
text: inputProps.$text,
|
|
228
|
+
buttonText: inputProps.buttonText,
|
|
229
|
+
showButtonText: inputProps.showButtonText,
|
|
230
|
+
showBorder: inputProps.showBorder,
|
|
231
|
+
placeholder: inputProps.placeholder,
|
|
232
|
+
onChangeText: inputProps.onChangeText,
|
|
233
|
+
onPressButtonText: inputProps.onPressButtonText,
|
|
234
|
+
error: inputProps.error,
|
|
235
|
+
disabled: inputProps.disabled,
|
|
236
|
+
icon: inputProps.icon,
|
|
237
|
+
iconColor: inputProps.iconColor,
|
|
238
|
+
onRightIconPressed: inputProps.onRightIconPressed,
|
|
239
|
+
onFocus: inputProps.onFocus,
|
|
240
|
+
onBlur: inputProps.onBlur,
|
|
241
|
+
loading: inputProps.loading,
|
|
242
|
+
fontWeight: inputProps.fontWeight,
|
|
243
|
+
keyboardType: inputProps.keyboardType
|
|
244
|
+
)
|
|
245
|
+
} else {
|
|
246
|
+
Text(title)
|
|
247
|
+
.font(.system(size: 17, weight: .bold))
|
|
248
|
+
.foregroundColor(tintColor ?? Colors.black17)
|
|
249
|
+
.frame(maxWidth: titlePosition == .center ? UIScreen.main.bounds.width - 252 : nil)
|
|
250
|
+
.frame(maxWidth: titlePosition == .center ? .infinity : UIScreen.main.bounds.width - 172, alignment: titlePosition == .center ? .center : .leading)
|
|
251
|
+
.lineLimit(1)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
Spacer()
|
|
255
|
+
}
|
|
256
|
+
.padding(.horizontal)
|
|
257
|
+
}
|
|
258
|
+
.background(Color.clear)
|
|
259
|
+
.frame(height: 52)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
public protocol ComposeApi {
|
|
4
|
+
func request(funcName: String, params: Any, _ completion: ((String) -> Void)?)
|
|
5
|
+
func request(funcName: String, params: Any) -> String
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Default implementation
|
|
9
|
+
public class ComposeApiImpl: ComposeApi {
|
|
10
|
+
public static let shared = ComposeApiImpl()
|
|
11
|
+
|
|
12
|
+
private init() {}
|
|
13
|
+
|
|
14
|
+
public func request(funcName: String, params: Any, _ completion: ((String) -> Void)?) {
|
|
15
|
+
// Implement your API request logic here
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public func request(funcName: String, params: Any) -> String {
|
|
19
|
+
// Implement your API request logic here
|
|
20
|
+
return ""
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import SwiftUI
|
|
2
|
+
import Combine
|
|
3
|
+
|
|
4
|
+
public enum FABSize {
|
|
5
|
+
case small
|
|
6
|
+
case large
|
|
7
|
+
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public enum FABPosition {
|
|
11
|
+
case right
|
|
12
|
+
case center
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public struct FabProps {
|
|
16
|
+
public let icon: String?
|
|
17
|
+
public let iconColor: Color?
|
|
18
|
+
public let label: String?
|
|
19
|
+
public let onClick: (() -> Void)?
|
|
20
|
+
public let containerColor: Color?
|
|
21
|
+
public let size: FABSize?
|
|
22
|
+
public let iconSize: CGFloat?
|
|
23
|
+
public let scrollOffset: CGFloat?
|
|
24
|
+
public let position: FABPosition?
|
|
25
|
+
public let bottomPadding: CGFloat?
|
|
26
|
+
public let renderComponent: (() -> AnyView)?
|
|
27
|
+
|
|
28
|
+
public init(
|
|
29
|
+
icon: String? = nil,
|
|
30
|
+
iconColor: Color? = .white,
|
|
31
|
+
label: String? = nil,
|
|
32
|
+
onClick: (() -> Void)? = nil,
|
|
33
|
+
containerColor: Color? = Colors.primary,
|
|
34
|
+
size: FABSize? = .small,
|
|
35
|
+
iconSize: CGFloat? = nil,
|
|
36
|
+
scrollOffset: CGFloat? = nil,
|
|
37
|
+
position: FABPosition? = .right,
|
|
38
|
+
bottomPadding: CGFloat? = nil,
|
|
39
|
+
renderComponent: (() -> AnyView)? = nil
|
|
40
|
+
) {
|
|
41
|
+
self.icon = icon
|
|
42
|
+
self.iconColor = iconColor
|
|
43
|
+
self.label = label
|
|
44
|
+
self.onClick = onClick
|
|
45
|
+
self.containerColor = containerColor
|
|
46
|
+
self.size = size
|
|
47
|
+
self.iconSize = iconSize
|
|
48
|
+
self.scrollOffset = scrollOffset
|
|
49
|
+
self.position = position
|
|
50
|
+
self.bottomPadding = bottomPadding
|
|
51
|
+
self.renderComponent = renderComponent
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public struct FloatingButton: View {
|
|
56
|
+
@State private var lastScrollOffset: CGFloat = 0
|
|
57
|
+
@State private var isExpanded: Bool = false
|
|
58
|
+
@State private var internalScrollOffset: CGFloat = 0
|
|
59
|
+
@State private var showText: Bool = true
|
|
60
|
+
@State private var fullWidth: CGFloat? = nil
|
|
61
|
+
@State private var currentWidth: CGFloat = 0
|
|
62
|
+
@State private var lastDirection: String? = nil
|
|
63
|
+
|
|
64
|
+
private let props: FabProps
|
|
65
|
+
private var keyboardOffset: CGFloat
|
|
66
|
+
private var scrollOffset: CGFloat
|
|
67
|
+
private var bottomPadding: CGFloat { props.bottomPadding ?? 12 + keyboardOffset}
|
|
68
|
+
private var position: FABPosition? { props.position ?? .right }
|
|
69
|
+
private var containerColor: Color? { props.containerColor ?? Colors.primary }
|
|
70
|
+
private var iconColor: Color? { props.iconColor ?? .white }
|
|
71
|
+
private var label: String? { props.label }
|
|
72
|
+
private var icon: String? { props.icon }
|
|
73
|
+
private var size: FABSize? { props.size }
|
|
74
|
+
private var iconSize: CGFloat? { props.iconSize ?? defaultIconSize}
|
|
75
|
+
private var onClick: (() -> Void)? { props.onClick }
|
|
76
|
+
private var renderComponent: (() -> AnyView)? { props.renderComponent }
|
|
77
|
+
|
|
78
|
+
public init(props: FabProps, keyboardOffset: CGFloat = 0, scrollOffset: CGFloat = 0) {
|
|
79
|
+
self.props = props
|
|
80
|
+
self.keyboardOffset = keyboardOffset
|
|
81
|
+
self.scrollOffset = scrollOffset
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private var height: CGFloat {
|
|
85
|
+
if(iconSize == nil) {
|
|
86
|
+
size == .small ? 36 : 48
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
iconSize!
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private var minWidth: CGFloat {
|
|
94
|
+
size == .small ? 36 : 48
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private var defaultIconSize: CGFloat {
|
|
98
|
+
size == .small ? 12 : 24
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public var body: some View {
|
|
102
|
+
Group {
|
|
103
|
+
if ((icon?.isEmpty) == nil), let render = renderComponent {
|
|
104
|
+
render()
|
|
105
|
+
} else {
|
|
106
|
+
content
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
.onTapGesture {
|
|
110
|
+
onClick?()
|
|
111
|
+
}
|
|
112
|
+
.padding(Spacing.M)
|
|
113
|
+
.frame(height: height + (Spacing.M * 2))
|
|
114
|
+
.background(containerColor)
|
|
115
|
+
.cornerRadius(100)
|
|
116
|
+
.padding(.bottom, bottomPadding)
|
|
117
|
+
.frame(alignment: position == .center ? .center : .trailing)
|
|
118
|
+
.onAppear {
|
|
119
|
+
internalScrollOffset = scrollOffset
|
|
120
|
+
isExpanded = label != nil
|
|
121
|
+
}
|
|
122
|
+
.onReceive(Just(scrollOffset)) { newValue in
|
|
123
|
+
let direction = newValue > internalScrollOffset ? "down" : "up"
|
|
124
|
+
|
|
125
|
+
if direction != lastDirection {
|
|
126
|
+
lastDirection = direction
|
|
127
|
+
if direction == "down" {
|
|
128
|
+
withAnimation(.easeOut(duration: 0.1)) {
|
|
129
|
+
isExpanded = false
|
|
130
|
+
}
|
|
131
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
132
|
+
showText = false
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
showText = true
|
|
136
|
+
withAnimation(.easeIn(duration: 0.1)) {
|
|
137
|
+
isExpanded = true
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private var content: some View {
|
|
146
|
+
HStack(spacing: 0) {
|
|
147
|
+
ImageView(icon ?? "")
|
|
148
|
+
.scaledToFit()
|
|
149
|
+
.frame(width: iconSize, height: iconSize)
|
|
150
|
+
.foregroundColor(iconColor)
|
|
151
|
+
|
|
152
|
+
if let label = label {
|
|
153
|
+
if showText {
|
|
154
|
+
Spacer().frame(width: 8)
|
|
155
|
+
Text(label)
|
|
156
|
+
.foregroundColor(.white)
|
|
157
|
+
.font(.system(size: 16, weight: .bold))
|
|
158
|
+
.lineLimit(1)
|
|
159
|
+
.background(
|
|
160
|
+
GeometryReader { geo in
|
|
161
|
+
Color.clear.onAppear {
|
|
162
|
+
fullWidth = geo.size.width
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
.opacity(isExpanded ? 1 : 0)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|