Skip to content

Commit 44d07f8

Browse files
format
1 parent a2c8aa1 commit 44d07f8

File tree

6 files changed

+34
-45
lines changed

6 files changed

+34
-45
lines changed

FirebaseSwiftUI/FirebaseOAuthSwiftUI/Sources/Services/AccountService+OAuth.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@ class OAuthDeleteUserOperation: AuthenticatedOperation,
4444
}
4545
}
4646
}
47-

FirebaseSwiftUI/FirebaseOAuthSwiftUI/Sources/Services/AuthService+OAuth.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ public extension AuthService {
2828
return self
2929
}
3030
}
31-

FirebaseSwiftUI/FirebaseOAuthSwiftUI/Sources/Services/OAuthProviderSwift+Presets.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import SwiftUI
1616

1717
/// Preset configurations for common OAuth providers
1818
public extension OAuthProviderSwift {
19-
2019
/// GitHub OAuth provider
2120
/// - Parameters:
2221
/// - scopes: GitHub scopes (default: ["user"])
@@ -31,7 +30,7 @@ public extension OAuthProviderSwift {
3130
buttonForegroundColor: .white
3231
)
3332
}
34-
33+
3534
/// Microsoft OAuth provider
3635
/// - Parameters:
3736
/// - scopes: Microsoft scopes (default: ["openid", "profile", "email"])
@@ -40,14 +39,14 @@ public extension OAuthProviderSwift {
4039
return OAuthProviderSwift(
4140
providerId: "microsoft.com",
4241
scopes: scopes,
43-
customParameters: ["prompt" : "consent"],
42+
customParameters: ["prompt": "consent"],
4443
displayName: "Sign in with Microsoft",
4544
iconSystemName: "building.2",
46-
buttonBackgroundColor: Color(red: 0/255, green: 120/255, blue: 212/255),
45+
buttonBackgroundColor: Color(red: 0 / 255, green: 120 / 255, blue: 212 / 255),
4746
buttonForegroundColor: .white
4847
)
4948
}
50-
49+
5150
/// Yahoo OAuth provider
5251
/// - Parameters:
5352
/// - scopes: Yahoo scopes (default: ["user.readwrite"])
@@ -56,12 +55,11 @@ public extension OAuthProviderSwift {
5655
return OAuthProviderSwift(
5756
providerId: "yahoo.com",
5857
scopes: scopes,
59-
customParameters: ["prompt" : "consent"],
58+
customParameters: ["prompt": "consent"],
6059
displayName: "Sign in with Yahoo",
6160
iconSystemName: "y.circle.fill",
62-
buttonBackgroundColor: Color(red: 80/255, green: 0/255, blue: 155/255),
61+
buttonBackgroundColor: Color(red: 80 / 255, green: 0 / 255, blue: 155 / 255),
6362
buttonForegroundColor: .white
6463
)
6564
}
6665
}
67-

