Post

Replies

Boosts

Views

Activity

Reply to TimelineView using ExplicitTimelineSchedule ignores last date?
Thank goodness for this thread. You saved my sanity. I had figured out that the first Date in the Sequence was immediately evaluated, but I hadn't noticed that the last Date was never evaluated. I created this extension to solve the problem. And yes, this is all very, very stupid. extension TimelineSchedule { /// The standard library's ExplicitTimelineSchedule is buggy. It will immediately render and provide the first Date in the sequence to the TimelineView enclosure, /// and it will ignore the last Date in the sequence. To make it work as expected, we bracket the given sequence of Dates with Date.distantPast and Date.distantFuture. static func explicitThatActuallyWorks<S>(_ dates: S) -> ExplicitTimelineSchedule<[Date]> where Self == ExplicitTimelineSchedule<S>, S : Sequence, S.Element == Date { .explicit([.distantPast] + Array(dates) + [.distantFuture]) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
3w
Reply to TimelineView using ExplicitTimelineSchedule ignores last date?
Thank goodness for this thread. You saved my sanity. I had figured out that the first Date in the Sequence was immediately evaluated, but I hadn't noticed that the last Date was never evaluated. I created this extension to solve the problem. And yes, this is all very, very stupid. extension TimelineSchedule { /// The standard library's ExplicitTimelineSchedule is buggy. It will immediately render and provide the first Date in the sequence to the TimelineView enclosure, /// and it will ignore the last Date in the sequence. To make it work as expected, we bracket the given sequence of Dates with Date.distantPast and Date.distantFuture. static func explicitThatActuallyWorks<S>(_ dates: S) -> ExplicitTimelineSchedule<[Date]> where Self == ExplicitTimelineSchedule<S>, S : Sequence, S.Element == Date { .explicit([.distantPast] + Array(dates) + [.distantFuture]) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
3w