Skip to content

Commit a6bafd9

Browse files
committed
avoid any view
1 parent 9355939 commit a6bafd9

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Services/AuthService.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import SwiftUI
33

44
public protocol ExternalAuthProvider {
5-
@MainActor var authButton: any View { get }
5+
associatedtype ButtonType: View
6+
@MainActor var authButton: ButtonType { get }
67
}
78

89
public protocol GoogleProviderProtocol: ExternalAuthProvider {
@@ -64,9 +65,9 @@ private final class AuthListenerManager {
6465
@Observable
6566
public final class AuthService {
6667
public init(configuration: AuthConfiguration = AuthConfiguration(), auth: Auth = Auth.auth(),
67-
googleProvider: GoogleProviderProtocol? = nil,
68-
facebookProvider: FacebookProviderProtocol? = nil,
69-
phoneAuthProvider: PhoneAuthProviderProtocol? = nil) {
68+
googleProvider: (any GoogleProviderProtocol)? = nil,
69+
facebookProvider: (any FacebookProviderProtocol)? = nil,
70+
phoneAuthProvider: (any PhoneAuthProviderProtocol)? = nil) {
7071
self.auth = auth
7172
self.configuration = configuration
7273
self.googleProvider = googleProvider
@@ -87,14 +88,14 @@ public final class AuthService {
8788
public var errorMessage = ""
8889
public let passwordPrompt: PasswordPromptCoordinator = .init()
8990

90-
public var googleProvider: GoogleProviderProtocol?
91-
public var facebookProvider: FacebookProviderProtocol?
92-
public var phoneAuthProvider: PhoneAuthProviderProtocol?
91+
public var googleProvider: (any GoogleProviderProtocol)?
92+
public var facebookProvider: (any FacebookProviderProtocol)?
93+
public var phoneAuthProvider: (any PhoneAuthProviderProtocol)?
9394

9495
private var listenerManager: AuthListenerManager?
9596
private var signedInCredential: AuthCredential?
9697

97-
private var safeGoogleProvider: GoogleProviderProtocol {
98+
private var safeGoogleProvider: any GoogleProviderProtocol {
9899
get throws {
99100
guard let provider = googleProvider else {
100101
throw AuthServiceError
@@ -104,7 +105,7 @@ public final class AuthService {
104105
}
105106
}
106107

107-
private var safeFacebookProvider: FacebookProviderProtocol {
108+
private var safeFacebookProvider: any FacebookProviderProtocol {
108109
get throws {
109110
guard let provider = facebookProvider else {
110111
throw AuthServiceError
@@ -114,7 +115,7 @@ public final class AuthService {
114115
}
115116
}
116117

117-
private var safePhoneAuthProvider: PhoneAuthProviderProtocol {
118+
private var safePhoneAuthProvider: any PhoneAuthProviderProtocol {
118119
get throws {
119120
guard let provider = phoneAuthProvider else {
120121
throw AuthServiceError

FirebaseSwiftUI/FirebaseFacebookSwiftUI/Sources/Services/FacebookProviderSwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class FacebookProviderSwift: FacebookProviderProtocol {
3535
shaNonce = CommonUtils.sha256Hash(of: rawNonce)
3636
}
3737

38-
@MainActor public var authButton: any View {
38+
@MainActor public var authButton: SignInWithFacebookButton {
3939
return SignInWithFacebookButton()
4040
}
4141

FirebaseSwiftUI/FirebaseGoogleSwiftUI/Sources/Services/GoogleProviderSwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class GoogleProviderSwift: @preconcurrency GoogleProviderProtocol {
2525
self.clientID = clientID
2626
}
2727

28-
@MainActor public var authButton: any View {
28+
@MainActor public var authButton: GoogleSignInButton {
2929
return GoogleSignInButton {
3030
Task {
3131
try await self.signInWithGoogle(clientID: self.clientID)

FirebaseSwiftUI/FirebasePhoneAuthSwiftUI/Sources/Services/PhoneAuthProviderSwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public typealias VerificationID = String
66

77
public class PhoneAuthProviderSwift: @preconcurrency PhoneAuthProviderProtocol {
88

9-
public var authButton: any View {
9+
public var authButton: Button<Text> {
1010
// TODO: implement me
1111
return Button("Phone", action: { })
1212
}

0 commit comments

Comments
 (0)