Merge pull request #2619 from stuartbreckenridge/widget-layout-fix
timeline refresh can now be controlled
This commit is contained in:
commit
ae41a84114
|
@ -18,7 +18,7 @@ struct WidgetDataEncoder {
|
||||||
|
|
||||||
private static var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Application")
|
private static var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Application")
|
||||||
|
|
||||||
static func encodeWidgetData() {
|
static func encodeWidgetData(refreshTimeline: Bool = true) {
|
||||||
os_log(.debug, log: log, "Starting encoding widget data.")
|
os_log(.debug, log: log, "Starting encoding widget data.")
|
||||||
do {
|
do {
|
||||||
// Unread Articles
|
// Unread Articles
|
||||||
|
@ -32,6 +32,7 @@ struct WidgetDataEncoder {
|
||||||
feedIcon: article.iconImage()?.image.dataRepresentation(),
|
feedIcon: article.iconImage()?.image.dataRepresentation(),
|
||||||
pubDate: article.datePublished!.description)
|
pubDate: article.datePublished!.description)
|
||||||
unread.append(latestArticle)
|
unread.append(latestArticle)
|
||||||
|
|
||||||
if unread.count == 7 { break }
|
if unread.count == 7 { break }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +83,10 @@ struct WidgetDataEncoder {
|
||||||
}
|
}
|
||||||
if FileManager.default.createFile(atPath: dataURL!.path, contents: encodedData, attributes: nil) {
|
if FileManager.default.createFile(atPath: dataURL!.path, contents: encodedData, attributes: nil) {
|
||||||
os_log(.debug, log: log, "Wrote widget data to container.")
|
os_log(.debug, log: log, "Wrote widget data to container.")
|
||||||
|
if refreshTimeline == true {
|
||||||
WidgetCenter.shared.reloadAllTimelines()
|
WidgetCenter.shared.reloadAllTimelines()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
os_log(.error, "%@", error.localizedDescription)
|
os_log(.error, "%@", error.localizedDescription)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,8 @@ struct SmartFeedSummaryWidgetView: View {
|
||||||
var entry: Provider.Entry
|
var entry: Provider.Entry
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
switch family {
|
|
||||||
case .systemSmall:
|
|
||||||
smallWidget
|
smallWidget
|
||||||
case .systemMedium:
|
.widgetURL(WidgetDeepLink.icon.url)
|
||||||
smallWidget
|
|
||||||
case .systemLarge:
|
|
||||||
smallWidget
|
|
||||||
@unknown default:
|
|
||||||
smallWidget
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct StarredWidgetView : View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if entry.widgetData.starredArticles.count == 0 {
|
if entry.widgetData.starredArticles.count == 0 {
|
||||||
inboxZero
|
inboxZero
|
||||||
|
.widgetURL(WidgetDeepLink.starred.url)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GeometryReader { metrics in
|
GeometryReader { metrics in
|
||||||
|
@ -49,7 +50,7 @@ struct StarredWidgetView : View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}.padding(.leading, 4)
|
}.padding(.leading, 4)
|
||||||
}.padding()
|
}.padding()
|
||||||
}
|
}.widgetURL(WidgetDeepLink.starred.url)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct TodayWidgetView : View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if entry.widgetData.todayArticles.count == 0 {
|
if entry.widgetData.todayArticles.count == 0 {
|
||||||
inboxZero
|
inboxZero
|
||||||
|
.widgetURL(WidgetDeepLink.today.url)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GeometryReader { metrics in
|
GeometryReader { metrics in
|
||||||
|
@ -50,7 +51,7 @@ struct TodayWidgetView : View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}.padding(.leading, 4)
|
}.padding(.leading, 4)
|
||||||
}.padding()
|
}.padding()
|
||||||
}
|
}.widgetURL(WidgetDeepLink.today.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct UnreadWidgetView : View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if entry.widgetData.currentUnreadCount == 0 {
|
if entry.widgetData.currentUnreadCount == 0 {
|
||||||
inboxZero
|
inboxZero
|
||||||
|
.widgetURL(WidgetDeepLink.unread.url)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GeometryReader { metrics in
|
GeometryReader { metrics in
|
||||||
|
@ -49,7 +50,7 @@ struct UnreadWidgetView : View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}.padding(.leading, 4)
|
}.padding(.leading, 4)
|
||||||
}.padding()
|
}.padding()
|
||||||
}
|
}.widgetURL(WidgetDeepLink.unread.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if #available(iOS 14, *) {
|
if #available(iOS 14, *) {
|
||||||
WidgetDataEncoder.encodeWidgetData()
|
WidgetDataEncoder.encodeWidgetData(refreshTimeline: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue