Skip to content

Commit f86818c

Browse files
committed
Create a separate container view for button loading preview.
1 parent c1a865b commit f86818c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ private extension POSButtonSize {
172172
#if DEBUG
173173

174174
struct POSButtonStyle_Previews: View {
175-
@State private var showsLoadingState: Bool = false
176175
var body: some View {
177176
ScrollView {
178177
VStack(alignment: .leading, spacing: POSSpacing.xLarge) {
@@ -188,9 +187,9 @@ struct POSButtonStyle_Previews: View {
188187
previewSection(title: "Outlined Buttons - Extra Small",
189188
variant: .outlined, size: .extraSmall)
190189

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

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

195194
// Example with long text
196195
VStack(alignment: .leading, spacing: POSSpacing.medium) {
@@ -231,8 +230,14 @@ struct POSButtonStyle_Previews: View {
231230
}
232231
}
233232
}
233+
}
234+
235+
private struct LoadingPreviewSection: View {
236+
let title: String
237+
let size: POSButtonSize
238+
@State private var showsLoadingState: Bool = false
234239

235-
private func loadingPreviewSection(title: String, size: POSButtonSize) -> some View {
240+
var body: some View {
236241
VStack(alignment: .leading, spacing: POSSpacing.medium) {
237242
Text(title)
238243
.font(.headline)
@@ -242,6 +247,11 @@ struct POSButtonStyle_Previews: View {
242247
}
243248
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: showsLoadingState))
244249

250+
Button("Show loading state in\nmultiple\nlines") {
251+
showsLoadingState.toggle()
252+
}
253+
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: showsLoadingState))
254+
245255
Button("Enabled Loading Button") {}
246256
.buttonStyle(POSFilledButtonStyle(size: size, isLoading: true))
247257

0 commit comments

Comments
 (0)