-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coordinate alert presentation by integrating it into routing system
- Loading branch information
Jon Petersson
committed
Sep 1, 2023
1 parent
ab84091
commit 26a812b
Showing
26 changed files
with
522 additions
and
368 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// AlertCoordinator.swift | ||
// MullvadVPN | ||
// | ||
// Created by Jon Petersson on 2023-08-23. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import MullvadLogging | ||
import Routing | ||
import UIKit | ||
|
||
final class AlertCoordinator: Coordinator, Presentable { | ||
private var alertController: AlertViewController? | ||
private let presentation: AlertPresentation | ||
|
||
var didFinish: (() -> Void)? | ||
|
||
var presentedViewController: UIViewController { | ||
return alertController! | ||
} | ||
|
||
init(presentation: AlertPresentation) { | ||
self.presentation = presentation | ||
} | ||
|
||
func start() { | ||
let alertController = AlertViewController( | ||
header: presentation.header, | ||
title: presentation.title, | ||
message: presentation.message, | ||
icon: presentation.icon | ||
) | ||
|
||
self.alertController = alertController | ||
|
||
alertController.onDismiss = { [weak self] in | ||
self?.didFinish?() | ||
} | ||
|
||
presentation.buttons.forEach { action in | ||
alertController.addAction(title: action.title, style: action.style, handler: action.handler) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.