Skip to content

Commit eca588f

Browse files
authored
Рефактор превью (#111)
Перевел все превью на макросы
1 parent de44483 commit eca588f

File tree

73 files changed

+596
-748
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+596
-748
lines changed

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/BadgeView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ struct BadgeView: View {
1010
}
1111

1212
#if DEBUG
13-
struct BadgeView_Previews: PreviewProvider {
14-
static var previews: some View {
15-
BadgeView(value: 1)
16-
}
13+
#Preview {
14+
BadgeView(value: 1)
1715
}
1816
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/CachedImage/CachedImage.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ public extension CachedImage {
7676
}
7777

7878
#if DEBUG
79-
struct SmallProfileCacheImageView_Previews: PreviewProvider {
80-
static var previews: some View {
81-
ScrollView {
82-
ForEach(CachedImage.Mode.allCases, id: \.self) { mode in
83-
CachedImage(
84-
url: .init(string: "https://workout.su/img/avatar_default.jpg")!,
85-
mode: mode
86-
)
87-
}
79+
#Preview {
80+
ScrollView {
81+
ForEach(CachedImage.Mode.allCases, id: \.self) { mode in
82+
CachedImage(
83+
url: .init(string: "https://workout.su/img/avatar_default.jpg")!,
84+
mode: mode
85+
)
8886
}
8987
}
9088
}

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/CachedImage/ResizableCachedImage.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public struct ResizableCachedImage: View {
2929
}
3030

3131
#if DEBUG
32-
struct ResizableCachedImage_Previews: PreviewProvider {
33-
static var previews: some View {
34-
ResizableCachedImage(url: nil, didTapImage: { _ in })
35-
}
32+
#Preview {
33+
ResizableCachedImage(url: nil, didTapImage: { _ in })
3634
}
3735
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/Color+.swift

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,29 @@ public extension Color {
3434
}
3535

3636
#if DEBUG
37-
struct AllColors_Previews: PreviewProvider {
38-
static let colors: [Color] = [
37+
#Preview {
38+
let colors: [Color] = [
3939
.swBackground, .swCardBackground, .swSmallElements, .swSeparators,
4040
.swMainText, .swAccent, .swFilledButtonText, .swFilledButtonPressed,
4141
.swDisabledButton, .swDisabledButtonText,
4242
.swTintedButton, .swTintedButtonPressed,
4343
.swXmarkButton, .swAddPhotoButton, .swError
4444
]
45-
static var previews: some View {
46-
ScrollView {
47-
VStack(spacing: 4) {
48-
ForEach(colors, id: \.self) { color in
49-
HStack(spacing: 20) {
50-
Group {
51-
Circle()
52-
Circle()
53-
.environment(\.colorScheme, .dark)
54-
}
55-
.foregroundColor(color)
56-
.frame(width: 50, height: 50)
45+
return ScrollView {
46+
VStack(spacing: 4) {
47+
ForEach(colors, id: \.self) { color in
48+
HStack(spacing: 20) {
49+
Group {
50+
Circle()
51+
Circle()
52+
.environment(\.colorScheme, .dark)
5753
}
54+
.foregroundColor(color)
55+
.frame(width: 50, height: 50)
5856
}
5957
}
60-
.frame(maxWidth: .infinity)
6158
}
59+
.frame(maxWidth: .infinity)
6260
}
6361
}
6462
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/ContentInSheet.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ private extension ContentInSheet {
5252
}
5353

5454
#if DEBUG
55-
struct ContentInSheet_Previews: PreviewProvider {
56-
static var previews: some View {
57-
ContentInSheet(title: "Header") {
58-
Text("Some content")
59-
.frame(maxWidth: .infinity, maxHeight: .infinity)
60-
.background(.yellow)
61-
}
55+
#Preview {
56+
ContentInSheet(title: "Header") {
57+
Text("Some content")
58+
.frame(maxWidth: .infinity, maxHeight: .infinity)
59+
.background(.yellow)
6260
}
6361
}
6462
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/Icons.swift

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,42 +57,40 @@ public enum Icons {
5757
}
5858

5959
#if DEBUG
60-
struct ButtonIcons_Previews: PreviewProvider {
61-
static var previews: some View {
62-
List {
63-
Section("Tabbar icons") {
64-
VStack(alignment: .leading, spacing: 16) {
65-
ForEach(Icons.Tabbar.allCases, id: \.rawValue) { icon in
66-
HStack(spacing: 16) {
67-
Image(systemName: icon.rawValue)
68-
Text(icon.rawValue)
69-
}
60+
#Preview {
61+
List {
62+
Section("Tabbar icons") {
63+
VStack(alignment: .leading, spacing: 16) {
64+
ForEach(Icons.Tabbar.allCases, id: \.rawValue) { icon in
65+
HStack(spacing: 16) {
66+
Image(systemName: icon.rawValue)
67+
Text(icon.rawValue)
7068
}
7169
}
7270
}
73-
Section("Regular icons") {
74-
VStack(alignment: .leading, spacing: 16) {
75-
ForEach(Icons.Regular.allCases, id: \.rawValue) { icon in
76-
HStack(spacing: 16) {
77-
Image(systemName: icon.rawValue)
78-
Text(icon.rawValue)
79-
}
71+
}
72+
Section("Regular icons") {
73+
VStack(alignment: .leading, spacing: 16) {
74+
ForEach(Icons.Regular.allCases, id: \.rawValue) { icon in
75+
HStack(spacing: 16) {
76+
Image(systemName: icon.rawValue)
77+
Text(icon.rawValue)
8078
}
8179
}
8280
}
83-
Section("Misc icons") {
84-
VStack(alignment: .leading, spacing: 16) {
85-
ForEach(Icons.Misc.allCases, id: \.rawValue) { icon in
86-
HStack(spacing: 16) {
87-
Image(systemName: icon.rawValue)
88-
Text(icon.rawValue)
89-
}
81+
}
82+
Section("Misc icons") {
83+
VStack(alignment: .leading, spacing: 16) {
84+
ForEach(Icons.Misc.allCases, id: \.rawValue) { icon in
85+
HStack(spacing: 16) {
86+
Image(systemName: icon.rawValue)
87+
Text(icon.rawValue)
9088
}
9189
}
9290
}
9391
}
94-
.listStyle(.plain)
95-
.previewDisplayName("Icons")
9692
}
93+
.listStyle(.plain)
94+
.previewDisplayName("Icons")
9795
}
9896
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/ItemListScreen.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ private extension ItemListScreen {
6666
}
6767

6868
#if DEBUG
69-
struct ItemListScreen_Previews: PreviewProvider {
70-
static var previews: some View {
71-
ItemListScreen(
72-
allItems: ["Россия, Канада, Австралия"],
73-
selectedItem: "Россия",
74-
didSelectItem: { _ in }
75-
)
76-
}
69+
#Preview {
70+
ItemListScreen(
71+
allItems: ["Россия, Канада, Австралия"],
72+
selectedItem: "Россия",
73+
didSelectItem: { _ in }
74+
)
7775
}
7876
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/ProfileView.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ public struct ProfileView: View {
5555
}
5656

5757
#if DEBUG
58-
struct ProfileView_Previews: PreviewProvider {
59-
static var previews: some View {
60-
ProfileView(
61-
imageURL: nil,
62-
login: "Beautifulbutterfly101",
63-
genderWithAge: "Женщина, 30 лет",
64-
countryAndCity: "Россия, Краснодар"
65-
)
66-
.padding(.horizontal, 40)
67-
.previewLayout(.sizeThatFits)
68-
}
58+
#Preview {
59+
ProfileView(
60+
imageURL: nil,
61+
login: "Beautifulbutterfly101",
62+
genderWithAge: "Женщина, 30 лет",
63+
countryAndCity: "Россия, Краснодар"
64+
)
65+
.padding(.horizontal, 40)
66+
.previewLayout(.sizeThatFits)
6967
}
7068
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/RoundedCornerShape.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ struct RoundedCornerShape: Shape {
1616
}
1717

1818
#if DEBUG
19-
struct RoundedCornerShape_Previews: PreviewProvider {
20-
static var previews: some View {
21-
Rectangle()
22-
.foregroundColor(.blue)
23-
.clipShape(RoundedCornerShape(radius: 20, corners: .bottomLeft))
24-
}
19+
#Preview {
20+
Rectangle()
21+
.foregroundColor(.blue)
22+
.clipShape(RoundedCornerShape(radius: 20, corners: .bottomLeft))
2523
}
2624
#endif

SwiftUI-WorkoutApp/DesignSystem/Sources/DesignSystem/RoundedDefaultImage.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ public struct RoundedDefaultImage: View {
1919
}
2020

2121
#if DEBUG
22-
struct RoundedRectDefaultImage_Previews: PreviewProvider {
23-
static var previews: some View {
24-
VStack(spacing: 16) {
25-
RoundedDefaultImage(size: .init(width: 45, height: 45))
26-
RoundedDefaultImage(size: .init(width: 60, height: 60))
27-
}
28-
.padding()
29-
.previewLayout(.sizeThatFits)
22+
#Preview {
23+
VStack(spacing: 16) {
24+
RoundedDefaultImage(size: .init(width: 45, height: 45))
25+
RoundedDefaultImage(size: .init(width: 60, height: 60))
3026
}
27+
.padding()
28+
.previewLayout(.sizeThatFits)
3129
}
3230
#endif

0 commit comments

Comments
 (0)