Add archive actions if there are archived habits (#1345)

This commit is contained in:
Kürşad Bumin Giray Saka
2022-04-12 04:50:44 +03:00
committed by GitHub
parent 4469f86e46
commit b79f7850ed

View File

@@ -190,6 +190,7 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
@objc func onMoreActionsClicked() {
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
if isThereAnyArchivedHabit() {
if preferences.showArchived {
alert.addAction(UIAlertAction(title: strings.hide_archived, style: .default) {
(action: UIAlertAction) -> Void in
@@ -203,6 +204,7 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
self.dataSource.requestData()
})
}
}
if preferences.showCompleted {
alert.addAction(UIAlertAction(title: strings.hide_completed, style: .default) {
@@ -262,4 +264,8 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
let sections = NSIndexSet(indexesIn: NSMakeRange(0, self.tableView.numberOfSections))
tableView.reloadSections(sections as IndexSet, with: .automatic)
}
func isThereAnyArchivedHabit() -> Bool {
return data!.habits.filter({ $0.isArchived }).count > 0
}
}