Skip to content

Commit 7644b3e

Browse files
authored
POS: Fix taller button height in loading state (#16025)
2 parents 4ceaafd + f86818c commit 7644b3e

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

WooCommerce/Classes/POS/Presentation/Reusable Views/Buttons/POSButtonStyle.swift

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,6 @@ private struct POSButton: View {
8989
private var progressView: some View {
9090
ProgressView()
9191
.progressViewStyle(POSButtonProgressViewStyle(size: size.progressViewDimensions.size, lineWidth: size.progressViewDimensions.lineWidth))
92-
.padding(
93-
.init(
94-
top: size.additionalPadding.vertical,
95-
leading: size.additionalPadding.horizontal,
96-
bottom: size.additionalPadding.vertical,
97-
trailing: size.additionalPadding.horizontal
98-
)
99-
)
10092
}
10193

10294
private var backgroundColor: Color {
@@ -173,17 +165,6 @@ private extension POSButtonSize {
173165
(size: 20, lineWidth: 6)
174166
}
175167
}
176-
177-
/// The internal use of `IndefiniteCircularProgressViewStyle` progress style results in half of the line width drawn outside of the progress view.
178-
/// This additional padding is thus adjusted by the partial line width to achieve the expected padding in design.
179-
var additionalPadding: (vertical: CGFloat, horizontal: CGFloat) {
180-
switch self {
181-
case .normal:
182-
(vertical: progressViewDimensions.lineWidth * 0.5, horizontal: progressViewDimensions.lineWidth * 0.5)
183-
case .extraSmall:
184-
(vertical: 2 + progressViewDimensions.lineWidth * 0.5, horizontal: 16 + progressViewDimensions.lineWidth * 0.5)
185-
}
186-
}
187168
}
188169

189170
// MARK: - Preview
@@ -206,9 +187,9 @@ struct POSButtonStyle_Previews: View {
206187
previewSection(title: "Outlined Buttons - Extra Small",
207188
variant: .outlined, size: .extraSmall)
208189

209-
loadingPreviewSection(title: "Loading Buttons - Normal", size: .normal)
190+
LoadingPreviewSection(title: "Loading Buttons - Normal", size: .normal)
210191

211-
loadingPreviewSection(title: "Loading Buttons - Extra Small", size: .extraSmall)
192+
LoadingPreviewSection(title: "Loading Buttons - Extra Small", size: .extraSmall)
212193

213194
// Example with long text
214195
VStack(alignment: .leading, spacing: POSSpacing.medium) {
@@ -249,12 +230,28 @@ struct POSButtonStyle_Previews: View {
249230
}
250231
}
251232
}
233+
}
252234

253-
private func loadingPreviewSection(title: String, size: POSButtonSize) -> some View {
235+
private struct LoadingPreviewSection: View {
236+
let title: String
237+
let size: POSButtonSize
238+
@State private var showsLoadingState: Bool = false
239+
240+
var body: some View {
254241
VStack(alignment: .leading, spacing: POSSpacing.medium) {
255242
Text(title)
256243
.font(.headline)
257244

245+
Button("Show loading state") {
246+
showsLoadingState.toggle()
247+
}
248+
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: showsLoadingState))
249+
250+
Button("Show loading state in\nmultiple\nlines") {
251+
showsLoadingState.toggle()
252+
}
253+
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: showsLoadingState))
254+
258255
Button("Enabled Loading Button") {}
259256
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: true))
260257

0 commit comments

Comments
 (0)