Combining Day Entry Views for a Week Overview

The day entry view needs the maximum duration to provide the correct scaling to its rectangle. Before we can show the day entry views for the last seven days, though, we need to calculate the maximum duration of these entries. Open LocationProvider and add the following property:

 var​ max: ​TimeInterval​ = 1

To calculate the maximum, replace the dayEntries property declaration with the following code:

 @Published​ ​var​ dayEntries: [​DayEntry​] = [] {
 didSet​ {
  max = dayEntries.​reduce​(1.0, { result, nextDayEntry ​in
 Swift​.​max​(result, nextDayEntry.duration)

Get Build Location-Based Projects for iOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.