Rename to DetailScreenController; pass habit as argument

This commit is contained in:
2019-03-31 19:43:20 -05:00
parent 979affef22
commit 48c3ff584a
3 changed files with 14 additions and 12 deletions

View File

@@ -19,9 +19,10 @@
import UIKit
class ShowHabitController : UITableViewController {
class DetailScreenController : UITableViewController {
let theme: Theme
let habit: Habit
let color: Color
var cells = [UITableViewCell]()
@@ -29,14 +30,15 @@ class ShowHabitController : UITableViewController {
fatalError()
}
init(theme: Theme, color: Color) {
self.theme = theme
self.color = color
init(habit: Habit, backend: Backend) {
self.theme = backend.theme
self.habit = habit
self.color = theme.color(paletteIndex: self.habit.color.index)
super.init(style: .grouped)
}
override func viewDidLoad() {
self.title = "Exercise"
self.title = habit.name
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit,
target: self,
action: #selector(self.onEditHabitClicked))

View File

@@ -164,9 +164,9 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let color = theme.color(paletteIndex: data!.habits[indexPath.row].color.index)
self.navigationController?.pushViewController(ShowHabitController(theme: theme,
color: color),
let habit = data!.habits[indexPath.row]
let color = theme.color(paletteIndex: habit.color.index)
self.navigationController?.pushViewController(DetailScreenController(habit: habit, backend: backend),
animated: true)
}