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")!
|
return UIImage(systemName: "doc.on.doc")!
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
static var deactivateImage: UIImage = {
|
||||||
|
UIImage(systemName: "minus.circle")!
|
||||||
|
}()
|
||||||
|
|
||||||
static var editImage: UIImage = {
|
static var editImage: UIImage = {
|
||||||
UIImage(systemName: "square.and.pencil")!
|
UIImage(systemName: "square.and.pencil")!
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -542,15 +542,15 @@ extension MasterFeedViewController: UIContextMenuInteractionDelegate {
|
||||||
|
|
||||||
guard let sectionIndex = interaction.view?.tag,
|
guard let sectionIndex = interaction.view?.tag,
|
||||||
let sectionNode = coordinator.rootNode.childAtIndex(sectionIndex),
|
let sectionNode = coordinator.rootNode.childAtIndex(sectionIndex),
|
||||||
let account = sectionNode.representedObject as? Account,
|
let account = sectionNode.representedObject as? Account
|
||||||
let headerView = interaction.view as? MasterFeedTableViewSectionHeader
|
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in
|
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in
|
||||||
let accountInfoAction = self.getAccountInfoAction(account: account)
|
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
|
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? {
|
func getInfoAlertAction(indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? {
|
||||||
guard let node = dataSource.itemIdentifier(for: indexPath), let feed = node.representedObject as? Feed else {
|
guard let node = dataSource.itemIdentifier(for: indexPath), let feed = node.representedObject as? Feed else {
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue