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