-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b99af3c
commit 9bce0f7
Showing
12 changed files
with
201 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import UIKit | ||
|
||
// MARK: Alert+Vault | ||
|
||
extension Alert { | ||
/// An alert confirming deletion of an item | ||
/// | ||
/// - Parameters: | ||
/// - action: The action to perform if the user confirms | ||
/// - Returns: An alert confirming item deletion | ||
/// | ||
static func confirmDeleteItem(action: @escaping () async -> Void) -> Alert { | ||
Alert( | ||
title: Localizations.doYouReallyWantToDelete, | ||
message: nil, | ||
alertActions: [ | ||
AlertAction(title: Localizations.yes, style: .default) { _, _ in await action() }, | ||
AlertAction(title: Localizations.no, style: .cancel), | ||
] | ||
) | ||
} | ||
|
||
/// An alert presenting the user with more options for an item. | ||
/// | ||
/// - Parameters: | ||
/// - authenticatorItemView: The item to show | ||
/// - id: The id of the item | ||
/// - action: The action to perform after selecting an option. | ||
/// | ||
/// - Returns: An alert presenting the user with options to select an attachment type. | ||
@MainActor | ||
static func moreOptions( | ||
authenticatorItemView: AuthenticatorItemView, | ||
id: String, | ||
action: @escaping (_ action: MoreOptionsAction) async -> Void | ||
) -> Alert { | ||
var alertActions = [AlertAction]() | ||
|
||
if let totp = authenticatorItemView.totpKey, | ||
let totpKey = TOTPKeyModel(authenticatorKey: totp) { | ||
alertActions.append( | ||
AlertAction(title: Localizations.copy, style: .default) { _, _ in | ||
await action(.copyTotp(totpKey: totpKey)) | ||
}) | ||
} | ||
|
||
alertActions.append(AlertAction(title: Localizations.edit, style: .default) { _, _ in | ||
await action(.edit(authenticatorItemView: authenticatorItemView)) | ||
}) | ||
|
||
alertActions.append(AlertAction(title: Localizations.delete, style: .destructive) { _, _ in | ||
await action(.delete(id: id)) | ||
}) | ||
|
||
return Alert( | ||
title: authenticatorItemView.name, | ||
message: nil, | ||
preferredStyle: .actionSheet, | ||
alertActions: alertActions + [AlertAction(title: Localizations.cancel, style: .cancel)] | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
AuthenticatorShared/UI/Vault/Views/ItemListItemRow/ItemListItemRowEffect.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// MARK: - ItemListItemRowEffect | ||
|
||
/// Effects that can be performed from an `ItemListItemRowView` | ||
enum ItemListItemRowEffect: Equatable { | ||
/// The more button was pressed | ||
case morePressed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters