Skip to content

Commit c1a865b

Browse files
committed
Remove redundant padding that makes progress view bigger than text label, resulting in a taller height in the button loading state.
1 parent 732cda3 commit c1a865b

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

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

Lines changed: 6 additions & 19 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,24 +165,14 @@ 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
190171

191172
#if DEBUG
192173

193174
struct POSButtonStyle_Previews: View {
175+
@State private var showsLoadingState: Bool = false
194176
var body: some View {
195177
ScrollView {
196178
VStack(alignment: .leading, spacing: POSSpacing.xLarge) {
@@ -255,6 +237,11 @@ struct POSButtonStyle_Previews: View {
255237
Text(title)
256238
.font(.headline)
257239

240+
Button("Show loading state") {
241+
showsLoadingState.toggle()
242+
}
243+
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: showsLoadingState))
244+
258245
Button("Enabled Loading Button") {}
259246
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: true))
260247

0 commit comments

Comments
 (0)