-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from Team-MindWay/78-add-gauthsignin
🔀 :: [#78] GauthSignin 추가
- Loading branch information
Showing
47 changed files
with
815 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import NeedleFoundation | ||
import Service | ||
import SwiftUI | ||
|
||
public final class AppComponent: BootstrapComponent { | ||
public func makeRootView() -> some View { | ||
rootComponent.makeView() | ||
} | ||
|
||
var rootComponent: RootComponent { | ||
RootComponent(parent: self) | ||
} | ||
|
||
public var keychain: Keychain { | ||
shared { | ||
KeychainImpl() | ||
} | ||
} | ||
} | ||
|
||
public extension AppComponent { | ||
var signinFactory: any SigninFactory { | ||
SigninComponent(parent: self) | ||
} | ||
|
||
var mainFactory: any MainFactory { | ||
MainComponent(parent: self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import NeedleFoundation | ||
import Service | ||
|
||
public extension AppComponent { | ||
var localAuthDataSource: any LocalAuthDataSource { | ||
shared { | ||
LocalAuthDataSourceImpl(keychain: keychain) | ||
} | ||
} | ||
|
||
var remoteAuthDataSource: any RemoteAuthDataSource { | ||
shared { | ||
RemoteAuthDataSourceImpl(keychain: keychain) | ||
} | ||
} | ||
|
||
var authRepository: any AuthRepository { | ||
shared { | ||
AuthRepositoryImpl( | ||
remoteAuthDataSource: remoteAuthDataSource, | ||
localAuthDataSource: localAuthDataSource | ||
) | ||
} | ||
} | ||
|
||
var loginUseCase: any LoginUseCase { | ||
shared { | ||
LoginUseCaseImpl(authRepository: authRepository) | ||
} | ||
} | ||
|
||
var logoutUseCase: any LogoutUseCase { | ||
shared { | ||
LogoutUseCaseImpl(authRepository: authRepository) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
|
||
|
||
import NeedleFoundation | ||
import Service | ||
import SwiftUI | ||
|
||
// swiftlint:disable unused_declaration | ||
private let needleDependenciesHash : String? = nil | ||
|
||
// MARK: - Traversal Helpers | ||
|
||
private func parent1(_ component: NeedleFoundation.Scope) -> NeedleFoundation.Scope { | ||
return component.parent | ||
} | ||
|
||
// MARK: - Providers | ||
|
||
#if !NEEDLE_DYNAMIC | ||
|
||
private class MainDependency7c6a5b4738b211b8e155Provider: MainDependency { | ||
|
||
|
||
init() { | ||
|
||
} | ||
} | ||
/// ^->AppComponent->MainComponent | ||
private func factoryc9274e46e78e70f29c54e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject { | ||
return MainDependency7c6a5b4738b211b8e155Provider() | ||
} | ||
private class RootDependency3944cc797a4a88956fb5Provider: RootDependency { | ||
var signinFactory: any SigninFactory { | ||
return appComponent.signinFactory | ||
} | ||
private let appComponent: AppComponent | ||
init(appComponent: AppComponent) { | ||
self.appComponent = appComponent | ||
} | ||
} | ||
/// ^->AppComponent->RootComponent | ||
private func factory264bfc4d4cb6b0629b40f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject { | ||
return RootDependency3944cc797a4a88956fb5Provider(appComponent: parent1(component) as! AppComponent) | ||
} | ||
private class SigninDependencyde06a9d0b22764487733Provider: SigninDependency { | ||
var loginUseCase: any LoginUseCase { | ||
return appComponent.loginUseCase | ||
} | ||
var mainFactory: any MainFactory { | ||
return appComponent.mainFactory | ||
} | ||
private let appComponent: AppComponent | ||
init(appComponent: AppComponent) { | ||
self.appComponent = appComponent | ||
} | ||
} | ||
/// ^->AppComponent->SigninComponent | ||
private func factory2882a056d84a613debccf47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject { | ||
return SigninDependencyde06a9d0b22764487733Provider(appComponent: parent1(component) as! AppComponent) | ||
} | ||
|
||
#else | ||
extension MainComponent: Registration { | ||
public func registerItems() { | ||
|
||
} | ||
} | ||
extension RootComponent: Registration { | ||
public func registerItems() { | ||
keyPathToName[\RootDependency.signinFactory] = "signinFactory-any SigninFactory" | ||
} | ||
} | ||
extension SigninComponent: Registration { | ||
public func registerItems() { | ||
keyPathToName[\SigninDependency.loginUseCase] = "loginUseCase-any LoginUseCase" | ||
keyPathToName[\SigninDependency.mainFactory] = "mainFactory-any MainFactory" | ||
} | ||
} | ||
extension AppComponent: Registration { | ||
public func registerItems() { | ||
|
||
localTable["keychain-Keychain"] = { [unowned self] in self.keychain as Any } | ||
localTable["localAuthDataSource-any LocalAuthDataSource"] = { [unowned self] in self.localAuthDataSource as Any } | ||
localTable["remoteAuthDataSource-any RemoteAuthDataSource"] = { [unowned self] in self.remoteAuthDataSource as Any } | ||
localTable["authRepository-any AuthRepository"] = { [unowned self] in self.authRepository as Any } | ||
localTable["loginUseCase-any LoginUseCase"] = { [unowned self] in self.loginUseCase as Any } | ||
localTable["logoutUseCase-any LogoutUseCase"] = { [unowned self] in self.logoutUseCase as Any } | ||
localTable["signinFactory-any SigninFactory"] = { [unowned self] in self.signinFactory as Any } | ||
localTable["mainFactory-any MainFactory"] = { [unowned self] in self.mainFactory as Any } | ||
} | ||
} | ||
|
||
|
||
#endif | ||
|
||
private func factoryEmptyDependencyProvider(_ component: NeedleFoundation.Scope) -> AnyObject { | ||
return EmptyDependencyProvider(component: component) | ||
} | ||
|
||
// MARK: - Registration | ||
private func registerProviderFactory(_ componentPath: String, _ factory: @escaping (NeedleFoundation.Scope) -> AnyObject) { | ||
__DependencyProviderRegistry.instance.registerDependencyProviderFactory(for: componentPath, factory) | ||
} | ||
|
||
#if !NEEDLE_DYNAMIC | ||
|
||
@inline(never) private func register1() { | ||
registerProviderFactory("^->AppComponent->MainComponent", factoryc9274e46e78e70f29c54e3b0c44298fc1c149afb) | ||
registerProviderFactory("^->AppComponent->RootComponent", factory264bfc4d4cb6b0629b40f47b58f8f304c97af4d5) | ||
registerProviderFactory("^->AppComponent->SigninComponent", factory2882a056d84a613debccf47b58f8f304c97af4d5) | ||
registerProviderFactory("^->AppComponent", factoryEmptyDependencyProvider) | ||
} | ||
#endif | ||
|
||
public func registerProviderFactories() { | ||
#if !NEEDLE_DYNAMIC | ||
register1() | ||
#endif | ||
} |
7 changes: 7 additions & 0 deletions
7
App/Sources/DesignSystem/Extensions/View+eraseToAnyView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SwiftUI | ||
|
||
public extension View { | ||
func eraseToAnyView() -> AnyView { | ||
AnyView(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import UIKit | ||
|
||
open class BaseViewModel: ObservableObject { | ||
@Published public var isErrorOccurred = false | ||
@Published public var isLoading = false | ||
@Published public var errorMessage = "" | ||
|
||
public init() {} | ||
|
||
public func addCancellable<T>( | ||
_ task: @escaping @Sendable () async throws -> T, | ||
onReceiveValue: @escaping (T) -> Void, | ||
onReceiveError: ((Error) -> Void)? = nil | ||
) { | ||
isLoading = true | ||
Task { | ||
do { | ||
let value = try await task() | ||
onReceiveValue(value) | ||
} catch { | ||
if let onReceiveError { | ||
onReceiveError(error) | ||
} | ||
|
||
errorMessage = error.localizedDescription | ||
isErrorOccurred = true | ||
} | ||
isLoading = false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
public enum SceneFlow: String, RawRepresentable { | ||
case login | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
public enum TabFlow: String, RawRepresentable { | ||
case home | ||
case event | ||
case book | ||
case my | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Foundation | ||
|
||
public final class SceneState: ObservableObject { | ||
@Published public var sceneFlow: SceneFlow | ||
|
||
init(sceneFlow: SceneFlow) { | ||
self.sceneFlow = sceneFlow | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import NeedleFoundation | ||
import Service | ||
import SwiftUI | ||
|
||
public protocol MainDependency: Dependency {} | ||
|
||
public final class MainComponent: Component<MainDependency>, MainFactory { | ||
public func makeView() -> some View { | ||
MainView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SwiftUI | ||
|
||
public protocol MainFactory { | ||
associatedtype SomeView: View | ||
func makeView() -> SomeView | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import NeedleFoundation | ||
import SwiftUI | ||
|
||
public protocol RootDependency: Dependency { | ||
var signinFactory: any SigninFactory { get } | ||
} | ||
|
||
public final class RootComponent: Component<RootDependency> { | ||
public func makeView() -> some View { | ||
RootView( | ||
signinFactory: self.dependency.signinFactory | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import SwiftUI | ||
|
||
struct RootView: View { | ||
@EnvironmentObject var sceneState: SceneState | ||
private let signinFactory: any SigninFactory | ||
|
||
public init( | ||
signinFactory: any SigninFactory | ||
) { | ||
self.signinFactory = signinFactory | ||
} | ||
|
||
var body: some View { | ||
Group { | ||
switch sceneState.sceneFlow { | ||
case .login: | ||
signinFactory.makeView() | ||
.eraseToAnyView() | ||
.environmentObject(sceneState) | ||
} | ||
} | ||
.animation(.default, value: sceneState.sceneFlow) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
App/Sources/Feature/SigninFeature/Component/GAuthButtonView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import GAuthSignin | ||
import SwiftUI | ||
import UIKit | ||
|
||
struct GAuthButtonView: UIViewRepresentable { | ||
private let completion: (String) -> Void | ||
|
||
init( | ||
completion: @escaping (String) -> Void | ||
) { | ||
self.completion = completion | ||
} | ||
|
||
func updateUIView(_ uiView: UIViewType, context: Context) { } | ||
|
||
func makeUIView(context: Context) -> some UIView { | ||
let gauthButton = GAuthButton( | ||
auth: .signup, | ||
color: .outline, | ||
rounded: .default | ||
) | ||
guard let presentingViewController = (UIApplication.shared.connectedScenes.first as? UIWindowScene)? | ||
.windows | ||
.first? | ||
.rootViewController | ||
else { return gauthButton } | ||
gauthButton.prepare( | ||
clientID: Bundle.main.object(forInfoDictionaryKey: "CLIENT_ID") as? String ?? "", | ||
redirectURI: Bundle.main.object(forInfoDictionaryKey: "REDIRECT_URI") as? String ?? "", | ||
presenting: presentingViewController, | ||
completion: completion | ||
) | ||
return gauthButton | ||
} | ||
} |
Oops, something went wrong.