Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔀 :: [#83] View 연결 #105

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions App/Sources/Application/DI/AppComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,16 @@ public extension AppComponent {
var recommendBookFactory: any RecommendBookFactory {
RecommendBookComponent(parent: self)
}

var bookOrderFactory: any BookOrderFactory {
BookOrderComponent(parent: self)
}

var mindwayIntroduceFactory: any MindwayIntroduceFactory {
MindwayIntroduceComponent(parent: self)
}

var eventDetailFactory: any EventDetailFactory {
EventDetailComponent(parent: self)
}
}
2 changes: 1 addition & 1 deletion App/Sources/Application/MindWayApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Service
@main
struct MindWayApp: App {
@State private var showMainView = false
@StateObject private var sceneState = SceneState(sceneFlow: .login)
@StateObject private var sceneState = SceneState(sceneFlow: .main)

init() {
registerProviderFactories()
Expand Down
114 changes: 90 additions & 24 deletions App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,30 @@ private func parent1(_ component: NeedleFoundation.Scope) -> NeedleFoundation.Sc
#if !NEEDLE_DYNAMIC

private class EventDependency7c44a7ba678fce8bee09Provider: EventDependency {


init() {

var eventDetailFactory: any EventDetailFactory {
return appComponent.eventDetailFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->EventComponent
private func factory59c5e0d7ceb1b46b5a25e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject {
return EventDependency7c44a7ba678fce8bee09Provider()
private func factory59c5e0d7ceb1b46b5a25f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return EventDependency7c44a7ba678fce8bee09Provider(appComponent: parent1(component) as! AppComponent)
}
private class MyPageDependency48d84b530313b3ee40feProvider: MyPageDependency {


init() {

var mindwayIntroduceFactory: any MindwayIntroduceFactory {
return appComponent.mindwayIntroduceFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->MyPageComponent
private func factory0f6f456ebf157d02dfb3e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject {
return MyPageDependency48d84b530313b3ee40feProvider()
private func factory0f6f456ebf157d02dfb3f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return MyPageDependency48d84b530313b3ee40feProvider(appComponent: parent1(component) as! AppComponent)
}
private class MainDependency7c6a5b4738b211b8e155Provider: MainDependency {

Expand All @@ -50,6 +54,19 @@ private class MainDependency7c6a5b4738b211b8e155Provider: MainDependency {
private func factoryc9274e46e78e70f29c54e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject {
return MainDependency7c6a5b4738b211b8e155Provider()
}
private class MindwayIntroduceDependencyc4365ffea3250f49d853Provider: MindwayIntroduceDependency {
var myPageFactory: any MyPageFactory {
return appComponent.myPageFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->MindwayIntroduceComponent
private func factoryf6e8064cd5a3d7f6fe63f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return MindwayIntroduceDependencyc4365ffea3250f49d853Provider(appComponent: parent1(component) as! AppComponent)
}
private class TabBarDependency6b058f6bef1c605940dfProvider: TabBarDependency {
var mainFactory: any MainFactory {
return appComponent.mainFactory
Expand Down Expand Up @@ -102,33 +119,66 @@ private func factory2882a056d84a613debccf47b58f8f304c97af4d5(_ component: Needle
return SigninDependencyde06a9d0b22764487733Provider(appComponent: parent1(component) as! AppComponent)
}
private class RecommendBookDependency7cd1f82e68cef9855fcdProvider: RecommendBookDependency {


init() {

var bookOrderFactory: any BookOrderFactory {
return appComponent.bookOrderFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->RecommendBookComponent
private func factory2ba4c0e89046a26569d4e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject {
return RecommendBookDependency7cd1f82e68cef9855fcdProvider()
private func factory2ba4c0e89046a26569d4f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return RecommendBookDependency7cd1f82e68cef9855fcdProvider(appComponent: parent1(component) as! AppComponent)
}
private class BookOrderDependency090458c21d8e6b1613deProvider: BookOrderDependency {
var recommendBookFactory: any RecommendBookFactory {
return appComponent.recommendBookFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->BookOrderComponent
private func factory42c646092382554dd34cf47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return BookOrderDependency090458c21d8e6b1613deProvider(appComponent: parent1(component) as! AppComponent)
}
private class EventDetailDependencya414c017c6a5e1011982Provider: EventDetailDependency {
var eventFactory: any EventFactory {
return appComponent.eventFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->EventDetailComponent
private func factory8610907cee92bde36225f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return EventDetailDependencya414c017c6a5e1011982Provider(appComponent: parent1(component) as! AppComponent)
}

#else
extension EventComponent: Registration {
public func registerItems() {

keyPathToName[\EventDependency.eventDetailFactory] = "eventDetailFactory-any EventDetailFactory"
}
}
extension MyPageComponent: Registration {
public func registerItems() {

keyPathToName[\MyPageDependency.mindwayIntroduceFactory] = "mindwayIntroduceFactory-any MindwayIntroduceFactory"
}
}
extension MainComponent: Registration {
public func registerItems() {

}
}
extension MindwayIntroduceComponent: Registration {
public func registerItems() {
keyPathToName[\MindwayIntroduceDependency.myPageFactory] = "myPageFactory-any MyPageFactory"
}
}
extension TabBarComponent: Registration {
public func registerItems() {
keyPathToName[\TabBarDependency.mainFactory] = "mainFactory-any MainFactory"
Expand All @@ -150,7 +200,17 @@ extension SigninComponent: Registration {
}
extension RecommendBookComponent: Registration {
public func registerItems() {

keyPathToName[\RecommendBookDependency.bookOrderFactory] = "bookOrderFactory-any BookOrderFactory"
}
}
extension BookOrderComponent: Registration {
public func registerItems() {
keyPathToName[\BookOrderDependency.recommendBookFactory] = "recommendBookFactory-any RecommendBookFactory"
}
}
extension EventDetailComponent: Registration {
public func registerItems() {
keyPathToName[\EventDetailDependency.eventFactory] = "eventFactory-any EventFactory"
}
}
extension AppComponent: Registration {
Expand All @@ -176,6 +236,9 @@ extension AppComponent: Registration {
localTable["eventFactory-any EventFactory"] = { [unowned self] in self.eventFactory as Any }
localTable["myPageFactory-any MyPageFactory"] = { [unowned self] in self.myPageFactory as Any }
localTable["recommendBookFactory-any RecommendBookFactory"] = { [unowned self] in self.recommendBookFactory as Any }
localTable["bookOrderFactory-any BookOrderFactory"] = { [unowned self] in self.bookOrderFactory as Any }
localTable["mindwayIntroduceFactory-any MindwayIntroduceFactory"] = { [unowned self] in self.mindwayIntroduceFactory as Any }
localTable["eventDetailFactory-any EventDetailFactory"] = { [unowned self] in self.eventDetailFactory as Any }
localTable["remoteNoticeDataSource-any RemoteNoticeDataSource"] = { [unowned self] in self.remoteNoticeDataSource as Any }
localTable["noticeRepository-any NoticeRepository"] = { [unowned self] in self.noticeRepository as Any }
localTable["fetchNoticeUseCase-any FetchNoticeUseCase"] = { [unowned self] in self.fetchNoticeUseCase as Any }
Expand Down Expand Up @@ -219,13 +282,16 @@ private func registerProviderFactory(_ componentPath: String, _ factory: @escapi
#if !NEEDLE_DYNAMIC

@inline(never) private func register1() {
registerProviderFactory("^->AppComponent->EventComponent", factory59c5e0d7ceb1b46b5a25e3b0c44298fc1c149afb)
registerProviderFactory("^->AppComponent->MyPageComponent", factory0f6f456ebf157d02dfb3e3b0c44298fc1c149afb)
registerProviderFactory("^->AppComponent->EventComponent", factory59c5e0d7ceb1b46b5a25f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->MyPageComponent", factory0f6f456ebf157d02dfb3f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->MainComponent", factoryc9274e46e78e70f29c54e3b0c44298fc1c149afb)
registerProviderFactory("^->AppComponent->MindwayIntroduceComponent", factoryf6e8064cd5a3d7f6fe63f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->TabBarComponent", factory9dac845129838b40415cf47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->RootComponent", factory264bfc4d4cb6b0629b40f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->SigninComponent", factory2882a056d84a613debccf47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->RecommendBookComponent", factory2ba4c0e89046a26569d4e3b0c44298fc1c149afb)
registerProviderFactory("^->AppComponent->RecommendBookComponent", factory2ba4c0e89046a26569d4f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->BookOrderComponent", factory42c646092382554dd34cf47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->EventDetailComponent", factory8610907cee92bde36225f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent", factoryEmptyDependencyProvider)
}
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import SwiftUI

public protocol BookOrderFactory {
associatedtype SomeView: View
func makeView() -> SomeView
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import NeedleFoundation
import Service
import SwiftUI

public protocol BookOrderDependency: Dependency {
var recommendBookFactory: any RecommendBookFactory { get }
}

public final class BookOrderComponent: Component<BookOrderDependency>, BookOrderFactory {
public func makeView() -> some View {
BookOrderView(
recommendBookFactory: dependency.recommendBookFactory
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ struct BookOrderView: View {
@StateObject var viewModel = BookOrderViewModel()
@Environment(\.dismiss) var dismiss

private let recommendBookFactory: any RecommendBookFactory

init(
recommendBookFactory: any RecommendBookFactory
) {
self.recommendBookFactory = recommendBookFactory
}

var body: some View {
ZStack {
NavigationView {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import SwiftUI

public protocol EventDetailFactory {
associatedtype SomeView: View
func makeView() -> SomeView
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import NeedleFoundation
import Service
import SwiftUI

public protocol EventDetailDependency: Dependency {
var eventFactory: any EventFactory { get }
}

public final class EventDetailComponent: Component<EventDetailDependency>, EventDetailFactory {
public func makeView() -> some View {
EventDetailView(
eventFactory: dependency.eventFactory
)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import SwiftUI

struct EventDetailView: View {
@StateObject private var viewmodel = EventViewModel()
@Environment(\.dismiss) var dismiss

private let eventFactory: any EventFactory

init(
eventFactory: any EventFactory
) {
self.eventFactory = eventFactory
}

var body: some View {
NavigationView {
VStack(alignment: .leading, spacing: 0) {
Expand All @@ -13,18 +20,18 @@ struct EventDetailView: View {
.frame(height: 264)
.padding(.trailing, 24)

Text(viewmodel.eventTitle)
Text("가을 독서 행사")
.mindWaySemiboldFont(.m1)
.padding(.top, 20)

Text(viewmodel.eventDescription)
Text("독서의 계절, 가을을 맞아 도서관에서 특별한 이벤트를준비했습니다. 랜덤으로 초성 책 제목이 적혀있는 쪽지를 뽑고, 그에 맞는 책을 찾아오면 푸짐한 선물뽑기를 할 수 있습니다. 점심시간마다 진행할 예정이니 많은 관심 바랍니다.")
.mindWayRegularFont(.m3)
.padding(.trailing, 24)
.padding(.top, 10)
.lineSpacing(5)


Text(viewmodel.eventTime)
Text("2024년 08월 1일 ~ 2024년 09월 1일")
.mindWayRegularFont(.label)
.frame(height: 22)
.padding(.top, 14)
Expand Down
8 changes: 6 additions & 2 deletions App/Sources/Feature/EventFeature/Sources/EventComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import NeedleFoundation
import Service
import SwiftUI

public protocol EventDependency: Dependency {}
public protocol EventDependency: Dependency {
var eventDetailFactory: any EventDetailFactory { get }
}

public final class EventComponent: Component<EventDependency>, EventFactory {
public func makeView() -> some View {
EventTopBarView()
EventTopBarView(
eventDetailFactory: dependency.eventDetailFactory
)
}
}

20 changes: 14 additions & 6 deletions App/Sources/Feature/EventFeature/Sources/EventTopBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ import SwiftUI

struct EventTopBarView: View {
@State private var topNavigationState = false
@StateObject private var viewmodel = EventViewModel()
@State private var detailState = false

private let eventDetailFactory: any EventDetailFactory

init(
eventDetailFactory: any EventDetailFactory
) {
self.eventDetailFactory = eventDetailFactory
}

var body: some View {
NavigationView {
VStack(alignment: topNavigationState ? .trailing : .leading, spacing: 0) {
Expand Down Expand Up @@ -47,9 +54,9 @@ struct EventTopBarView: View {
ScrollView(showsIndicators: false) {
ForEach(1...5, id: \.self) { _ in
detailView(
eventTitle: viewmodel.eventTitle,
eventDescription: viewmodel.eventDescription,
eventTime: viewmodel.eventTime,
eventTitle: "가을 독서 행사",
eventDescription: "독서의 계절, 가을을 맞아 도서관에서 특별한 이벤트를준비했습니다. 랜덤으로 초성 책 제목이 적혀있는 쪽지를 뽑고, 그에 맞는 책을 찾아오면 푸짐한 선물뽑기를 할 수 있습니다. 점심시간마다 진행할 예정이니 많은 관심 바랍니다.",
eventTime: "2024년 08월 1일 ~ 2024년 09월 1일",
detailState: $detailState
)
}
Expand All @@ -64,7 +71,9 @@ struct EventTopBarView: View {
Spacer()
}
.fullScreenCover(isPresented: $detailState) {
EventDetailView()
eventDetailFactory
.makeView()
.eraseToAnyView()
}
}
}
Expand Down Expand Up @@ -121,7 +130,6 @@ func detailView(

)
.padding(.top, 20)

}

@ViewBuilder
Expand Down
7 changes: 0 additions & 7 deletions App/Sources/Feature/EventFeature/Sources/EventViewModel.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import SwiftUI

public protocol MindwayIntroduceFactory {
associatedtype SomeView: View
func makeView() -> SomeView
}
Loading
Loading