Post

Replies

Boosts

Views

Activity

Reply to My widgets appear with a Placeholder view in the Widget Gallery
When I actually add the widget to the homescreen, the widget displays properly. From the documentation, snapshot appears to be what is used for the Widget Gallery view: WidgetKit calls snapshot(for:with:completion:) when the widget appears in transient situations. If context.isPreview is true, the widget appears in the widget gallery. Regardless, I am passing entries in the timeline - below is my code. I'm only providing one timeline entry since I want to refresh the data every 15 minute increments. (This is an agenda widget, so I want to load any new calendar events, etc). I set the entry date for the 15 minute mark so it refreshes roughly every 15 minutes. I also tried passing two entries: one for Date(), and one with the Refresh date below, and I still see the same issue. var entries: [SimpleEntry] = [] let refreshDate = DateHelper.shared.nextWidgetRefreshDate(frequency: 15) let agendaViewModel = AgendaViewModel() agendaViewModel.getData(hidePastEvents: true) { let agendaItemsByDate = Array(agendaViewModel.agendaItemsByDate.prefix(2)) let entry = SimpleEntry(date: refreshDate, agendaItemsByDate: agendaItemsByDate) entries.append(entry) let timeline = Timeline(entries: entries, policy: .atEnd) completion(timeline) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’20