FirebaseSwiftUI/FirebaseOAuthSwiftUI/Sources/Services/OAuthProviderSwift.swift

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public class OAuthProviderSwift: AuthProviderSwift, DeleteUserSwift {
2222
public let providerId: String
2323
public let scopes: [String]
2424
public let customParameters: [String: String]
25-
25+
2626
// Button appearance
2727
public let displayName: String
2828
public let buttonIcon: Image
2929
public let buttonBackgroundColor: Color
3030
public let buttonForegroundColor: Color
31-
31+
3232
/// Initialize a generic OAuth provider
3333
/// - Parameters:
3434
/// - providerId: The OAuth provider ID (e.g., "github.com", "microsoft.com")
@@ -38,15 +38,13 @@ public class OAuthProviderSwift: AuthProviderSwift, DeleteUserSwift {
3838
/// - buttonIcon: Button icon image
3939
/// - buttonBackgroundColor: Button background color
4040
/// - buttonForegroundColor: Button text/icon color
41-
public init(
42-
providerId: String,
43-
scopes: [String] = [],
44-
customParameters: [String: String] = [:],
45-
displayName: String,
46-
buttonIcon: Image,
47-
buttonBackgroundColor: Color = .black,
48-
buttonForegroundColor: Color = .white
49-
) {
41+
public init(providerId: String,
42+
scopes: [String] = [],
43+
customParameters: [String: String] = [:],
44+
displayName: String,
45+
buttonIcon: Image,
46+
buttonBackgroundColor: Color = .black,
47+
buttonForegroundColor: Color = .white) {
5048
self.providerId = providerId
5149
self.scopes = scopes
5250
self.customParameters = customParameters
@@ -55,7 +53,7 @@ public class OAuthProviderSwift: AuthProviderSwift, DeleteUserSwift {
5553
self.buttonBackgroundColor = buttonBackgroundColor
5654
self.buttonForegroundColor = buttonForegroundColor
5755
}
58-
56+
5957
/// Convenience initializer using SF Symbol
6058
/// - Parameters:
6159
/// - providerId: The OAuth provider ID (e.g., "github.com", "microsoft.com")
@@ -65,15 +63,13 @@ public class OAuthProviderSwift: AuthProviderSwift, DeleteUserSwift {
6563
/// - iconSystemName: SF Symbol name
6664
/// - buttonBackgroundColor: Button background color
6765
/// - buttonForegroundColor: Button text/icon color
68-
public convenience init(
69-
providerId: String,
70-
scopes: [String] = [],
71-
customParameters: [String: String] = [:],
72-
displayName: String,
73-
iconSystemName: String,
74-
buttonBackgroundColor: Color = .black,
75-
buttonForegroundColor: Color = .white
76-
) {
66+
public convenience init(providerId: String,
67+
scopes: [String] = [],
68+
customParameters: [String: String] = [:],
69+
displayName: String,
70+
iconSystemName: String,
71+
buttonBackgroundColor: Color = .black,
72+
buttonForegroundColor: Color = .white) {
7773
self.init(
7874
providerId: providerId,
7975
scopes: scopes,
@@ -84,20 +80,20 @@ public class OAuthProviderSwift: AuthProviderSwift, DeleteUserSwift {
8480
buttonForegroundColor: buttonForegroundColor
8581
)
8682
}
87-
83+
8884
@MainActor public func createAuthCredential() async throws -> AuthCredential {
8985
let provider = OAuthProvider(providerID: providerId)
90-
86+
9187
// Set scopes if provided
9288
if !scopes.isEmpty {
9389
provider.scopes = scopes
9490
}
95-
91+
9692
// Set custom parameters if provided
9793
if !customParameters.isEmpty {
9894
provider.customParameters = customParameters
9995
}
100-
96+
10197
return try await withCheckedThrowingContinuation { continuation in
10298
provider.getCredentialWith(nil) { credential, error in
10399
if let error {
@@ -116,7 +112,7 @@ public class OAuthProviderSwift: AuthProviderSwift, DeleteUserSwift {
116112
}
117113
}
118114
}
119-
115+
120116
public func deleteUser(user: User) async throws {
121117
let operation = OAuthDeleteUserOperation(oauthProvider: self)
122118
try await operation(on: user)
@@ -125,20 +121,19 @@ public class OAuthProviderSwift: AuthProviderSwift, DeleteUserSwift {
125121

126122
public class OAuthProviderAuthUI: AuthProviderUI {
127123
public var provider: AuthProviderSwift
128-
124+
129125
public init(provider: AuthProviderSwift) {
130126
self.provider = provider
131127
}
132-
128+
133129
public var id: String {
134130
guard let oauthProvider = provider as? OAuthProviderSwift else {
135131
return "oauth.unknown"
136132
}
137133
return oauthProvider.providerId
138134
}
139-
135+
140136
@MainActor public func authButton() -> AnyView {
141137
AnyView(GenericOAuthButton(provider: provider))
142138
}
143139
}
144-

FirebaseSwiftUI/FirebaseOAuthSwiftUI/Sources/Views/GenericOAuthButton.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import SwiftUI
2020
public struct GenericOAuthButton {
2121
@Environment(AuthService.self) private var authService
2222
let provider: AuthProviderSwift
23-
23+
2424
public init(provider: AuthProviderSwift) {
2525
self.provider = provider
2626
}
@@ -34,7 +34,7 @@ extension GenericOAuthButton: View {
3434
.foregroundColor(.red)
3535
)
3636
}
37-
37+
3838
return AnyView(
3939
Button(action: {
4040
Task {
@@ -48,7 +48,7 @@ extension GenericOAuthButton: View {
4848
.scaledToFit()
4949
.frame(width: 24, height: 24)
5050
.foregroundColor(oauthProvider.buttonForegroundColor)
51-
51+
5252
Text(oauthProvider.displayName)
5353
.fontWeight(.semibold)
5454
.foregroundColor(oauthProvider.buttonForegroundColor)
@@ -62,4 +62,3 @@ extension GenericOAuthButton: View {
6262
)
6363
}
6464
}
65-

FirebaseSwiftUI/FirebaseOAuthSwiftUI/Tests/FirebaseOAuthSwiftUITests/FirebaseOAuthSwiftUITests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ import Testing
1818
@Test func example() async throws {
1919
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
2020
}
21-

0 commit comments

Comments
 (0)