-
Notifications
You must be signed in to change notification settings - Fork 352
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 8, 2023
1 parent
350719c
commit d183883
Showing
27 changed files
with
531 additions
and
393 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file was deleted.
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
Oops, something went wrong.