Widget timer, SwiftUI

Viewed 43

I have the following configuration for my widget:

func getTimeline(in context: Context, completion: @escaping (Timeline<SimpleEntry>) -> Void) {
   var currentDate: Date = Date()
   let entry = SimpleEntry(date: currentDate.addingTimeInterval(60))
   let timeline: Timeline = Timeline(entries: [entry], policy: .atEnd)
   completion(timeline)
}

I would love to have a timer COUNTING UP, given a certain amount of seconds. (Let's say the timer should start from 120 seconds, so it goes: 2:00, 2:01, 2:02 and so on).

The main problem here is that the timer is always COUNTING DOWN.

This is the swiftUI view:

Text(entry.date, style: .timer)

How can I achieve the desired result? Is the reload policy correct?

0 Answers
Related