Added deactivate context menu for accounts.
This commit is contained in:
parent
f0d1cf6239
commit
9376fcd64a
|
@ -77,6 +77,10 @@ struct AppAssets {
|
|||
return UIImage(systemName: "doc.on.doc")!
|
||||
}()
|
||||
|
||||
static var deactivateImage: UIImage = {
|
||||
UIImage(systemName: "minus.circle")!
|
||||
}()
|
||||
|
||||
static var editImage: UIImage = {
|
||||
UIImage(systemName: "square.and.pencil")!
|
||||
}()
|
||||
|
|
|
@ -542,15 +542,15 @@ extension MasterFeedViewController: UIContextMenuInteractionDelegate {
|
|||
|
||||
guard let sectionIndex = interaction.view?.tag,
|
||||
let sectionNode = coordinator.rootNode.childAtIndex(sectionIndex),
|
||||
let account = sectionNode.representedObject as? Account,
|
||||
let headerView = interaction.view as? MasterFeedTableViewSectionHeader
|
||||
let account = sectionNode.representedObject as? Account
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in
|
||||
let accountInfoAction = self.getAccountInfoAction(account: account)
|
||||
return UIMenu(title: "", children: [accountInfoAction])
|
||||
let deactivateAction = self.deactivateAccountAction(account: account)
|
||||
return UIMenu(title: "", children: [accountInfoAction, deactivateAction])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -878,6 +878,14 @@ private extension MasterFeedViewController {
|
|||
return action
|
||||
}
|
||||
|
||||
func deactivateAccountAction(account: Account) -> UIAction {
|
||||
let title = NSLocalizedString("Deactivate", comment: "Deactivate")
|
||||
let action = UIAction(title: title, image: AppAssets.deactivateImage) { action in
|
||||
account.isActive = false
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
func getInfoAlertAction(indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? {
|
||||
guard let node = dataSource.itemIdentifier(for: indexPath), let feed = node.representedObject as? Feed else {
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue