Skip to content

Commit

Permalink
✨ MainFeature 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
juyeong525 committed Apr 26, 2024
1 parent f9ba81d commit b486eb3
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ extension ModulePaths: MicroTargetPathConvertable {

public extension ModulePaths {
enum Feature: String, MicroTargetPathConvertable {
<<<<<<< HEAD
case SignupFeature
=======
case MainFeature
>>>>>>> 8b8d5cd ( MainFeature 추가)
case SigninFeature
case SplashFeature
case RootFeature
Expand Down
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 @@ -6,8 +6,13 @@ import SplashFeature
import SplashFeatureInterface
import SigninFeature
import SigninFeatureInterface
<<<<<<< HEAD
import SignupFeature
import SignupFeatureInterface
=======
import MainFeature
import MainFeatureInterface
>>>>>>> 8b8d5cd ( MainFeature 추가)

public final class AppComponent: BootstrapComponent {
// private let _keychain: any Keychain
Expand Down Expand Up @@ -38,6 +43,7 @@ public extension AppComponent {
var signinFactory: any SigninFactory {
SigninComponent(parent: self)
}
<<<<<<< HEAD
// Signup
var signupEmailVerifyFactory: any SignupEmailVerifyFactory {
SignupEmailVerifyComponent(parent: self)
Expand All @@ -59,5 +65,9 @@ public extension AppComponent {
}
var signupCheckLevelFactory: any SignupCheckLevelFactory {
SignupCheckLevelComponent(parent: self)
=======
var mainFactory: any MainFactory {
MainComponent(parent: self)
>>>>>>> 8b8d5cd ( MainFeature 추가)
}
}
14 changes: 14 additions & 0 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@


import MainFeature
import MainFeatureInterface
import NeedleFoundation
import RootFeature
import RootFeatureInterface
Expand Down Expand Up @@ -88,6 +90,7 @@ private func factory997eaa831d16af15eee5f47b58f8f304c97af4d5(_ component: Needle
return SignupGenderDependency65e2a6565372eb41f4acProvider(appComponent: parent1(component) as! AppComponent)
}
private class SignupCheckLevelDependencye4ec84c7d38354a454aeProvider: SignupCheckLevelDependency {
private class MainDependency7c6a5b4738b211b8e155Provider: MainDependency {


init() {
Expand Down Expand Up @@ -123,6 +126,10 @@ private class SignupEmailVerifyDependencyf9d372ac752ee19b78caProvider: SignupEma
/// ^->AppComponent->SignupEmailVerifyComponent
private func factory3b1904c76335d70151ebf47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return SignupEmailVerifyDependencyf9d372ac752ee19b78caProvider(appComponent: parent1(component) as! AppComponent)

/// ^->AppComponent->MainComponent
private func factoryc9274e46e78e70f29c54e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject {
return MainDependency7c6a5b4738b211b8e155Provider()
}
private class RootDependency3944cc797a4a88956fb5Provider: RootDependency {
var splashFactory: any SplashFactory {
Expand All @@ -131,6 +138,9 @@ private class RootDependency3944cc797a4a88956fb5Provider: RootDependency {
var signinFactory: any SigninFactory {
return appComponent.signinFactory
}
var mainFactory: any MainFactory {
return appComponent.mainFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
Expand Down Expand Up @@ -167,6 +177,7 @@ extension AppComponent: Registration {
localTable["signupStudentIDFactory-any SignupStudentIDFactory"] = { [unowned self] in self.signupStudentIDFactory as Any }
localTable["signupGenderFactory-any SignupGenderFactory"] = { [unowned self] in self.signupGenderFactory as Any }
localTable["signupCheckLevelFactory-any SignupCheckLevelFactory"] = { [unowned self] in self.signupCheckLevelFactory as Any }
localTable["mainFactory-any MainFactory"] = { [unowned self] in self.mainFactory as Any }
}
}
extension SplashComponent: Registration {
Expand Down Expand Up @@ -195,6 +206,7 @@ extension SignupGenderComponent: Registration {
}
}
extension SignupCheckLevelComponent: Registration {
extension MainComponent: Registration {
public func registerItems() {

}
Expand All @@ -213,6 +225,7 @@ extension RootComponent: Registration {
public func registerItems() {
keyPathToName[\RootDependency.splashFactory] = "splashFactory-any SplashFactory"
keyPathToName[\RootDependency.signinFactory] = "signinFactory-any SigninFactory"
keyPathToName[\RootDependency.mainFactory] = "mainFactory-any MainFactory"
}
}
extension SigninComponent: Registration {
Expand Down Expand Up @@ -245,6 +258,7 @@ private func registerProviderFactory(_ componentPath: String, _ factory: @escapi
registerProviderFactory("^->AppComponent->SignupCheckLevelComponent", factory5b23127e837152346fdae3b0c44298fc1c149afb)
registerProviderFactory("^->AppComponent->SignupNameComponent", factory71e8fa7f4327b1e25ed0f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->SignupEmailVerifyComponent", factory3b1904c76335d70151ebf47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->MainComponent", factoryc9274e46e78e70f29c54e3b0c44298fc1c149afb)
registerProviderFactory("^->AppComponent->RootComponent", factory264bfc4d4cb6b0629b40f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->SigninComponent", factory2882a056d84a613debccf47b58f8f304c97af4d5)
}
Expand Down
3 changes: 3 additions & 0 deletions Projects/Feature/BaseFeature/Sources/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public struct AppState: DynamicProperty {
public final class AppStateProvider: ObservableObject {
@Published public var sceneFlow: SceneFlow
@Published public var rule: RuleExample
<<<<<<< HEAD

=======
>>>>>>> 8b8d5cd (✨ MainFeature 추가)
public init(sceneFlow: SceneFlow, rule: RuleExample) {
self.sceneFlow = sceneFlow
self.rule = rule
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<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"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
19 changes: 19 additions & 0 deletions Projects/Feature/MainFeature/Demo/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import UIKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let viewController = UIViewController()
viewController.view.backgroundColor = .yellow
window?.rootViewController = viewController
window?.makeKeyAndVisible()

return true
}
}
6 changes: 6 additions & 0 deletions Projects/Feature/MainFeature/Interface/MainFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import SwiftUI

public protocol MainFactory {
associatedtype SomeView: View
func makeView() -> SomeView
}
23 changes: 23 additions & 0 deletions Projects/Feature/MainFeature/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import DependencyPlugin
import ProjectDescription
import ProjectDescriptionHelpers

let project = Project.module(
name: ModulePaths.Feature.MainFeature.rawValue,
targets: [
.interface(module: .feature(.MainFeature)),
.implements(
module: .feature(.MainFeature),
dependencies: [
.feature(target: .MainFeature, type: .interface),
.feature(target: .BaseFeature)
]
),
.tests(module: .feature(.MainFeature), dependencies: [
.feature(target: .MainFeature)
]),
.demo(module: .feature(.MainFeature), dependencies: [
.feature(target: .MainFeature)
])
]
)
11 changes: 11 additions & 0 deletions Projects/Feature/MainFeature/Sources/MainComponent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import SwiftUI
import NeedleFoundation
import MainFeatureInterface

public protocol MainDependency: Dependency {}

public final class MainComponent: Component<MainDependency>, MainFactory {
public func makeView() -> some View {
MainView()
}
}
7 changes: 7 additions & 0 deletions Projects/Feature/MainFeature/Sources/MainView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import SwiftUI

public struct MainView: View {
public var body: some View {
Color.red
}
}
11 changes: 11 additions & 0 deletions Projects/Feature/MainFeature/Tests/MainFeatureTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import XCTest

final class MainFeatureTests: XCTestCase {
override func setUpWithError() throws {}

override func tearDownWithError() throws {}

func testExample() {
XCTAssertEqual(1, 1)
}
}
11 changes: 11 additions & 0 deletions Projects/Feature/MainFeature/UITests/MainFeatureUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import XCTest

final class MainFeatureTests: XCTestCase {
override func setUpWithError() throws {}

override func tearDownWithError() throws {}

func testExample() throws {
XCTAssertEqual("A", "A")
}
}
5 changes: 4 additions & 1 deletion Projects/Feature/RootFeature/Sources/RootComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import NeedleFoundation
import SwiftUI
import SplashFeatureInterface
import SigninFeatureInterface
import MainFeatureInterface

public protocol RootDependency: Dependency {
var splashFactory: any SplashFactory { get }
var signinFactory: any SigninFactory { get }
var mainFactory: any MainFactory { get }
}

public final class RootComponent: Component<RootDependency>, RootFactory {
public func makeView() -> some View {
RootView(
splashFactory: dependency.splashFactory,
signinFactory: dependency.signinFactory
signinFactory: dependency.signinFactory,
mainFactory: dependency.mainFactory
)
}
}
8 changes: 6 additions & 2 deletions Projects/Feature/RootFeature/Sources/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ import SwiftUI
import DesignSystem
import SplashFeatureInterface
import SigninFeatureInterface
import MainFeatureInterface
import ViewUtil

struct RootView: View {
@AppState var appState
private let splashFactory: any SplashFactory
private let signinFactory: any SigninFactory
private let mainFactory: any MainFactory

public init(
splashFactory: any SplashFactory,
signinFactory: any SigninFactory
signinFactory: any SigninFactory,
mainFactory: any MainFactory
) {
self.splashFactory = splashFactory
self.signinFactory = signinFactory
self.mainFactory = mainFactory
}

var body: some View {
Expand All @@ -27,7 +31,7 @@ struct RootView: View {
.environmentObject(appState)

case .main:
EmptyView()
mainFactory.makeView().eraseToAnyView()
.environmentObject(appState)

case .splash:
Expand Down
4 changes: 4 additions & 0 deletions Projects/Feature/SigninFeature/Sources/SigninView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct SigninView: View {
case email
case password
}
@AppState var appState
@FocusState private var focusField: FocusField?
@StateObject var viewModel: SigninViewModel

Expand Down Expand Up @@ -71,5 +72,8 @@ struct SigninView: View {
Spacer()
}
.navigate(to: signupEmailVerifyFactory.makeView().eraseToAnyView(), when: $viewModel.isNavigatedToSignup)
.onChange(of: viewModel.isSuccessToSignin) { _ in
self.appState.sceneFlow = .main
}
}
}
3 changes: 2 additions & 1 deletion Projects/Feature/SigninFeature/Sources/SigninViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import Combine
final class SigninViewModel: BaseViewModel {
@Published var email: String = ""
@Published var password: String = ""
@Published var isSuccessToSignin: Bool = false

@Published var isNavigatedToSignup: Bool = false

func signinButtonDidTap() {
print("Signin")
self.isSuccessToSignin = true
}

func signupButtonDidTap() {
Expand Down
Binary file added graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b486eb3

Please sign in to comment.