summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2023-10-10 15:13:58 +0200
committerBug Magnet <marco.nikic@mullvad.net>2023-10-10 15:13:58 +0200
commit9efdfafd98b8dedc8a96fb66f59f682b0f3aa509 (patch)
treec5e981606f7ccae82211b8056ac98cc7a105341e
parentdb1d41f577fb470ad241a8bc3adbf65bfccb2a74 (diff)
parentf6e3aedaa87cf6a7c4c081ba99204c3db4588ed1 (diff)
downloadmullvadvpn-9efdfafd98b8dedc8a96fb66f59f682b0f3aa509.tar.xz
mullvadvpn-9efdfafd98b8dedc8a96fb66f59f682b0f3aa509.zip
Merge branch 'device-name-does-not-appear-in-bold-in-handledevicedeletion-ios-333'
-rw-r--r--ios/MullvadVPN/Coordinators/AccountCoordinator.swift1
-rw-r--r--ios/MullvadVPN/Coordinators/AlertCoordinator.swift20
-rw-r--r--ios/MullvadVPN/Coordinators/ChangeLogCoordinator.swift37
-rw-r--r--ios/MullvadVPN/View controllers/Alert/AlertPresentation.swift3
-rw-r--r--ios/MullvadVPN/View controllers/Alert/AlertViewController.swift30
-rw-r--r--ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift41
-rw-r--r--ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift4
7 files changed, 70 insertions, 66 deletions
diff --git a/ios/MullvadVPN/Coordinators/AccountCoordinator.swift b/ios/MullvadVPN/Coordinators/AccountCoordinator.swift
index 0338d7427b..3c58e35287 100644
--- a/ios/MullvadVPN/Coordinators/AccountCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/AccountCoordinator.swift
@@ -172,6 +172,7 @@ final class AccountCoordinator: Coordinator, Presentable, Presenting {
let presentation = AlertPresentation(
id: "account-device-info-alert",
+ icon: .info,
message: message,
buttons: [AlertAction(
title: NSLocalizedString(
diff --git a/ios/MullvadVPN/Coordinators/AlertCoordinator.swift b/ios/MullvadVPN/Coordinators/AlertCoordinator.swift
index c06691e222..f40b9198cc 100644
--- a/ios/MullvadVPN/Coordinators/AlertCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/AlertCoordinator.swift
@@ -25,26 +25,10 @@ final class AlertCoordinator: Coordinator, Presentable {
}
func start() {
- let alertController = AlertViewController(
- header: presentation.header,
- title: presentation.title,
- message: presentation.message,
- icon: presentation.icon
- )
+ alertController = AlertViewController(presentation: presentation)
- self.alertController = alertController
-
- alertController.onDismiss = { [weak self] in
+ alertController?.onDismiss = { [weak self] in
self?.didFinish?()
}
-
- presentation.buttons.forEach { action in
- alertController.addAction(
- title: action.title,
- style: action.style,
- accessibilityId: action.accessibilityID,
- handler: action.handler
- )
- }
}
}
diff --git a/ios/MullvadVPN/Coordinators/ChangeLogCoordinator.swift b/ios/MullvadVPN/Coordinators/ChangeLogCoordinator.swift
index e55a31b13d..915502fd43 100644
--- a/ios/MullvadVPN/Coordinators/ChangeLogCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/ChangeLogCoordinator.swift
@@ -24,27 +24,28 @@ final class ChangeLogCoordinator: Coordinator, Presentable {
}
func start() {
- let alertController = AlertViewController(
+ let presentation = AlertPresentation(
+ id: "change-log-ok-alert",
header: interactor.viewModel.header,
title: interactor.viewModel.title,
- attributedMessage: interactor.viewModel.body
+ attributedMessage: interactor.viewModel.body,
+ buttons: [
+ AlertAction(
+ title: NSLocalizedString(
+ "CHANGE_LOG_OK_ACTION",
+ tableName: "Account",
+ value: "Got it!",
+ comment: ""
+ ),
+ style: .default,
+ handler: { [weak self] in
+ guard let self else { return }
+ didFinish?(self)
+ }
+ ),
+ ]
)
- alertController.addAction(
- title: NSLocalizedString(
- "CHANGE_LOG_OK_ACTION",
- tableName: "Account",
- value: "Got it!",
- comment: ""
- ),
- style: .default,
- accessibilityId: "OkButton",
- handler: { [weak self] in
- guard let self else { return }
- didFinish?(self)
- }
- )
-
- self.alertController = alertController
+ alertController = AlertViewController(presentation: presentation)
}
}
diff --git a/ios/MullvadVPN/View controllers/Alert/AlertPresentation.swift b/ios/MullvadVPN/View controllers/Alert/AlertPresentation.swift
index c09d0e1e72..38f60a8981 100644
--- a/ios/MullvadVPN/View controllers/Alert/AlertPresentation.swift
+++ b/ios/MullvadVPN/View controllers/Alert/AlertPresentation.swift
@@ -27,7 +27,8 @@ struct AlertPresentation: Identifiable, CustomDebugStringConvertible {
var header: String?
var icon: AlertIcon?
var title: String?
- let message: String?
+ var message: String?
+ var attributedMessage: NSAttributedString?
let buttons: [AlertAction]
var debugDescription: String {
diff --git a/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift b/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift
index bac96175b2..d45e16bcf6 100644
--- a/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift
+++ b/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift
@@ -58,19 +58,27 @@ class AlertViewController: UIViewController {
private var handlers = [UIButton: Handler]()
- init(header: String? = nil, title: String? = nil, message: String? = nil, icon: AlertIcon? = nil) {
+ init(presentation: AlertPresentation) {
super.init(nibName: nil, bundle: nil)
- setUp(header: header, title: title, icon: icon) {
- message.flatMap { addMessage($0) }
+ setUp(
+ header: presentation.header,
+ title: presentation.title,
+ icon: presentation.icon
+ ) {
+ if let message = presentation.attributedMessage {
+ addMessage(message)
+ } else if let message = presentation.message {
+ addMessage(message)
+ }
}
- }
-
- init(header: String? = nil, title: String? = nil, attributedMessage: NSAttributedString?, icon: AlertIcon? = nil) {
- super.init(nibName: nil, bundle: nil)
- setUp(header: header, title: title, icon: icon) {
- attributedMessage.flatMap { addMessage($0) }
+ presentation.buttons.forEach { action in
+ addAction(
+ title: action.title,
+ style: action.style,
+ handler: action.handler
+ )
}
}
@@ -120,14 +128,13 @@ class AlertViewController: UIViewController {
}
}
- func addAction(title: String, style: AlertActionStyle, accessibilityId: String?, handler: (() -> Void)? = nil) {
+ func addAction(title: String, style: AlertActionStyle, handler: (() -> Void)? = nil) {
// The presence of a button should reset any custom button margin to default.
containerView.directionalLayoutMargins.bottom = UIMetrics.CustomAlert.containerMargins.bottom
let button = AppButton(style: style.buttonStyle)
button.setTitle(title, for: .normal)
- button.accessibilityIdentifier = accessibilityId
button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside)
containerView.addArrangedSubview(button)
@@ -185,6 +192,7 @@ class AlertViewController: UIViewController {
let label = UILabel()
label.attributedText = message
+ label.textColor = .white.withAlphaComponent(0.8)
label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 0
diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift
index 7675490333..c54c55836b 100644
--- a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift
+++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift
@@ -183,40 +183,49 @@ class DeviceManagementViewController: UIViewController, RootContainment {
deviceName: String,
completion: @escaping (_ shouldDelete: Bool) -> Void
) {
+ let text = String(
+ format: NSLocalizedString(
+ "DELETE_ALERT_TITLE",
+ tableName: "DeviceManagement",
+ value: "Are you sure you want to log **\(deviceName)** out?",
+ comment: ""
+ )
+ )
+
+ let attributedText = NSAttributedString(
+ markdownString: text,
+ options: MarkdownStylingOptions(
+ font: .preferredFont(forTextStyle: .body)
+ )
+ )
+
let presentation = AlertPresentation(
id: "logout-confirmation-alert",
icon: .alert,
- message: String(
- format: NSLocalizedString(
- "DELETE_ALERT_TITLE",
- tableName: "DeviceManagement",
- value: "Are you sure you want to log %@ out?",
- comment: ""
- ), deviceName
- ),
+ attributedMessage: attributedText,
buttons: [
AlertAction(
title: NSLocalizedString(
- "DELETE_ALERT_CANCEL_ACTION",
+ "DELETE_ALERT_CONFIRM_ACTION",
tableName: "DeviceManagement",
- value: "Back",
+ value: "Yes, log out device",
comment: ""
),
- style: .default,
+ style: .destructive,
handler: {
- completion(false)
+ completion(true)
}
),
AlertAction(
title: NSLocalizedString(
- "DELETE_ALERT_CONFIRM_ACTION",
+ "DELETE_ALERT_CANCEL_ACTION",
tableName: "DeviceManagement",
- value: "Yes, log out device",
+ value: "Back",
comment: ""
),
- style: .destructive,
+ style: .default,
handler: {
- completion(true)
+ completion(false)
}
),
]
diff --git a/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift b/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift
index 0e050b872d..56e6f5e4fa 100644
--- a/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift
+++ b/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift
@@ -39,8 +39,8 @@ class MullvadVPNScreenshots: XCTestCase {
app.buttons["AgreeButton"].tap()
// Dismiss changelog screen
- _ = app.buttons["OkButton"].waitForExistence(timeout: 10)
- app.buttons["OkButton"].tap()
+ _ = app.buttons["Got it!"].waitForExistence(timeout: 10)
+ app.buttons["Got it!"].tap()
// Wait for Login screen
let textField = app.textFields["LoginTextField"]