|
|
@@ -24,6 +24,8 @@ final class MainCoordinator: BaseCoordinator {
|
|
|
switch route {
|
|
|
case .products:
|
|
|
showProductsModule()
|
|
|
+ case .product(let id):
|
|
|
+ showProductModule(with: id)
|
|
|
case .cart:
|
|
|
showCartModule()
|
|
|
default: EmptyView()
|
|
|
@@ -38,6 +40,9 @@ final class MainCoordinator: BaseCoordinator {
|
|
|
onProducts: { [weak self] in
|
|
|
self?.currentRouter.push(Route.products)
|
|
|
},
|
|
|
+ onProduct: { [weak self] id in
|
|
|
+ self?.currentRouter.push(Route.product(id: id))
|
|
|
+ },
|
|
|
onCart: { [weak self] in
|
|
|
self?.currentRouter.push(Route.cart)
|
|
|
}
|
|
|
@@ -48,6 +53,9 @@ final class MainCoordinator: BaseCoordinator {
|
|
|
private func showProductsModule() -> some View {
|
|
|
ProductsBuilder().build(
|
|
|
with: .init(
|
|
|
+ onProduct: { [weak self] in
|
|
|
+ self?.currentRouter.push(Route.product(id: $0))
|
|
|
+ },
|
|
|
onCart: { [weak self] in
|
|
|
self?.currentRouter.push(Route.cart)
|
|
|
}
|
|
|
@@ -64,4 +72,18 @@ final class MainCoordinator: BaseCoordinator {
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
+ private func showProductModule(with id: Int) -> some View {
|
|
|
+ ProductBuilder().build(
|
|
|
+ with: .init(id: id),
|
|
|
+ output: .init(
|
|
|
+ onProducts: { [weak self] in
|
|
|
+ self?.currentRouter.push(Route.products)
|
|
|
+ },
|
|
|
+ onCart: { [weak self] in
|
|
|
+ self?.currentRouter.push(Route.cart)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|