Skip to content

Commit deff08d

Browse files
committed
Current event bubble now works and updates
1 parent 0e7427f commit deff08d

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

BrickHack-Mobile/Controllers/ScheduleTableViewController.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,14 @@ class ScheduleTableViewController: UITableViewController {
129129
cell.bubbleEnabled = true
130130
} else {
131131
// Only current item gets button.
132-
// @TODO: Check with design on this one.
133132
cell.bubbleEnabled = false
133+
134+
// Reset label color as this previously-current item is no longer current
135+
if #available(iOS 13.0, *) {
136+
cell.titleLabel.textColor = UIColor.label
137+
} else {
138+
cell.titleLabel.textColor = UIColor.black
139+
}
134140
}
135141

136142
// Text content
@@ -272,13 +278,12 @@ class ScheduleTableViewController: UITableViewController {
272278
}
273279

274280
// Start at -1 as we look at the next index to see if the current is over yet
281+
// (Updating each section as "current" as we go)
275282
print("sectionCount: \(ScheduleParser.sectionCount)")
276283
for sectionIndex in 0..<ScheduleParser.sectionCount {
277284

278285
// Grab the next section's date
279-
print(self.timelineEvents)
280286
let events = self.timelineEvents.filter({ $0.event.section == sectionIndex })
281-
print(events)
282287
let sectionDate = events.first!.event.time
283288

284289
// If greater, STOP. We are at the current section.
@@ -291,14 +296,15 @@ class ScheduleTableViewController: UITableViewController {
291296

292297
print("updated \(timelineEvent)")
293298
timelineEvent.allColor = self.backColor
294-
295-
if timelineEvent.timelinePoint != nil {
296-
timelineEvent.timelinePoint = TimelinePoint(color: self.backColor, filled: true)
297-
}
298299
}
299300

300301
// @TODO: Set the current event with a TimelinePoint
301-
302+
let mostCurrentEvent = self.timelineEvents.filter({ $0.event.section == sectionIndex }).last
303+
mostCurrentEvent?.timelinePoint = TimelinePoint(color: self.backColor, filled: true)
304+
305+
// Remove it from the previous section
306+
let lastCurrentEvent = self.timelineEvents.filter({ $0.event.section == sectionIndex - 1}).last
307+
lastCurrentEvent?.timelinePoint = nil
302308
}
303309

304310
DispatchQueue.main.async {

0 commit comments

Comments
 (0)