Skip to content

Commit 0e72485

Browse files
chore: create previews for all Views
1 parent 8cea58f commit 0e72485

File tree

10 files changed

+68
-0
lines changed

10 files changed

+68
-0
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Utils/CommonUtils.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import CommonCrypto
2+
import FirebaseCore
23
import Foundation
34
import Security
45

@@ -46,4 +47,19 @@ public class CommonUtils {
4647
}
4748
return hash.map { String(format: "%02x", $0) }.joined()
4849
}
50+
51+
public static func dummyConfigurationForPreview() {
52+
guard FirebaseApp.app() == nil else { return }
53+
54+
let options = FirebaseOptions(
55+
googleAppID: "1:123:ios:123abc456def7890",
56+
gcmSenderID: "dummy"
57+
)
58+
options.apiKey = "dummy"
59+
options.projectID = "dummy-project-id"
60+
options.bundleID = Bundle.main.bundleIdentifier ?? "com.example.dummy"
61+
options.clientID = "dummy-abc.apps.googleusercontent.com"
62+
63+
FirebaseApp.configure(options: options)
64+
}
4965
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/EmailAuthView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,9 @@ extension EmailAuthView: View {
132132
}
133133
}
134134
}
135+
136+
#Preview {
137+
CommonUtils.dummyConfigurationForPreview()
138+
return EmailAuthView()
139+
.environment(AuthService())
140+
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/EmailLinkView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,9 @@ extension EmailLinkView: View {
7474
}))
7575
}
7676
}
77+
78+
#Preview {
79+
CommonUtils.dummyConfigurationForPreview()
80+
return EmailLinkView()
81+
.environment(AuthService())
82+
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/PasswordPromptView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ extension PasswordPromptSheet: View {
2727
.padding()
2828
}
2929
}
30+
31+
#Preview {
32+
PasswordPromptSheet(coordinator: PasswordPromptCoordinator())
33+
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/PasswordRecoveryView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ extension PasswordRecoveryView: View {
6767
}))
6868
}
6969
}
70+
71+
#Preview {
72+
CommonUtils.dummyConfigurationForPreview()
73+
return PasswordRecoveryView()
74+
.environment(AuthService())
75+
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/SignedInView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ extension SignedInView: View {
4343
}
4444
}
4545
}
46+
47+
#Preview {
48+
CommonUtils.dummyConfigurationForPreview()
49+
return SignedInView()
50+
.environment(AuthService())
51+
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/VerifyEmailView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ extension VerifyEmailView: View {
4242
}
4343
}
4444
}
45+
46+
#Preview {
47+
CommonUtils.dummyConfigurationForPreview()
48+
return VerifyEmailView()
49+
.environment(AuthService())
50+
}

FirebaseSwiftUI/FirebaseFacebookSwiftUI/Sources/Views/SignInWithFacebookButton.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,9 @@ extension SignInWithFacebookButton: View {
108108
Text(errorMessage).foregroundColor(.red)
109109
}
110110
}
111+
112+
#Preview {
113+
CommonUtils.dummyConfigurationForPreview()
114+
return SignInWithFacebookButton()
115+
.environment(AuthService())
116+
}

FirebaseSwiftUI/FirebaseGoogleSwiftUI/Sources/Views/SignInWithGoogleButton.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ extension SignInWithGoogleButton: View {
4949
})
5050
}
5151
}
52+
53+
#Preview {
54+
CommonUtils.dummyConfigurationForPreview()
55+
return SignInWithGoogleButton()
56+
.environment(AuthService())
57+
}

FirebaseSwiftUI/FirebasePhoneAuthSwiftUI/Sources/Views/PhoneAuthButtonView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,9 @@ extension PhoneAuthButtonView: View {
9090
Text(errorMessage).foregroundColor(.red)
9191
}
9292
}
93+
94+
#Preview {
95+
CommonUtils.dummyConfigurationForPreview()
96+
return PhoneAuthButtonView()
97+
.environment(AuthService())
98+
}

0 commit comments

Comments
 (0)