generated from baekteun/Tuist_Modular_Template
-
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.
- Loading branch information
Showing
36 changed files
with
592 additions
and
77 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,3 @@ | ||
excluded: | ||
- "**/*/NeedleGenerated.swift" | ||
- "Tuist" |
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
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
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 |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import SwiftUI | ||
import DesignSystem | ||
import BaseFeature | ||
import ViewUtil | ||
|
||
@main | ||
struct KillerGramApp: App { | ||
@StateObject var appState = AppState(sceneFlow: .splash) | ||
|
||
init() { | ||
DesignSystemFontFamily.registerAllCustomFonts() | ||
// registerProviderFactori이es() | ||
registerProviderFactories() | ||
} | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
AppComponent() | ||
.makeRootView() | ||
// .eraseToAnyView() | ||
// .environmentObject(appState) | ||
AppComponent().makeRootView() | ||
.eraseToAnyView() | ||
.environmentObject(appState) | ||
} | ||
} | ||
} |
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,115 @@ | ||
|
||
|
||
import NeedleFoundation | ||
import RootFeature | ||
import RootFeatureInterface | ||
import SigninFeature | ||
import SigninFeatureInterface | ||
import SplashFeature | ||
import SplashFeatureInterface | ||
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 SplashDependencye0cb7136f2ec3edfd60aProvider: SplashDependency { | ||
|
||
|
||
init() { | ||
|
||
} | ||
} | ||
/// ^->AppComponent->SplashComponent | ||
private func factoryace9f05f51d68f4c0677e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject { | ||
return SplashDependencye0cb7136f2ec3edfd60aProvider() | ||
} | ||
private class RootDependency3944cc797a4a88956fb5Provider: RootDependency { | ||
var splashFactory: any SplashFactory { | ||
return appComponent.splashFactory | ||
} | ||
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 { | ||
|
||
|
||
init() { | ||
|
||
} | ||
} | ||
/// ^->AppComponent->SigninComponent | ||
private func factory2882a056d84a613debcce3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject { | ||
return SigninDependencyde06a9d0b22764487733Provider() | ||
} | ||
|
||
#else | ||
extension AppComponent: Registration { | ||
public func registerItems() { | ||
|
||
localTable["splashFactory-any SplashFactory"] = { [unowned self] in self.splashFactory as Any } | ||
localTable["signinFactory-any SigninFactory"] = { [unowned self] in self.signinFactory as Any } | ||
} | ||
} | ||
extension SplashComponent: Registration { | ||
public func registerItems() { | ||
|
||
} | ||
} | ||
extension RootComponent: Registration { | ||
public func registerItems() { | ||
keyPathToName[\RootDependency.splashFactory] = "splashFactory-any SplashFactory" | ||
keyPathToName[\RootDependency.signinFactory] = "signinFactory-any SigninFactory" | ||
} | ||
} | ||
extension SigninComponent: Registration { | ||
public func registerItems() { | ||
|
||
} | ||
} | ||
|
||
|
||
#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", factoryEmptyDependencyProvider) | ||
registerProviderFactory("^->AppComponent->SplashComponent", factoryace9f05f51d68f4c0677e3b0c44298fc1c149afb) | ||
registerProviderFactory("^->AppComponent->RootComponent", factory264bfc4d4cb6b0629b40f47b58f8f304c97af4d5) | ||
registerProviderFactory("^->AppComponent->SigninComponent", factory2882a056d84a613debcce3b0c44298fc1c149afb) | ||
} | ||
#endif | ||
|
||
public func registerProviderFactories() { | ||
#if !NEEDLE_DYNAMIC | ||
register1() | ||
#endif | ||
} |
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,9 @@ | ||
import Foundation | ||
|
||
public final class AppState: ObservableObject { | ||
@Published public var sceneFlow: SceneFlow | ||
|
||
public init(sceneFlow: SceneFlow) { | ||
self.sceneFlow = sceneFlow | ||
} | ||
} |
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 SwiftUI | ||
|
||
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 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,7 @@ | ||
import Foundation | ||
|
||
public enum SceneFlow: String, RawRepresentable { | ||
case splash | ||
case auth | ||
case main | ||
} |
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import RootFeatureInterface | ||
import NeedleFoundation | ||
import SwiftUI | ||
import SplashFeatureInterface | ||
import SigninFeatureInterface | ||
|
||
public protocol RootDependency: Dependency { | ||
// var signinFactory: any SigninFactory { get } | ||
// var splashFactory: any SplashFactory { get } | ||
// var mainFactory: any MainFactory { get } | ||
var splashFactory: any SplashFactory { get } | ||
var signinFactory: any SigninFactory { get } | ||
} | ||
|
||
public final class RootComponent: Component<RootDependency>, RootFactory { | ||
public func makeView() -> some View { | ||
RootView( | ||
// signinFactory: dependency.signinFactory, | ||
// splashFactory: dependency.splashFactory, | ||
// mainFactory: dependency.mainFactory | ||
splashFactory: dependency.splashFactory, | ||
signinFactory: 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 |
---|---|---|
@@ -1,42 +1,41 @@ | ||
import BaseFeature | ||
import SwiftUI | ||
|
||
import DesignSystem | ||
import SplashFeatureInterface | ||
import SigninFeatureInterface | ||
import ViewUtil | ||
|
||
struct RootView: View { | ||
// @EnvironmentObject var appState: AppState | ||
// private let signinFactory: any SigninFactory | ||
// private let splashFactory: any SplashFactory | ||
// private let mainFactory: any MainFactory | ||
// | ||
// public init( | ||
// signinFactory: any SigninFactory, | ||
// splashFactory: any SplashFactory, | ||
// mainFactory: any MainFactory | ||
// ) { | ||
// self.signinFactory = signinFactory | ||
// self.splashFactory = splashFactory | ||
// self.mainFactory = mainFactory | ||
// } | ||
@EnvironmentObject var appState: AppState | ||
private let splashFactory: any SplashFactory | ||
private let signinFactory: any SigninFactory | ||
|
||
public init( | ||
splashFactory: any SplashFactory, | ||
signinFactory: any SigninFactory | ||
) { | ||
self.splashFactory = splashFactory | ||
self.signinFactory = signinFactory | ||
} | ||
|
||
var body: some View { | ||
ZStack { | ||
// switch appState.sceneFlow { | ||
// case .auth: | ||
// signinFactory.makeView().eraseToAnyView() | ||
// .environmentObject(appState) | ||
// | ||
// case .main: | ||
// mainFactory.makeView().eraseToAnyView() | ||
// .environmentObject(appState) | ||
// | ||
// case .splash: | ||
// splashFactory.makeView().eraseToAnyView() | ||
// .environmentObject(appState) | ||
// } | ||
Text("RootView") | ||
switch appState.sceneFlow { | ||
case .auth: | ||
signinFactory.makeView().eraseToAnyView() | ||
.environmentObject(appState) | ||
|
||
case .main: | ||
EmptyView() | ||
.environmentObject(appState) | ||
|
||
case .splash: | ||
splashFactory.makeView().eraseToAnyView() | ||
.environmentObject(appState) | ||
} | ||
} | ||
// .animation(.easeInOut, value: appState.sceneFlow) | ||
.background(Color.System.background.ignoresSafeArea()) | ||
.animation(.easeInOut, value: appState.sceneFlow) | ||
.transition(.opacity.animation(.easeInOut)) | ||
} | ||
} |
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,6 @@ | ||
import SwiftUI | ||
|
||
public protocol SigninFactory { | ||
associatedtype SomeView: View | ||
func makeView() -> SomeView | ||
} |
Oops, something went wrong.