mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Main screen: add action sheet
This commit is contained in:
@@ -113,9 +113,12 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
|
|||||||
self.title = "Habits"
|
self.title = "Habits"
|
||||||
|
|
||||||
self.navigationItem.rightBarButtonItems = [
|
self.navigationItem.rightBarButtonItems = [
|
||||||
|
UIBarButtonItem(barButtonSystemItem: .bookmarks, /* TODO: Replace by appropriate icon */
|
||||||
|
target: self,
|
||||||
|
action: #selector(self.onMoreActionsClicked)),
|
||||||
UIBarButtonItem(barButtonSystemItem: .add,
|
UIBarButtonItem(barButtonSystemItem: .add,
|
||||||
target: self,
|
target: self,
|
||||||
action: #selector(self.onCreateHabitClicked))
|
action: #selector(self.onCreateHabitClicked)),
|
||||||
]
|
]
|
||||||
tableView.register(MainScreenCell.self, forCellReuseIdentifier: "cell")
|
tableView.register(MainScreenCell.self, forCellReuseIdentifier: "cell")
|
||||||
tableView.backgroundColor = theme.headerBackgroundColor.uicolor
|
tableView.backgroundColor = theme.headerBackgroundColor.uicolor
|
||||||
@@ -128,10 +131,6 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
|
|||||||
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
|
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func onCreateHabitClicked() {
|
|
||||||
self.navigationController?.pushViewController(EditHabitController(), animated: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
return data?.habits.count ?? 0
|
return data?.habits.count ?? 0
|
||||||
}
|
}
|
||||||
@@ -169,4 +168,37 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
|
|||||||
color: color),
|
color: color),
|
||||||
animated: true)
|
animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func onCreateHabitClicked() {
|
||||||
|
self.navigationController?.pushViewController(EditHabitController(), animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func onMoreActionsClicked() {
|
||||||
|
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||||
|
alert.addAction(UIAlertAction(title: "Show archived", style: .default) {
|
||||||
|
(action: UIAlertAction) -> Void in
|
||||||
|
// TODO
|
||||||
|
})
|
||||||
|
alert.addAction(UIAlertAction(title: "Hide completed", style: .default) {
|
||||||
|
(action: UIAlertAction) -> Void in
|
||||||
|
// TODO
|
||||||
|
})
|
||||||
|
alert.addAction(UIAlertAction(title: "Night mode", style: .default) {
|
||||||
|
(action: UIAlertAction) -> Void in
|
||||||
|
// TODO
|
||||||
|
})
|
||||||
|
alert.addAction(UIAlertAction(title: "Help & FAQ", style: .default) {
|
||||||
|
(action: UIAlertAction) -> Void in
|
||||||
|
// TODO
|
||||||
|
})
|
||||||
|
alert.addAction(UIAlertAction(title: "About", style: .default) {
|
||||||
|
(action: UIAlertAction) -> Void in
|
||||||
|
// TODO
|
||||||
|
})
|
||||||
|
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) {
|
||||||
|
(action: UIAlertAction) -> Void in
|
||||||
|
// Do nothing
|
||||||
|
})
|
||||||
|
present(alert, animated: true, completion: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user