Skip to content

Commit 32e26a3

Browse files
committed
Added proper time seciton headers
1 parent 3ec4b87 commit 32e26a3

2 files changed

Lines changed: 28 additions & 18 deletions

File tree

BrickHack-Mobile/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<rect key="frame" x="0.0" y="0.0" width="375" height="598"/>
2222
<subviews>
2323
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="brickHack6Logo" translatesAutoresizingMaskIntoConstraints="NO" id="1am-Hz-qrF">
24-
<rect key="frame" x="36" y="229.33333333333337" width="148" height="139.66666666666663"/>
24+
<rect key="frame" x="36" y="159.66666666666663" width="296" height="279"/>
2525
</imageView>
2626
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="loginShapes" translatesAutoresizingMaskIntoConstraints="NO" id="QYc-0X-ayY">
27-
<rect key="frame" x="164" y="124.66666666666669" width="211" height="349"/>
27+
<rect key="frame" x="-47" y="-50" width="422" height="698"/>
2828
</imageView>
2929
</subviews>
3030
<color key="backgroundColor" name="primaryColor"/>

BrickHack-Mobile/Controllers/ScheduleTableViewController.swift

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)