@@ -11,9 +11,14 @@ import MullvadSettings
11
11
import Routing
12
12
import UIKit
13
13
14
- class EditCustomListCoordinator : Coordinator , Presentable {
14
+ class EditCustomListCoordinator : Coordinator , Presentable , Presenting {
15
15
let navigationController : UINavigationController
16
16
let customListInteractor : CustomListInteractorProtocol
17
+ let subject : CurrentValueSubject < CustomListViewModel , Never >
18
+
19
+ lazy var alertPresenter : AlertPresenter = {
20
+ AlertPresenter ( context: self )
21
+ } ( )
17
22
18
23
var presentedViewController : UIViewController {
19
24
navigationController
@@ -25,18 +30,18 @@ class EditCustomListCoordinator: Coordinator, Presentable {
25
30
) {
26
31
self . navigationController = navigationController
27
32
self . customListInteractor = customListInteractor
28
- }
29
33
30
- func start( ) {
31
- let subject = CurrentValueSubject < CustomListViewModel , Never > (
34
+ subject = CurrentValueSubject < CustomListViewModel , Never > (
32
35
CustomListViewModel (
33
36
id: UUID ( ) ,
34
37
name: " A list " ,
35
38
locations: [ ] ,
36
39
tableSections: [ . name, . editLocations, . deleteList]
37
40
)
38
41
)
42
+ }
39
43
44
+ func start( ) {
40
45
let controller = CustomListViewController ( interactor: customListInteractor, subject: subject)
41
46
controller. delegate = self
42
47
@@ -57,7 +62,41 @@ extension EditCustomListCoordinator: CustomListViewControllerDelegate {
57
62
}
58
63
59
64
func customListDidDelete( ) {
60
- dismiss ( animated: true )
65
+ let presentation = AlertPresentation (
66
+ id: " api-custom-lists-delete-list-alert " ,
67
+ icon: . alert,
68
+ message: NSLocalizedString (
69
+ " CUSTOM_LISTS_DELETE_PROMPT " ,
70
+ tableName: " APIAccess " ,
71
+ value: " Delete \( subject. value. name) ? " ,
72
+ comment: " "
73
+ ) ,
74
+ buttons: [
75
+ AlertAction (
76
+ title: NSLocalizedString (
77
+ " CUSTOM_LISTS_DELETE_BUTTON " ,
78
+ tableName: " APIAccess " ,
79
+ value: " Delete " ,
80
+ comment: " "
81
+ ) ,
82
+ style: . destructive,
83
+ handler: {
84
+ self . customListInteractor. deleteCustomList ( id: self . subject. value. id)
85
+ }
86
+ ) ,
87
+ AlertAction (
88
+ title: NSLocalizedString (
89
+ " CUSTOM_LISTS_CANCEL_BUTTON " ,
90
+ tableName: " APIAccess " ,
91
+ value: " Cancel " ,
92
+ comment: " "
93
+ ) ,
94
+ style: . default
95
+ )
96
+ ]
97
+ )
98
+
99
+ alertPresenter. showAlert ( presentation: presentation, animated: true )
61
100
}
62
101
63
102
func showLocations( ) {
0 commit comments