Main screen: add action sheet

pull/498/head
Alinson S. Xavier 7 years ago
parent f491acdda9
commit 274d3d6858

@ -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
@ -127,10 +130,6 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
self.navigationController?.navigationBar.barTintColor = .white self.navigationController?.navigationBar.barTintColor = .white
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)
}
} }

Loading…
Cancel
Save