@momo-kits/native-kits 0.162.2-beta.22 → 0.162.2-beta.23
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/ios/Button/Button.swift +23 -47
- package/package.json +3 -1
package/ios/Button/Button.swift
CHANGED
|
@@ -125,12 +125,7 @@ public struct Button: View {
|
|
|
125
125
|
var iconRight: AnyView?
|
|
126
126
|
var isFull: Bool
|
|
127
127
|
var loading: Bool
|
|
128
|
-
var iconOnly: Bool
|
|
129
128
|
|
|
130
|
-
/// When `iconOnly` is true the label is hidden and the button collapses to a compact,
|
|
131
|
-
/// icon-sized box (it ignores `isFull`). `title` stays required and is exposed as the
|
|
132
|
-
/// accessibility label. Supply the glyph via `iconLeft` (preferred) or `iconRight`;
|
|
133
|
-
/// while `loading` the spinner replaces the icon.
|
|
134
129
|
public init(
|
|
135
130
|
title: String = "",
|
|
136
131
|
action: @escaping () -> Void,
|
|
@@ -139,8 +134,7 @@ public struct Button: View {
|
|
|
139
134
|
iconLeft: AnyView? = nil,
|
|
140
135
|
iconRight: AnyView? = nil,
|
|
141
136
|
isFull: Bool = true,
|
|
142
|
-
loading: Bool = false
|
|
143
|
-
iconOnly: Bool = false
|
|
137
|
+
loading: Bool = false
|
|
144
138
|
) {
|
|
145
139
|
self.title = title
|
|
146
140
|
self.action = action
|
|
@@ -150,7 +144,6 @@ public struct Button: View {
|
|
|
150
144
|
self.iconRight = iconRight
|
|
151
145
|
self.isFull = isFull
|
|
152
146
|
self.loading = loading
|
|
153
|
-
self.iconOnly = iconOnly
|
|
154
147
|
}
|
|
155
148
|
|
|
156
149
|
private func shouldLoadingOnLeft(_ left: AnyView?, _ right: AnyView?) -> Bool {
|
|
@@ -173,46 +166,35 @@ public struct Button: View {
|
|
|
173
166
|
let border = type.borderColor
|
|
174
167
|
let borderWidth = type.borderWidth
|
|
175
168
|
|
|
176
|
-
|
|
169
|
+
SwiftUI.Button(action: {
|
|
177
170
|
if !loading, type != .disabled {
|
|
178
171
|
action()
|
|
179
172
|
}
|
|
180
173
|
}) {
|
|
181
174
|
HStack(spacing: size.iconSpacing) {
|
|
182
|
-
if
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
.lineLimit(1)
|
|
203
|
-
.truncationMode(.tail)
|
|
204
|
-
|
|
205
|
-
if loading && !loadingOnLeft {
|
|
206
|
-
LottieView(name: "lottie_circle_loader", loopMode: .loop)
|
|
207
|
-
.frame(width: size.iconSize, height: size.iconSize)
|
|
208
|
-
.colorMultiply(fg)
|
|
209
|
-
|
|
210
|
-
} else if let iconRight = iconRight {
|
|
211
|
-
iconRight.frame(width: size.iconSize, height: size.iconSize)
|
|
212
|
-
}
|
|
175
|
+
if loading && loadingOnLeft {
|
|
176
|
+
LottieView(name: "lottie_circle_loader", loopMode: .loop)
|
|
177
|
+
.frame(width: size.iconSize, height: size.iconSize)
|
|
178
|
+
.colorMultiply(fg)
|
|
179
|
+
|
|
180
|
+
} else if let iconLeft = iconLeft {
|
|
181
|
+
iconLeft.frame(width: size.iconSize, height: size.iconSize)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
MomoText(title, typography: size.typographyStyle, color: fg)
|
|
185
|
+
.lineLimit(1)
|
|
186
|
+
.truncationMode(.tail)
|
|
187
|
+
|
|
188
|
+
if loading && !loadingOnLeft {
|
|
189
|
+
LottieView(name: "lottie_circle_loader", loopMode: .loop)
|
|
190
|
+
.frame(width: size.iconSize, height: size.iconSize)
|
|
191
|
+
.colorMultiply(fg)
|
|
192
|
+
|
|
193
|
+
} else if let iconRight = iconRight {
|
|
194
|
+
iconRight.frame(width: size.iconSize, height: size.iconSize)
|
|
213
195
|
}
|
|
214
196
|
}
|
|
215
|
-
.frame(maxWidth: isFull
|
|
197
|
+
.frame(maxWidth: isFull ? .infinity : nil)
|
|
216
198
|
.padding(.horizontal, size.padding)
|
|
217
199
|
.frame(height: size.height)
|
|
218
200
|
.background(bg)
|
|
@@ -224,11 +206,5 @@ public struct Button: View {
|
|
|
224
206
|
.opacity(loading ? 0.75 : 1)
|
|
225
207
|
}
|
|
226
208
|
.disabled(type == .disabled || loading)
|
|
227
|
-
|
|
228
|
-
if iconOnly {
|
|
229
|
-
button.accessibilityLabel(Text(title))
|
|
230
|
-
} else {
|
|
231
|
-
button
|
|
232
|
-
}
|
|
233
209
|
}
|
|
234
210
|
}
|