Skip to content

Commit 2fe3a85

Browse files
committed
Use PreviewProvider
1 parent 8fc4088 commit 2fe3a85

File tree

3 files changed

+49
-43
lines changed

3 files changed

+49
-43
lines changed

Backpack-SwiftUI/CardButton/Classes/BPKSaveCardButton.swift

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,30 @@ private struct InternalSaveCardButtonStyle: ButtonStyle {
9797
}
9898

9999
// MARK: - previews
100-
#Preview {
101-
VStack {
102-
HStack(spacing: .lg) {
103-
InteractiveDemo(size: .default, style: .default)
104-
InteractiveDemo(size: .small, style: .default)
105-
}
106-
.padding()
107-
108-
HStack(spacing: .lg) {
109-
InteractiveDemo(size: .default, style: .contained)
110-
InteractiveDemo(size: .small, style: .contained)
100+
struct BPKSaveCardButton_Previews: PreviewProvider {
101+
static var previews: some View {
102+
VStack {
103+
HStack(spacing: .lg) {
104+
InteractiveDemo(size: .default, style: .default)
105+
InteractiveDemo(size: .small, style: .default)
106+
}
107+
.padding()
111108

109+
HStack(spacing: .lg) {
110+
InteractiveDemo(size: .default, style: .contained)
111+
InteractiveDemo(size: .small, style: .contained)
112+
113+
}
114+
.padding()
115+
.background(.surfaceHighlightColor)
116+
117+
HStack(spacing: .lg) {
118+
InteractiveDemo(size: .default, style: .onDark)
119+
InteractiveDemo(size: .small, style: .onDark)
120+
}
121+
.padding()
122+
.background(.black)
112123
}
113-
.padding()
114-
.background(.surfaceHighlightColor)
115-
116-
HStack(spacing: .lg) {
117-
InteractiveDemo(size: .default, style: .onDark)
118-
InteractiveDemo(size: .small, style: .onDark)
119-
}
120-
.padding()
121-
.background(.black)
122124
}
123125
}
124126

Backpack-SwiftUI/CardButton/Classes/BPKShareCardButton.swift

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,28 @@ private struct InternalShareCardButtonStyle: ButtonStyle {
7272
}
7373
}
7474

75-
#Preview {
76-
VStack {
77-
HStack(spacing: .lg) {
78-
BPKShareCardButton(size: .default, style: .default, accessibilityLabel: "") { }
79-
BPKShareCardButton(size: .small, style: .default, accessibilityLabel: "") { }
75+
struct BPKShareCardButton_Previews: PreviewProvider {
76+
static var previews: some View {
77+
VStack {
78+
HStack(spacing: .lg) {
79+
BPKShareCardButton(size: .default, style: .default, accessibilityLabel: "") { }
80+
BPKShareCardButton(size: .small, style: .default, accessibilityLabel: "") { }
81+
}
82+
.padding()
83+
84+
HStack(spacing: .lg) {
85+
BPKShareCardButton(size: .default, style: .contained, accessibilityLabel: "") { }
86+
BPKShareCardButton(size: .small, style: .contained, accessibilityLabel: "") { }
87+
}
88+
.padding()
89+
.background(.surfaceHighlightColor)
90+
91+
HStack(spacing: .lg) {
92+
BPKShareCardButton(size: .default, style: .onDark, accessibilityLabel: "") { }
93+
BPKShareCardButton(size: .small, style: .onDark, accessibilityLabel: "") { }
94+
}
95+
.padding()
96+
.background(.black)
8097
}
81-
.padding()
82-
83-
HStack(spacing: .lg) {
84-
BPKShareCardButton(size: .default, style: .contained, accessibilityLabel: "") { }
85-
BPKShareCardButton(size: .small, style: .contained, accessibilityLabel: "") { }
86-
}
87-
.padding()
88-
.background(.surfaceHighlightColor)
89-
90-
HStack(spacing: .lg) {
91-
BPKShareCardButton(size: .default, style: .onDark, accessibilityLabel: "") { }
92-
BPKShareCardButton(size: .small, style: .onDark, accessibilityLabel: "") { }
93-
}
94-
.padding()
95-
.background(.black)
9698
}
9799
}

Example/Backpack/SwiftUI/Components/Card Button/CardButtonExampleView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ private struct BPKSaveCardButtonInteractiveDemo: View {
118118
size: size,
119119
style: style,
120120
checked: checked,
121-
accessibilityLabel: "save",
121+
accessibilityLabel: checked ? "remove from saved" : "save",
122122
action: {
123123
checked.toggle()
124124
}
125125
)
126126
}
127127
}
128128

129-
#Preview {
130-
CardButtonExampleView()
129+
struct CardButtonExampleView_Previews: PreviewProvider {
130+
static var previews: some View {
131+
CardButtonExampleView()
132+
}
131133
}

0 commit comments

Comments
 (0)