Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow deleting custom lists #5820

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ios/MullvadSettings/CustomListRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import UIKit
class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
let navigationController: UINavigationController
let customListInteractor: CustomListInteractorProtocol
let customList: CustomList

var presentedViewController: UIViewController {
navigationController
Expand All @@ -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]
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading