summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-03-07 08:41:04 +0100
committerBug Magnet <marco.nikic@mullvad.net>2024-03-07 08:41:04 +0100
commit7c6c854bb8790c36c9631769b4cb127c2018ca9d (patch)
tree2092b4861a89da3b1403e4087044927309688a90
parentea865a0ab5ac0a5176520b65614782da1edb179d (diff)
parenteb9edc7c703d4605b943f3f0c64025cdebe044e4 (diff)
downloadmullvadvpn-7c6c854bb8790c36c9631769b4cb127c2018ca9d.tar.xz
mullvadvpn-7c6c854bb8790c36c9631769b4cb127c2018ca9d.zip
Merge branch 'allow-deleting-custom-lists-ios-492'
-rw-r--r--ios/MullvadSettings/CustomListRepository.swift4
-rw-r--r--ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift4
-rw-r--r--ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift42
-rw-r--r--ios/MullvadVPN/Coordinators/CustomLists/EditCustomListCoordinator.swift11
-rw-r--r--ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift2
-rw-r--r--ios/MullvadVPN/View controllers/Alert/AlertViewController.swift4
6 files changed, 42 insertions, 25 deletions
diff --git a/ios/MullvadSettings/CustomListRepository.swift b/ios/MullvadSettings/CustomListRepository.swift
index deb0162d16..5b0935faf8 100644
--- a/ios/MullvadSettings/CustomListRepository.swift
+++ b/ios/MullvadSettings/CustomListRepository.swift
@@ -18,8 +18,8 @@ public enum CustomRelayListError: LocalizedError, Equatable {
switch self {
case .duplicateName:
NSLocalizedString(
- "DUPLICATE_CUSTOM_LIST_ERROR",
- tableName: "CustomListRepository",
+ "DUPLICATE_CUSTOM_LISTS_ERROR",
+ tableName: "CustomLists",
value: "Name is already taken.",
comment: ""
)
diff --git a/ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift b/ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift
index c85147f37c..6692471ba4 100644
--- a/ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift
@@ -42,14 +42,14 @@ class AddCustomListCoordinator: Coordinator, Presentable, Presenting {
controller.delegate = self
controller.navigationItem.title = NSLocalizedString(
- "CUSTOM_LIST_NAVIGATION_EDIT_TITLE",
+ "CUSTOM_LISTS_NAVIGATION_EDIT_TITLE",
tableName: "CustomLists",
value: "New custom list",
comment: ""
)
controller.saveBarButton.title = NSLocalizedString(
- "CUSTOM_LIST_NAVIGATION_CREATE_BUTTON",
+ "CUSTOM_LISTS_NAVIGATION_CREATE_BUTTON",
tableName: "CustomLists",
value: "Create",
comment: ""
diff --git a/ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift b/ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift
index e171bf6624..b0a5da3ae6 100644
--- a/ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift
+++ b/ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift
@@ -158,26 +158,40 @@ class CustomListViewController: UIViewController {
}
private func onDelete() {
- // TODO: Show error dialog.
- delegate?.customListDidDelete()
- }
+ let message = NSMutableAttributedString(
+ markdownString: NSLocalizedString(
+ "CUSTOM_LISTS_DELETE_PROMPT",
+ tableName: "CustomLists",
+ value: "Do you want to delete the list **\(subject.value.name)**?",
+ comment: ""
+ ),
+ options: MarkdownStylingOptions(font: .preferredFont(forTextStyle: .body))
+ )
- private func showSaveErrorAlert() {
let presentation = AlertPresentation(
- id: "api-custom-lists-save-list-alert",
+ id: "api-custom-lists-delete-list-alert",
icon: .alert,
- message: NSLocalizedString(
- "CUSTOM_LISTS_SAVE_ERROR_PROMPT",
- tableName: "APIAccess",
- value: "List name is already taken.",
- comment: ""
- ),
+ attributedMessage: message,
buttons: [
AlertAction(
title: NSLocalizedString(
- "CUSTOM_LISTS_OK_BUTTON",
- tableName: "APIAccess",
- value: "Got it!",
+ "CUSTOM_LISTS_DELETE_BUTTON",
+ tableName: "CustomLists",
+ value: "Delete list",
+ comment: ""
+ ),
+ style: .destructive,
+ handler: {
+ self.interactor.deleteCustomList(id: self.subject.value.id)
+ self.dismiss(animated: true)
+ self.delegate?.customListDidDelete()
+ }
+ ),
+ AlertAction(
+ title: NSLocalizedString(
+ "CUSTOM_LISTS_CANCEL_BUTTON",
+ tableName: "CustomLists",
+ value: "Cancel",
comment: ""
),
style: .default
diff --git a/ios/MullvadVPN/Coordinators/CustomLists/EditCustomListCoordinator.swift b/ios/MullvadVPN/Coordinators/CustomLists/EditCustomListCoordinator.swift
index 2da41754b8..ad045714de 100644
--- a/ios/MullvadVPN/Coordinators/CustomLists/EditCustomListCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/CustomLists/EditCustomListCoordinator.swift
@@ -14,6 +14,7 @@ import UIKit
class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
let navigationController: UINavigationController
let customListInteractor: CustomListInteractorProtocol
+ let customList: CustomList
var presentedViewController: UIViewController {
navigationController
@@ -23,18 +24,20 @@ class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
init(
navigationController: UINavigationController,
- customListInteractor: CustomListInteractorProtocol
+ customListInteractor: CustomListInteractorProtocol,
+ customList: CustomList
) {
self.navigationController = navigationController
self.customListInteractor = customListInteractor
+ self.customList = customList
}
func start() {
let subject = CurrentValueSubject<CustomListViewModel, Never>(
CustomListViewModel(
- id: UUID(),
- name: "A list",
- locations: [],
+ id: customList.id,
+ name: customList.name,
+ locations: customList.locations,
tableSections: [.name, .editLocations, .deleteList]
)
)
diff --git a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift
index e7606d3c81..55a907677a 100644
--- a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift
+++ b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift
@@ -333,7 +333,7 @@ class EditAccessMethodViewController: UITableViewController {
id: "api-access-methods-delete-method-alert",
icon: .alert,
message: NSLocalizedString(
- "METHOD_SETTINGS_SAVE_PROMPT",
+ "METHOD_SETTINGS_DELETE_PROMPT",
tableName: "APIAccess",
value: "Delete \(methodName)?",
comment: ""
diff --git a/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift b/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift
index 2f1796b063..a116e51839 100644
--- a/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift
+++ b/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift
@@ -231,8 +231,8 @@ class AlertViewController: UIViewController {
style.lineBreakMode = .byWordWrapping
label.attributedText = NSAttributedString(
- markdownString: message,
- options: MarkdownStylingOptions(font: font, paragraphStyle: style)
+ string: message,
+ attributes: [.paragraphStyle: style]
)
label.font = font
label.textColor = .white.withAlphaComponent(0.8)