Skip to content

Commit 5d44827

Browse files
author
Jon Petersson
committed
Allow deleting custom lists
1 parent d66d2e2 commit 5d44827

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

ios/MullvadSettings/CustomListRepository.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public enum CustomRelayListError: LocalizedError, Equatable {
1818
switch self {
1919
case .duplicateName:
2020
NSLocalizedString(
21-
"DUPLICATE_CUSTOM_LIST_ERROR",
21+
"DUPLICATE_CUSTOM_LISTS_ERROR",
2222
tableName: "CustomListRepository",
2323
value: "Name is already taken.",
2424
comment: ""

ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class AddCustomListCoordinator: Coordinator, Presentable, Presenting {
4242
controller.delegate = self
4343

4444
controller.navigationItem.title = NSLocalizedString(
45-
"CUSTOM_LIST_NAVIGATION_EDIT_TITLE",
45+
"CUSTOM_LISTS_NAVIGATION_EDIT_TITLE",
4646
tableName: "CustomLists",
4747
value: "New custom list",
4848
comment: ""
4949
)
5050

5151
controller.saveBarButton.title = NSLocalizedString(
52-
"CUSTOM_LIST_NAVIGATION_CREATE_BUTTON",
52+
"CUSTOM_LISTS_NAVIGATION_CREATE_BUTTON",
5353
tableName: "CustomLists",
5454
value: "Create",
5555
comment: ""

ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift

+41-12
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ class CustomListViewController: UIViewController {
8989
}
9090

9191
private func configureNavigationItem() {
92-
<<<<<<< HEAD
93-
=======
94-
navigationItem.title = NSLocalizedString(
95-
"CUSTOM_LIST_NAVIGATION_EDIT_TITLE",
96-
tableName: "CustomLists",
97-
value: subject.value.name,
98-
comment: ""
99-
)
100-
101-
>>>>>>> ba5bb4354 (Add UI for creating and editing a custom list)
10292
navigationItem.leftBarButtonItem = UIBarButtonItem(
10393
systemItem: .cancel,
10494
primaryAction: UIAction(handler: { _ in
@@ -157,8 +147,7 @@ class CustomListViewController: UIViewController {
157147
}
158148

159149
private func onDelete() {
160-
// TODO: Show error dialog.
161-
delegate?.customListDidDelete()
150+
showDeleteAlert()
162151
}
163152

164153
private func showSaveErrorAlert() {
@@ -186,4 +175,44 @@ class CustomListViewController: UIViewController {
186175

187176
alertPresenter.showAlert(presentation: presentation, animated: true)
188177
}
178+
179+
private func showDeleteAlert() {
180+
let presentation = AlertPresentation(
181+
id: "api-custom-lists-delete-list-alert",
182+
icon: .alert,
183+
message: NSLocalizedString(
184+
"CUSTOM_LISTS_DELETE_PROMPT",
185+
tableName: "APIAccess",
186+
value: "Delete \(subject.value.name)?",
187+
comment: ""
188+
),
189+
buttons: [
190+
AlertAction(
191+
title: NSLocalizedString(
192+
"CUSTOM_LISTS_DELETE_BUTTON",
193+
tableName: "APIAccess",
194+
value: "Delete",
195+
comment: ""
196+
),
197+
style: .destructive,
198+
handler: {
199+
self.interactor.deleteCustomList(id: self.subject.value.id)
200+
self.dismiss(animated: true)
201+
self.delegate?.customListDidDelete()
202+
}
203+
),
204+
AlertAction(
205+
title: NSLocalizedString(
206+
"CUSTOM_LISTS_CANCEL_BUTTON",
207+
tableName: "APIAccess",
208+
value: "Cancel",
209+
comment: ""
210+
),
211+
style: .default
212+
),
213+
]
214+
)
215+
216+
alertPresenter.showAlert(presentation: presentation, animated: true)
217+
}
189218
}

ios/MullvadVPN/Coordinators/SelectLocationCoordinator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SelectLocationCoordinator: Coordinator, Presentable, Presenting, RelayCach
7070
guard let self else { return }
7171

7272
// let coordinator = makeRelayFilterCoordinator(forModalPresentation: true)
73-
let coordinator = AddCustomListCoordinator(
73+
let coordinator = EditCustomListCoordinator(
7474
navigationController: CustomNavigationController(),
7575
customListInteractor: CustomListInteractor(repository: CustomListRepository())
7676
)

ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class EditAccessMethodViewController: UITableViewController {
333333
id: "api-access-methods-delete-method-alert",
334334
icon: .alert,
335335
message: NSLocalizedString(
336-
"METHOD_SETTINGS_SAVE_PROMPT",
336+
"METHOD_SETTINGS_DELETE_PROMPT",
337337
tableName: "APIAccess",
338338
value: "Delete \(methodName)?",
339339
comment: ""

0 commit comments

Comments
 (0)