Skip to content

Commit

Permalink
🔀 :: (#3) Splash / Signin 퍼블리싱
Browse files Browse the repository at this point in the history
  • Loading branch information
HongSJae authored Apr 23, 2024
2 parents 7d2d55c + ba680a8 commit bf96d58
Show file tree
Hide file tree
Showing 36 changed files with 592 additions and 77 deletions.
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
excluded:
- "**/*/NeedleGenerated.swift"
- "Tuist"
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extension ModulePaths: MicroTargetPathConvertable {

public extension ModulePaths {
enum Feature: String, MicroTargetPathConvertable {
case SigninFeature
case SplashFeature
case RootFeature
case BaseFeature
}
Expand All @@ -43,6 +45,7 @@ public extension ModulePaths {

public extension ModulePaths {
enum Shared: String, MicroTargetPathConvertable {
case ViewUtil
case GlobalThirdPartyLibrary
}
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let settings: Settings = .settings(
defaultSettings: .recommended
)

let scripts: [TargetScript] = generateEnvironment.scripts
let scripts: [TargetScript] = generateEnvironment.appScripts

let targets: [Target] = [
.init(
Expand Down
18 changes: 13 additions & 5 deletions Projects/App/Resources/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -11,15 +14,20 @@
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" name="Background"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<namedColor name="Background">
<color red="0.058823529411764705" green="0.058823529411764705" blue="0.058823529411764705" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
10 changes: 10 additions & 0 deletions Projects/App/Sources/Application/DI/AppComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import NeedleFoundation
import SwiftUI
import RootFeature
import RootFeatureInterface
import SplashFeature
import SplashFeatureInterface
import SigninFeature
import SigninFeatureInterface

public final class AppComponent: BootstrapComponent {
// private let _keychain: any Keychain
Expand All @@ -26,4 +30,10 @@ public final class AppComponent: BootstrapComponent {
}

public extension AppComponent {
var splashFactory: any SplashFactory {
SplashComponent(parent: self)
}
var signinFactory: any SigninFactory {
SigninComponent(parent: self)
}
}
13 changes: 8 additions & 5 deletions Projects/App/Sources/Application/KillerGramApp.swift
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)
}
}
}
115 changes: 115 additions & 0 deletions Projects/App/Sources/Application/NeedleGenerated.swift
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
}
3 changes: 2 additions & 1 deletion Projects/Feature/BaseFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ let project = Project.module(
targets: [
.implements(module: .feature(.BaseFeature), dependencies: [
.userInterface(target: .DesignSystem),
.shared(target: .GlobalThirdPartyLibrary)
.shared(target: .GlobalThirdPartyLibrary),
.shared(target: .ViewUtil)
]),
.tests(module: .feature(.BaseFeature), dependencies: [
.feature(target: .BaseFeature)
Expand Down
9 changes: 9 additions & 0 deletions Projects/Feature/BaseFeature/Sources/AppState.swift
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
}
}
31 changes: 31 additions & 0 deletions Projects/Feature/BaseFeature/Sources/BaseViewModel.swift
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
}
}
}
1 change: 0 additions & 1 deletion Projects/Feature/BaseFeature/Sources/Feature.swift

This file was deleted.

7 changes: 7 additions & 0 deletions Projects/Feature/BaseFeature/Sources/SceneFlow.swift
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
}
12 changes: 6 additions & 6 deletions Projects/Feature/RootFeature/Sources/RootComponent.swift
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
)
}
}
59 changes: 29 additions & 30 deletions Projects/Feature/RootFeature/Sources/RootView.swift
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))
}
}
6 changes: 6 additions & 0 deletions Projects/Feature/SigninFeature/Interface/SigninFactory.swift
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
}
Loading

0 comments on commit bf96d58

Please sign in to comment.