mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-18 12:31:01 +01:00
TimelineProvider.swift
Previews now use live data if it is available.
This commit is contained in:
parent
186be331d6
commit
65073d7346
@ -12,14 +12,23 @@ import SwiftUI
|
|||||||
struct Provider: TimelineProvider {
|
struct Provider: TimelineProvider {
|
||||||
|
|
||||||
func placeholder(in context: Context) -> WidgetTimelineEntry {
|
func placeholder(in context: Context) -> WidgetTimelineEntry {
|
||||||
WidgetTimelineEntry(date: Date(), widgetData: WidgetDataDecoder.sampleData())
|
do {
|
||||||
|
let data = try WidgetDataDecoder.decodeWidgetData()
|
||||||
|
return WidgetTimelineEntry(date: Date(), widgetData: data)
|
||||||
|
} catch {
|
||||||
|
return WidgetTimelineEntry(date: Date(), widgetData: WidgetDataDecoder.sampleData())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSnapshot(in context: Context, completion: @escaping (WidgetTimelineEntry) -> Void) {
|
func getSnapshot(in context: Context, completion: @escaping (WidgetTimelineEntry) -> Void) {
|
||||||
if context.isPreview {
|
if context.isPreview {
|
||||||
let entry = WidgetTimelineEntry(date: Date(),
|
do {
|
||||||
widgetData: WidgetDataDecoder.sampleData())
|
let data = try WidgetDataDecoder.decodeWidgetData()
|
||||||
completion(entry)
|
completion(WidgetTimelineEntry(date: Date(), widgetData: data))
|
||||||
|
} catch {
|
||||||
|
completion(WidgetTimelineEntry(date: Date(),
|
||||||
|
widgetData: WidgetDataDecoder.sampleData()))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
let widgetData = try WidgetDataDecoder.decodeWidgetData()
|
let widgetData = try WidgetDataDecoder.decodeWidgetData()
|
||||||
@ -27,7 +36,7 @@ struct Provider: TimelineProvider {
|
|||||||
completion(entry)
|
completion(entry)
|
||||||
} catch {
|
} catch {
|
||||||
let entry = WidgetTimelineEntry(date: Date(),
|
let entry = WidgetTimelineEntry(date: Date(),
|
||||||
widgetData: WidgetData(currentUnreadCount: 41, currentTodayCount: 40, currentStarredCount: 12, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date()) )
|
widgetData: WidgetDataDecoder.sampleData())
|
||||||
completion(entry)
|
completion(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user