mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Add archive actions if there are archived habits (#1345)
This commit is contained in:
committed by
GitHub
parent
4469f86e46
commit
b79f7850ed
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user