|
|
@@ -13,6 +13,8 @@ final class MainCoordinator: BaseCoordinator {
|
|
|
@Published
|
|
|
var presentation: Route?
|
|
|
|
|
|
+ var alertPresenter = AlertPresenter()
|
|
|
+
|
|
|
func run() -> some View {
|
|
|
showMainModule()
|
|
|
}
|
|
|
@@ -46,7 +48,7 @@ final class MainCoordinator: BaseCoordinator {
|
|
|
}
|
|
|
|
|
|
func onDismissPresentation() {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// MARK: - Private methods
|
|
|
@@ -113,6 +115,11 @@ final class MainCoordinator: BaseCoordinator {
|
|
|
},
|
|
|
onCart: { [weak self] in
|
|
|
self?.currentRouter.push(Route.cart)
|
|
|
+ },
|
|
|
+ onAlert: { [weak self] title in
|
|
|
+ self?.alertPresenter.showSimpleAlert(title) {
|
|
|
+ print("Alert OK")
|
|
|
+ }
|
|
|
}
|
|
|
)
|
|
|
)
|
|
|
@@ -129,10 +136,12 @@ struct MainNavigationView: View {
|
|
|
|
|
|
@StateObject private var coordinator: MainCoordinator
|
|
|
@StateObject private var router: Router
|
|
|
+ @StateObject private var alertPresenter: AlertPresenter
|
|
|
|
|
|
init(_ coordinator: MainCoordinator) {
|
|
|
_coordinator = StateObject(wrappedValue: coordinator)
|
|
|
_router = StateObject(wrappedValue: coordinator.currentRouter)
|
|
|
+ _alertPresenter = StateObject(wrappedValue: coordinator.alertPresenter)
|
|
|
}
|
|
|
|
|
|
var body: some View {
|
|
|
@@ -146,6 +155,10 @@ struct MainNavigationView: View {
|
|
|
item: $coordinator.presentation,
|
|
|
onDismiss: coordinator.onDismissPresentation,
|
|
|
content: coordinator.buildPresentation
|
|
|
+ ).alert(
|
|
|
+ alertPresenter.title,
|
|
|
+ isPresented: $alertPresenter.isPresenting,
|
|
|
+ actions: alertPresenter.buildButtons
|
|
|
)
|
|
|
}
|
|
|
}
|