mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Rename to DetailScreenController; pass habit as argument
This commit is contained in:
@@ -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))
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user