Skip to content

Commit 5af4767

Browse files
committed
Updated struct.
1 parent a4c56f1 commit 5af4767

File tree

13 files changed

+78
-59
lines changed

13 files changed

+78
-59
lines changed

Package.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ let package = Package(
99
defaultLocalization: "en",
1010
platforms: [.iOS(.v13), .macCatalyst(.v13), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v7)],
1111
products: [
12-
/*.library(
13-
name: "FirebaseWrapper",
14-
targets: ["FirebaseWrapper"]
15-
),*/
1612
.library(
1713
name: "FirewrapAuth",
1814
targets: ["FirewrapAuth"]
@@ -57,7 +53,7 @@ let package = Package(
5753
.target(
5854
name: "FirewrapRemoteConfig",
5955
dependencies: [
60-
.product(name: "FirewrapRemoteConfig", package: "firebase-ios-sdk"),
56+
.product(name: "FirebaseRemoteConfig", package: "firebase-ios-sdk"),
6157
.target(name: "Firewrap")
6258
]
6359
)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FirebaseWrapper
1+
# Firewrap (Firebase Wrapper)
22

33
- Auth
44
- Analytics
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import FirebaseCore
33
import SwiftBoost
44

5-
open class FirebaseWrapper {
5+
open class Firewrap {
66

77
public static func configure(with options: FirebaseOptions) {
88
FirebaseApp.configure(options: options)

Sources/FirewrapAuth/Error/FWAuthSignInError.swift renamed to Sources/FirewrapAuth/Error/FirewrapAuthSignInError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import FirebaseAuth
33

4-
public enum FWAuthSignInError: Error {
4+
public enum FirewrapAuthSignInError: Error {
55

66
case cantPresent
77
case mustConfirmViaEmail

Sources/FirewrapAuth/Error/FWADeleteProfileError.swift renamed to Sources/FirewrapAuth/Error/FirewrapDeleteProfileError.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import Foundation
22
import FirebaseAuth
33

4-
public enum FWADeleteProfileError: Error {
4+
public enum FirewrapDeleteProfileError: Error {
55

66
case requiredLogin
77
case faildSignInConfirm
88
case failed
99

10-
public static func get(by error: Error) -> FWADeleteProfileError? {
10+
public static func get(by error: Error) -> FirewrapDeleteProfileError? {
1111
let error = error as NSError
1212
guard error.domain == AuthErrorDomain else{
1313
return nil

Sources/FirewrapAuth/FirebaseWrapperAuth.swift renamed to Sources/FirewrapAuth/FirewrapAuth.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import UIKit
22
import FirebaseCore
3-
import FirebaseWrapper
3+
import Firewrap
44
import FirebaseAuth
55
import GoogleSignIn
66
import SwiftBoost
77

8-
public class FirebaseWrapperAuth {
8+
public class FirewrapAuth {
99

1010
public static func configure(authDidChangedWork: (() -> Void)? = nil) {
1111
// Logs
@@ -49,11 +49,11 @@ public class FirebaseWrapperAuth {
4949
public static var userName: String? { Auth.auth().currentUser?.displayName }
5050
public static var userEmail: String? { Auth.auth().currentUser?.email }
5151

52-
public static var providers: [FirebaseAuthProvider] {
52+
public static var providers: [FirewrapAuthProvider] {
5353
guard let providerData = Auth.auth().currentUser?.providerData else { return [] }
54-
var providers: [FirebaseAuthProvider] = []
54+
var providers: [FirewrapAuthProvider] = []
5555
for providerMeta in providerData {
56-
if let provider = FirebaseAuthProvider.getByBaseURL(providerMeta.providerID) {
56+
if let provider = FirewrapAuthProvider.getByBaseURL(providerMeta.providerID) {
5757
providers.append(provider)
5858
}
5959
}
@@ -70,7 +70,7 @@ public class FirebaseWrapperAuth {
7070

7171
// MARK: - Actions
7272

73-
public static func signInWithApple(on controller: UIViewController, completion: ((SignInWithAppleData?, FWAuthSignInError?) -> Void)?) {
73+
public static func signInWithApple(on controller: UIViewController, completion: ((SignInWithAppleData?, FirewrapAuthSignInError?) -> Void)?) {
7474
printConsole("Sign in with Apple...")
7575
guard let window = controller.view.window else {
7676
completion?(nil, .cantPresent)
@@ -103,7 +103,7 @@ public class FirebaseWrapperAuth {
103103
}
104104
}
105105

106-
public static func signInWithGoogle(on controller: UIViewController, completion: ((FWAuthSignInError?) -> Void)?) {
106+
public static func signInWithGoogle(on controller: UIViewController, completion: ((FirewrapAuthSignInError?) -> Void)?) {
107107
printConsole("Sign in with Google...")
108108
GoogleAuthService.signIn(on: controller) { data, googleError in
109109
if let googleError {
@@ -131,7 +131,7 @@ public class FirebaseWrapperAuth {
131131
/**
132132
Firebase asking about Dynamic Links, but its will depicated. Observing how shoud change it
133133
*/
134-
public static func signInWithEmail(email: String, handleURL: URL, completion: ((FWAuthSignInError?) -> Void)?) {
134+
public static func signInWithEmail(email: String, handleURL: URL, completion: ((FirewrapAuthSignInError?) -> Void)?) {
135135
printConsole("Sign in with Email...")
136136
EmailAuthService.signIn(email: email, handleURL: handleURL) { emailError in
137137
if let emailError {
@@ -145,7 +145,7 @@ public class FirebaseWrapperAuth {
145145
}
146146
}
147147

148-
static func handleSignInWithEmailURL(_ url: URL, completion: ((FWAuthSignInError?) -> Void)?) -> Bool {
148+
static func handleSignInWithEmailURL(_ url: URL, completion: ((FirewrapAuthSignInError?) -> Void)?) -> Bool {
149149
guard Auth.auth().isSignIn(withEmailLink: url.absoluteString) else {
150150
completion?(nil)
151151
return false
@@ -182,12 +182,12 @@ public class FirebaseWrapperAuth {
182182
Auth.auth().revokeToken(withAuthorizationCode: authorizationCode)
183183
}
184184

185-
public static func delete(completion: @escaping (FWADeleteProfileError?)->Void) {
185+
public static func delete(completion: @escaping (FirewrapDeleteProfileError?)->Void) {
186186
printConsole("Deleting Profile...")
187187
Auth.auth().currentUser?.delete(completion: { deleteError in
188-
let unwrapDeleteError: FWADeleteProfileError? = {
188+
let unwrapDeleteError: FirewrapDeleteProfileError? = {
189189
if let deleteError {
190-
return FWADeleteProfileError.get(by: deleteError) ?? .failed
190+
return FirewrapDeleteProfileError.get(by: deleteError) ?? .failed
191191
} else {
192192
return nil
193193
}
@@ -206,13 +206,13 @@ public class FirebaseWrapperAuth {
206206
}
207207

208208
private static func printConsole(_ text: String) {
209-
debug("FirebaseWrapper, Auth: " + text)
209+
debug("Firewrap, Auth: " + text)
210210
}
211211

212212
// MARK: - Singltone
213213

214214
private var observer: AuthStateDidChangeListenerHandle?
215-
private static let shared = FirebaseWrapperAuth()
216-
private var completionSignInViaEmail: ((FWAuthSignInError?) -> Void)? = nil
215+
private static let shared = FirewrapAuth()
216+
private var completionSignInViaEmail: ((FirewrapAuthSignInError?) -> Void)? = nil
217217
private init() {}
218218
}

Sources/FirewrapAuth/FirebaseAuthProvider.swift renamed to Sources/FirewrapAuth/FirewrapAuthProvider.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import Foundation
22

3-
public enum FirebaseAuthProvider: String, CaseIterable {
3+
public enum FirewrapAuthProvider: String, CaseIterable {
44

55
case apple
66
case google
77
case email
88

99
public var id: String { rawValue }
1010

11-
static func getByBaseURL(_ url: String) -> FirebaseAuthProvider? {
11+
static func getByBaseURL(_ url: String) -> FirewrapAuthProvider? {
1212
for provider in Self.allCases {
1313
if url == provider.baseURL {
1414
return provider
1515
}
1616
}
17-
print("FirebaseWrapper: Can't get provider by web url \(url)")
17+
print("Firewrap: Can't get provider by web url \(url)")
1818
return nil
1919
}
2020

Sources/FirewrapAuth/Services/AppleAuthService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AppleAuthService: NSObject, ASAuthorizationControllerDelegate, ASAuthoriza
2626
let authorizationCodeString = String(data: authorizationCode, encoding: .utf8)
2727
else {
2828
// todo parse
29-
completion?(nil, FWAuthSignInError.failed)
29+
completion?(nil, FirewrapAuthSignInError.failed)
3030
return
3131
}
3232

Sources/FirewrapAuth/Services/GoogleAuthService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import GoogleSignIn
44

55
class GoogleAuthService {
66

7-
public static func signIn(on controller: UIViewController, completion: ((SignInWithGoogleData?, FWAuthSignInError?) -> Void)?) {
7+
public static func signIn(on controller: UIViewController, completion: ((SignInWithGoogleData?, FirewrapAuthSignInError?) -> Void)?) {
88
guard let clientID = FirebaseApp.app()?.options.clientID else {
99
completion?(nil, .failed)
1010
return
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
import FirebaseFirestore
3+
4+
class FirewrapCollection {
5+
6+
func getDocument(id: String) -> FirewrapDocument? {
7+
return nil
8+
}
9+
10+
func getDocument(where field: String, equal: Any) -> FirewrapDocument? {
11+
return nil
12+
}
13+
14+
func getDocuments() -> [FirewrapDocument]? {
15+
return nil
16+
}
17+
18+
func observe(_ handler: () -> Void) {
19+
20+
}
21+
}

0 commit comments

Comments
 (0)