diff --git a/App/Sources/Application/DI/AppComponent.swift b/App/Sources/Application/DI/AppComponent.swift index b309f0d..22f755e 100644 --- a/App/Sources/Application/DI/AppComponent.swift +++ b/App/Sources/Application/DI/AppComponent.swift @@ -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) + } } diff --git a/App/Sources/Application/MindWayApp.swift b/App/Sources/Application/MindWayApp.swift index bd462d5..9cf116c 100644 --- a/App/Sources/Application/MindWayApp.swift +++ b/App/Sources/Application/MindWayApp.swift @@ -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() diff --git a/App/Sources/Application/NeedleGenerated.swift b/App/Sources/Application/NeedleGenerated.swift index 48c9cf3..64ef6ea 100644 --- a/App/Sources/Application/NeedleGenerated.swift +++ b/App/Sources/Application/NeedleGenerated.swift @@ -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 { @@ -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 @@ -102,26 +119,54 @@ 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 { @@ -129,6 +174,11 @@ extension MainComponent: Registration { } } +extension MindwayIntroduceComponent: Registration { + public func registerItems() { + keyPathToName[\MindwayIntroduceDependency.myPageFactory] = "myPageFactory-any MyPageFactory" + } +} extension TabBarComponent: Registration { public func registerItems() { keyPathToName[\TabBarDependency.mainFactory] = "mainFactory-any MainFactory" @@ -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 { @@ -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 } @@ -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 diff --git a/App/Sources/Feature/BookOrderFeature/Interface/BookOrderFactory.swift b/App/Sources/Feature/BookOrderFeature/Interface/BookOrderFactory.swift new file mode 100644 index 0000000..638c4aa --- /dev/null +++ b/App/Sources/Feature/BookOrderFeature/Interface/BookOrderFactory.swift @@ -0,0 +1,6 @@ +import SwiftUI + +public protocol BookOrderFactory { + associatedtype SomeView: View + func makeView() -> SomeView +} diff --git a/App/Sources/Feature/BookOrderFeature/Sources/BookOrderComponent.swift b/App/Sources/Feature/BookOrderFeature/Sources/BookOrderComponent.swift new file mode 100644 index 0000000..a735528 --- /dev/null +++ b/App/Sources/Feature/BookOrderFeature/Sources/BookOrderComponent.swift @@ -0,0 +1,15 @@ +import NeedleFoundation +import Service +import SwiftUI + +public protocol BookOrderDependency: Dependency { + var recommendBookFactory: any RecommendBookFactory { get } +} + +public final class BookOrderComponent: Component, BookOrderFactory { + public func makeView() -> some View { + BookOrderView( + recommendBookFactory: dependency.recommendBookFactory + ) + } +} diff --git a/App/Sources/Feature/BookOrderFeature/Sources/BookOrderView.swift b/App/Sources/Feature/BookOrderFeature/Sources/BookOrderView.swift index 3f50cbe..60acf95 100644 --- a/App/Sources/Feature/BookOrderFeature/Sources/BookOrderView.swift +++ b/App/Sources/Feature/BookOrderFeature/Sources/BookOrderView.swift @@ -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 { diff --git a/App/Sources/Feature/EventDetailFeature/Interface/EventDetailFactory.swift b/App/Sources/Feature/EventDetailFeature/Interface/EventDetailFactory.swift new file mode 100644 index 0000000..4459fb7 --- /dev/null +++ b/App/Sources/Feature/EventDetailFeature/Interface/EventDetailFactory.swift @@ -0,0 +1,6 @@ +import SwiftUI + +public protocol EventDetailFactory { + associatedtype SomeView: View + func makeView() -> SomeView +} diff --git a/App/Sources/Feature/EventDetailFeature/Sources/EventDetailComponent.swift b/App/Sources/Feature/EventDetailFeature/Sources/EventDetailComponent.swift new file mode 100644 index 0000000..cd867bb --- /dev/null +++ b/App/Sources/Feature/EventDetailFeature/Sources/EventDetailComponent.swift @@ -0,0 +1,15 @@ +import NeedleFoundation +import Service +import SwiftUI + +public protocol EventDetailDependency: Dependency { + var eventFactory: any EventFactory { get } +} + +public final class EventDetailComponent: Component, EventDetailFactory { + public func makeView() -> some View { + EventDetailView( + eventFactory: dependency.eventFactory + ) + } +} diff --git a/App/Sources/Feature/EventFeature/Sources/EventDetailView.swift b/App/Sources/Feature/EventDetailFeature/Sources/EventDetailView.swift similarity index 69% rename from App/Sources/Feature/EventFeature/Sources/EventDetailView.swift rename to App/Sources/Feature/EventDetailFeature/Sources/EventDetailView.swift index 7130248..fe189ec 100644 --- a/App/Sources/Feature/EventFeature/Sources/EventDetailView.swift +++ b/App/Sources/Feature/EventDetailFeature/Sources/EventDetailView.swift @@ -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) { @@ -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) diff --git a/App/Sources/Feature/EventFeature/Sources/EventComponent.swift b/App/Sources/Feature/EventFeature/Sources/EventComponent.swift index 2c423ab..8ecd31e 100644 --- a/App/Sources/Feature/EventFeature/Sources/EventComponent.swift +++ b/App/Sources/Feature/EventFeature/Sources/EventComponent.swift @@ -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, EventFactory { public func makeView() -> some View { - EventTopBarView() + EventTopBarView( + eventDetailFactory: dependency.eventDetailFactory + ) } } diff --git a/App/Sources/Feature/EventFeature/Sources/EventTopBarView.swift b/App/Sources/Feature/EventFeature/Sources/EventTopBarView.swift index 2a91a15..6f809c8 100644 --- a/App/Sources/Feature/EventFeature/Sources/EventTopBarView.swift +++ b/App/Sources/Feature/EventFeature/Sources/EventTopBarView.swift @@ -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) { @@ -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 ) } @@ -64,7 +71,9 @@ struct EventTopBarView: View { Spacer() } .fullScreenCover(isPresented: $detailState) { - EventDetailView() + eventDetailFactory + .makeView() + .eraseToAnyView() } } } @@ -121,7 +130,6 @@ func detailView( ) .padding(.top, 20) - } @ViewBuilder diff --git a/App/Sources/Feature/EventFeature/Sources/EventViewModel.swift b/App/Sources/Feature/EventFeature/Sources/EventViewModel.swift deleted file mode 100644 index f6cbacf..0000000 --- a/App/Sources/Feature/EventFeature/Sources/EventViewModel.swift +++ /dev/null @@ -1,7 +0,0 @@ -import SwiftUI - -class EventViewModel: ObservableObject { - @Published var eventTitle: String = "가을 독서 행사" - @Published var eventDescription: String = "독서의 계절, 가을을 맞아 도서관에서 특별한 이벤트를준비했습니다. 랜덤으로 초성 책 제목이 적혀있는 쪽지를 뽑고, 그에 맞는 책을 찾아오면 푸짐한 선물뽑기를 할 수 있습니다. 점심시간마다 진행할 예정이니 많은 관심 바랍니다." - @Published var eventTime: String = "2024년 08월 1일 ~ 2024년 09월 1일" -} diff --git a/App/Sources/Feature/MindWayIntroduceFeature/Interface/MindwayIntroduceFactory.swift b/App/Sources/Feature/MindWayIntroduceFeature/Interface/MindwayIntroduceFactory.swift new file mode 100644 index 0000000..d79ec36 --- /dev/null +++ b/App/Sources/Feature/MindWayIntroduceFeature/Interface/MindwayIntroduceFactory.swift @@ -0,0 +1,6 @@ +import SwiftUI + +public protocol MindwayIntroduceFactory { + associatedtype SomeView: View + func makeView() -> SomeView +} diff --git a/App/Sources/Feature/MyPageFeature/Sources/MindWayIntroduceView.swift b/App/Sources/Feature/MindWayIntroduceFeature/Sources/MindWayIntroduceView.swift similarity index 90% rename from App/Sources/Feature/MyPageFeature/Sources/MindWayIntroduceView.swift rename to App/Sources/Feature/MindWayIntroduceFeature/Sources/MindWayIntroduceView.swift index e9a44bf..6700c44 100644 --- a/App/Sources/Feature/MyPageFeature/Sources/MindWayIntroduceView.swift +++ b/App/Sources/Feature/MindWayIntroduceFeature/Sources/MindWayIntroduceView.swift @@ -3,6 +3,14 @@ import SwiftUI struct MindWayIntroduceView: View { @Environment(\.dismiss) var dismiss + private let myPageFactory: any MyPageFactory + + init( + myPageFactory: any MyPageFactory + ) { + self.myPageFactory = myPageFactory + } + var body: some View { NavigationView { VStack(alignment: .center) { diff --git a/App/Sources/Feature/MindWayIntroduceFeature/Sources/MindwayIntroduceComponent.swift b/App/Sources/Feature/MindWayIntroduceFeature/Sources/MindwayIntroduceComponent.swift new file mode 100644 index 0000000..b14ae05 --- /dev/null +++ b/App/Sources/Feature/MindWayIntroduceFeature/Sources/MindwayIntroduceComponent.swift @@ -0,0 +1,15 @@ +import NeedleFoundation +import Service +import SwiftUI + +public protocol MindwayIntroduceDependency: Dependency { + var myPageFactory: any MyPageFactory { get } +} + +public final class MindwayIntroduceComponent: Component, MindwayIntroduceFactory { + public func makeView() -> some View { + MindWayIntroduceView( + myPageFactory: dependency.myPageFactory + ) + } +} diff --git a/App/Sources/Feature/MyPageFeature/Sources/MyPageComponent.swift b/App/Sources/Feature/MyPageFeature/Sources/MyPageComponent.swift index a714c59..61846df 100644 --- a/App/Sources/Feature/MyPageFeature/Sources/MyPageComponent.swift +++ b/App/Sources/Feature/MyPageFeature/Sources/MyPageComponent.swift @@ -2,11 +2,12 @@ import NeedleFoundation import Service import SwiftUI -public protocol MyPageDependency: Dependency {} +public protocol MyPageDependency: Dependency { + var mindwayIntroduceFactory: any MindwayIntroduceFactory { get } +} public final class MyPageComponent: Component, MyPageFactory { public func makeView() -> some View { - MyPageView(viewModel: MyPageViewModel()) + MyPageView(viewModel: MyPageViewModel(), mindwayIntroduceFactory: dependency.mindwayIntroduceFactory) } } - diff --git a/App/Sources/Feature/MyPageFeature/Sources/MyPageView.swift b/App/Sources/Feature/MyPageFeature/Sources/MyPageView.swift index 193ee71..48a04f4 100644 --- a/App/Sources/Feature/MyPageFeature/Sources/MyPageView.swift +++ b/App/Sources/Feature/MyPageFeature/Sources/MyPageView.swift @@ -4,10 +4,14 @@ struct MyPageView: View { @Environment(\.dismiss) var dismiss @StateObject var viewModel: MyPageViewModel + private let mindwayIntroduceFactory: any MindwayIntroduceFactory + init( - viewModel: MyPageViewModel + viewModel: MyPageViewModel, + mindwayIntroduceFactory: any MindwayIntroduceFactory ) { _viewModel = StateObject(wrappedValue: viewModel) + self.mindwayIntroduceFactory = mindwayIntroduceFactory } var body: some View { @@ -94,7 +98,9 @@ struct MyPageView: View { .toolbar(.hidden, for: .tabBar) } .fullScreenCover(isPresented: $viewModel.isNavigateMindWayIntroducePage) { - MindWayIntroduceView() + mindwayIntroduceFactory + .makeView() + .eraseToAnyView() } } diff --git a/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookComponent.swift b/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookComponent.swift index d49ceb1..f188aeb 100644 --- a/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookComponent.swift +++ b/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookComponent.swift @@ -2,10 +2,14 @@ import NeedleFoundation import Service import SwiftUI -public protocol RecommendBookDependency: Dependency {} +public protocol RecommendBookDependency: Dependency { + var bookOrderFactory: any BookOrderFactory { get } +} public final class RecommendBookComponent: Component, RecommendBookFactory { public func makeView() -> some View { - RecommendBookView() + RecommendBookView( + bookOrderFactory: dependency.bookOrderFactory + ) } } diff --git a/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookView.swift b/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookView.swift index b809a0a..848e652 100644 --- a/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookView.swift +++ b/App/Sources/Feature/RecommendBookFeature/Sources/RecommendBookView.swift @@ -4,6 +4,14 @@ struct RecommendBookView: View { @State var navigateTopBarStatus: Bool = false @State var isBookOrder: Bool = false + private let bookOrderFactory: any BookOrderFactory + + init( + bookOrderFactory: any BookOrderFactory + ) { + self.bookOrderFactory = bookOrderFactory + } + var body: some View { VStack { HStack(spacing: 20) { @@ -52,7 +60,9 @@ struct RecommendBookView: View { .fullScreenCover( isPresented: $isBookOrder ) { - BookOrderView() + bookOrderFactory + .makeView() + .eraseToAnyView() } } .padding(.horizontal, 24)