@@ -165,7 +165,6 @@ class ScheduleTableViewController: UITableViewController {
165165 // This is a bit counterintuitive but it works ¯\_(ツ)_/¯
166166 cell. timeline. backColor = frontColor
167167 cell. bubbleEnabled = true
168- print ( " Current element: \( title) " )
169168 } else {
170169
171170 // Only current item gets button.
@@ -220,27 +219,38 @@ class ScheduleTableViewController: UITableViewController {
220219 // MARK: Section headers and view configuration
221220
222221 override func tableView( _ tableView: UITableView , viewForHeaderInSection section: Int ) -> UIView ? {
223- // @TODO:
224- // Implement header design, timeframes in each section in data model,
225- // make Description font bigger, move accessory margin (- instead of + in TimelineTableViewCell),
226- // Remove nasty bubble -- ask Chris about a good indicator to use for "active block".
227- // (maybe make bar bigger?)
228- return tableView. dequeueReusableCell ( withIdentifier: " header " )
229222
223+ print ( " Header for section \( section) " )
224+
225+ // Get our dummy cell from IB
226+ let cell = tableView. dequeueReusableCell ( withIdentifier: " header " ) !
227+
228+ // Make date formatter for just time
229+ let dateFormatter = DateFormatter ( )
230+ dateFormatter. timeStyle = . short
231+ dateFormatter. dateStyle = . none
232+
233+ // Return cell as-is if invlaid data
234+ guard let sectionDate = sampleData [ section] ? . first? . date else {
235+ cell. textLabel!. text = " Unknown Time "
236+ return cell
237+ }
238+
239+ // Otherwise set proper date
240+ cell. textLabel!. text = dateFormatter. string ( from: sectionDate)
241+
242+ return cell
230243
231244 }
232245
233- override func tableView ( _ tableView : UITableView , heightForFooterInSection section : Int ) -> CGFloat {
234- //@TODO
235- return 44
246+ // Defined height for the time header slot (e.g., "9am")
247+ override func tableView ( _ tableView : UITableView , heightForHeaderInSection section : Int ) -> CGFloat {
248+ return 60.0
236249 }
237250
238- override func tableView( _ tableView: UITableView , titleForHeaderInSection section: Int ) -> String ? {
239- switch section {
240- case 0 : return " 9am "
241- case 1 : return " 10am "
242- default : return " Unknown "
243- }
251+ // Remove margin between sections
252+ override func tableView( _ tableView: UITableView , heightForFooterInSection section: Int ) -> CGFloat {
253+ return . leastNormalMagnitude
244254 }
245255
246256}
0 commit comments