mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-27 01:52:30 +01:00
Merge pull request #2249 from stuartbreckenridge/feature/widget
Widget Work in Progress
This commit is contained in:
commit
3eda1de825
@ -17,6 +17,7 @@ struct SceneNavigationView: View {
|
||||
|
||||
#if os(iOS)
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
#endif
|
||||
|
||||
var body: some View {
|
||||
@ -64,6 +65,13 @@ struct SceneNavigationView: View {
|
||||
.onChange(of: sheetToShow) { value in
|
||||
value != .none ? (showSheet = true) : (showSheet = false)
|
||||
}
|
||||
.onChange(of: scenePhase) { newPhase in
|
||||
if newPhase == .background {
|
||||
#if os(iOS)
|
||||
WidgetDataEncoder.encodeWidgetData()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
.toolbar {
|
||||
|
||||
#if os(macOS)
|
||||
|
@ -12,6 +12,7 @@ import RSWeb
|
||||
import Account
|
||||
import BackgroundTasks
|
||||
import os.log
|
||||
import WidgetKit
|
||||
|
||||
var appDelegate: AppDelegate!
|
||||
|
||||
@ -115,6 +116,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
syncTimer!.update()
|
||||
#endif
|
||||
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
@ -133,6 +135,45 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
shuttingDown = true
|
||||
}
|
||||
|
||||
func refreshWidgetData() {
|
||||
|
||||
do {
|
||||
let articles = try SmartFeedsController.shared.unreadFeed.fetchArticles().sorted(by: { $0.datePublished! > $1.datePublished! })
|
||||
var latest = [LatestArticle]()
|
||||
for article in articles {
|
||||
let latestArticle = LatestArticle(feedTitle: article.sortableWebFeedID,
|
||||
articleTitle: article.title,
|
||||
articleSummary: article.summary,
|
||||
feedIcon: article.iconImage()?.image.dataRepresentation(),
|
||||
pubDate: article.datePublished!.description)
|
||||
latest.append(latestArticle)
|
||||
if latest.count == 5 { break }
|
||||
}
|
||||
|
||||
print(latest.map({ $0.pubDate }))
|
||||
|
||||
let latestData = WidgetData(currentUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount,
|
||||
currentTodayCount: SmartFeedsController.shared.todayFeed.unreadCount,
|
||||
latestArticles: latest,
|
||||
lastUpdateTime: Date())
|
||||
|
||||
print(latestData)
|
||||
|
||||
let encodedData = try JSONEncoder().encode(latestData)
|
||||
let appGroup = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as! String
|
||||
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup)
|
||||
let dataURL = containerURL?.appendingPathComponent("widget-data.json")
|
||||
if FileManager.default.fileExists(atPath: dataURL!.path) {
|
||||
try FileManager.default.removeItem(at: dataURL!)
|
||||
}
|
||||
try encodedData.write(to: dataURL!)
|
||||
print(dataURL!.path)
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
} catch {
|
||||
os_log(.error, log: self.log, "%@", error.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Notifications
|
||||
|
||||
@objc func unreadCountDidChange(_ note: Notification) {
|
||||
@ -373,6 +414,7 @@ private extension AppDelegate {
|
||||
}
|
||||
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.log) { [unowned self] in
|
||||
if !AccountManager.shared.isSuspended {
|
||||
WidgetDataEncoder.encodeWidgetData()
|
||||
self.suspendApplication()
|
||||
os_log("Account refresh operation completed.", log: self.log, type: .info)
|
||||
task.setTaskCompleted(success: true)
|
||||
|
28
Multiplatform/iOS/Widget Data/WidgetData.swift
Normal file
28
Multiplatform/iOS/Widget Data/WidgetData.swift
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// WidgetData.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Stuart Breckenridge on 10/7/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct WidgetData: Codable {
|
||||
|
||||
let currentUnreadCount: Int
|
||||
let currentTodayCount: Int
|
||||
let latestArticles: [LatestArticle]
|
||||
let lastUpdateTime: Date
|
||||
|
||||
}
|
||||
|
||||
struct LatestArticle: Codable {
|
||||
|
||||
let feedTitle: String
|
||||
let articleTitle: String?
|
||||
let articleSummary: String?
|
||||
let feedIcon: Data? // Base64 encoded image data
|
||||
let pubDate: String
|
||||
|
||||
}
|
36
Multiplatform/iOS/Widget Data/WidgetDataDecoder.swift
Normal file
36
Multiplatform/iOS/Widget Data/WidgetDataDecoder.swift
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// WidgetDataDecoder.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Stuart Breckenridge on 11/7/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct WidgetDataDecoder {
|
||||
|
||||
static func decodeWidgetData() throws -> WidgetData {
|
||||
let appGroup = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as! String
|
||||
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup)
|
||||
let dataURL = containerURL?.appendingPathComponent("widget-data.json")
|
||||
if FileManager.default.fileExists(atPath: dataURL!.path) {
|
||||
let decodedWidgetData = try JSONDecoder().decode(WidgetData.self, from: Data(contentsOf: dataURL!))
|
||||
return decodedWidgetData
|
||||
} else {
|
||||
return WidgetData(currentUnreadCount: 0, currentTodayCount: 0, latestArticles: [], lastUpdateTime: Date())
|
||||
}
|
||||
}
|
||||
|
||||
static func sampleData() -> WidgetData {
|
||||
let pathToSample = Bundle.main.url(forResource: "widget-data-sample", withExtension: "json")
|
||||
do {
|
||||
let data = try Data(contentsOf: pathToSample!)
|
||||
let decoded = try JSONDecoder().decode(WidgetData.self, from: data)
|
||||
return decoded
|
||||
} catch {
|
||||
return WidgetData(currentUnreadCount: 12, currentTodayCount: 12, latestArticles: [], lastUpdateTime: Date())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
59
Multiplatform/iOS/Widget Data/WidgetDataEncoder.swift
Normal file
59
Multiplatform/iOS/Widget Data/WidgetDataEncoder.swift
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// WidgetDataEncoder.swift
|
||||
// Multiplatform iOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 11/7/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import WidgetKit
|
||||
import os.log
|
||||
import UIKit
|
||||
|
||||
struct WidgetDataEncoder {
|
||||
|
||||
static let taskIdentifier = "com.ranchero.NetNewsWire.WidgetEncode"
|
||||
|
||||
static func encodeWidgetData() {
|
||||
os_log(.info, "Starting widget data encoding")
|
||||
let task = UIApplication.shared.beginBackgroundTask(withName: taskIdentifier, expirationHandler: nil)
|
||||
do {
|
||||
let articles = try SmartFeedsController.shared.unreadFeed.fetchArticles().sorted(by: { $0.datePublished! > $1.datePublished! })
|
||||
var latest = [LatestArticle]()
|
||||
for article in articles {
|
||||
let latestArticle = LatestArticle(feedTitle: article.sortableName,
|
||||
articleTitle: article.title,
|
||||
articleSummary: article.summary,
|
||||
feedIcon: article.iconImage()?.image.dataRepresentation(),
|
||||
pubDate: article.datePublished!.description)
|
||||
latest.append(latestArticle)
|
||||
if latest.count == 5 { break }
|
||||
}
|
||||
|
||||
let latestData = WidgetData(currentUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount,
|
||||
currentTodayCount: SmartFeedsController.shared.todayFeed.unreadCount,
|
||||
latestArticles: latest,
|
||||
lastUpdateTime: Date())
|
||||
|
||||
let encodedData = try JSONEncoder().encode(latestData)
|
||||
let appGroup = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as! String
|
||||
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup)
|
||||
let dataURL = containerURL?.appendingPathComponent("widget-data.json")
|
||||
if FileManager.default.fileExists(atPath: dataURL!.path) {
|
||||
try FileManager.default.removeItem(at: dataURL!)
|
||||
}
|
||||
try encodedData.write(to: dataURL!)
|
||||
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
os_log(.info, "Finished encoding widget data")
|
||||
print(UIApplication.shared.backgroundTimeRemaining)
|
||||
UIApplication.shared.endBackgroundTask(task)
|
||||
} catch {
|
||||
os_log(.error, "%@", error.localizedDescription)
|
||||
UIApplication.shared.endBackgroundTask(task)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0.933",
|
||||
"green" : "0.416",
|
||||
"red" : "0.031"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0.957",
|
||||
"green" : "0.620",
|
||||
"red" : "0.369"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
6
Multiplatform/iOS/Widget/Assets.xcassets/Contents.json
Normal file
6
Multiplatform/iOS/Widget/Assets.xcassets/Contents.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "display-p3",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0.000",
|
||||
"green" : "0.000",
|
||||
"red" : "0.000"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"platform" : "ios",
|
||||
"reference" : "systemGray6Color"
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
35
Multiplatform/iOS/Widget/Info.plist
Normal file
35
Multiplatform/iOS/Widget/Info.plist
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>OrganizationIdentifier</key>
|
||||
<string>$(ORGANIZATION_IDENTIFIER)</string>
|
||||
<key>AppGroup</key>
|
||||
<string>group.$(ORGANIZATION_IDENTIFIER).NetNewsWire.iOS</string>
|
||||
<key>AppIdentifierPrefix</key>
|
||||
<string>$(AppIdentifierPrefix)</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Widget</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
209
Multiplatform/iOS/Widget/LatestWidget.swift
Normal file
209
Multiplatform/iOS/Widget/LatestWidget.swift
Normal file
@ -0,0 +1,209 @@
|
||||
//
|
||||
// LatestWidget.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Stuart Breckenridge on 10/7/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
struct Provider: TimelineProvider {
|
||||
public typealias Entry = SummaryEntry
|
||||
|
||||
|
||||
public func snapshot(with context: Context, completion: @escaping (SummaryEntry) -> ()) {
|
||||
|
||||
if context.isPreview {
|
||||
let entry = SummaryEntry(date: Date(),
|
||||
widgetData: WidgetDataDecoder.sampleData())
|
||||
completion(entry)
|
||||
} else {
|
||||
do {
|
||||
let widgetData = try WidgetDataDecoder.decodeWidgetData()
|
||||
let entry = SummaryEntry(date: Date(), widgetData: widgetData)
|
||||
completion(entry)
|
||||
} catch {
|
||||
let entry = SummaryEntry(date: Date(),
|
||||
widgetData: WidgetData(currentUnreadCount: 42, currentTodayCount: 42, latestArticles: [], lastUpdateTime: Date()))
|
||||
completion(entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
||||
|
||||
// Create current timeline entry for now.
|
||||
let date = Date()
|
||||
var entry: SummaryEntry
|
||||
|
||||
do {
|
||||
let widgetData = try WidgetDataDecoder.decodeWidgetData()
|
||||
entry = SummaryEntry(date: date, widgetData: widgetData)
|
||||
} catch {
|
||||
entry = SummaryEntry(date: date, widgetData: WidgetData(currentUnreadCount: 42, currentTodayCount: 42, latestArticles: [], lastUpdateTime: Date()))
|
||||
}
|
||||
|
||||
// Configure next update in 1 hour.
|
||||
let nextUpdateDate = Calendar.current.date(byAdding: .hour, value: 1, to: date)!
|
||||
|
||||
let timeline = Timeline(
|
||||
entries:[entry],
|
||||
policy: .after(nextUpdateDate))
|
||||
|
||||
completion(timeline)
|
||||
}
|
||||
}
|
||||
|
||||
struct SummaryEntry: TimelineEntry {
|
||||
public let date: Date
|
||||
public let widgetData: WidgetData
|
||||
}
|
||||
|
||||
struct PlaceholderView : View {
|
||||
|
||||
@Environment(\.widgetFamily) var family: WidgetFamily
|
||||
|
||||
var body: some View {
|
||||
Text("Placeholder View")
|
||||
}
|
||||
}
|
||||
|
||||
struct NetNewsWireWidgetView : View {
|
||||
|
||||
@Environment(\.widgetFamily) var family: WidgetFamily
|
||||
var entry: Provider.Entry
|
||||
|
||||
@ViewBuilder var body: some View {
|
||||
switch family {
|
||||
case .systemSmall:
|
||||
compactWidget
|
||||
case .systemMedium:
|
||||
mediumWidget
|
||||
case .systemLarge:
|
||||
compactWidget
|
||||
@unknown default:
|
||||
compactWidget
|
||||
}
|
||||
}
|
||||
|
||||
var compactWidget: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Spacer()
|
||||
// Today
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Image(systemName: "sun.max.fill")
|
||||
.foregroundColor(.orange)
|
||||
.font(.title3)
|
||||
VStack(alignment: .leading) {
|
||||
Text("Today")
|
||||
.font(.title3)
|
||||
.bold()
|
||||
.foregroundColor(.white)
|
||||
Text(String(entry.widgetData.currentTodayCount))
|
||||
.font(.body)
|
||||
.bold()
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
// Unread
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Image(systemName: "largecircle.fill.circle")
|
||||
.foregroundColor(.accentColor)
|
||||
.font(.title3)
|
||||
VStack(alignment: .leading) {
|
||||
Text("Unread")
|
||||
.font(.title3)
|
||||
.bold()
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text(String(entry.widgetData.currentUnreadCount))
|
||||
.font(.body)
|
||||
.bold()
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
.background(Color("WidgetBackground"))
|
||||
}
|
||||
|
||||
var mediumWidget: some View {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Text("LATEST UNREAD ARTICLES")
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
Spacer()
|
||||
}
|
||||
if entry.widgetData.latestArticles.count > 2 {
|
||||
VStack(alignment: .leading) {
|
||||
ForEach(0..<2, content: { i in
|
||||
HStack(alignment: .top) {
|
||||
Image(uiImage: thumbnail(entry.widgetData.latestArticles[i].feedIcon))
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
VStack(alignment: .leading) {
|
||||
Text(entry.widgetData.latestArticles[i].articleTitle ?? "")
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
Text(entry.widgetData.latestArticles[i].feedTitle)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.gray)
|
||||
Spacer()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
ForEach(0..<entry.widgetData.latestArticles.count, content: { i in
|
||||
Text(entry.widgetData.latestArticles[i].articleTitle ?? "").font(.headline)
|
||||
Text(entry.widgetData.latestArticles[i].feedTitle)
|
||||
.font(.footnote)
|
||||
})
|
||||
}
|
||||
Spacer()
|
||||
}.padding()
|
||||
.background(Color("WidgetBackground"))
|
||||
}
|
||||
|
||||
func thumbnail(_ data: Data?) -> UIImage {
|
||||
if data == nil {
|
||||
return UIImage(systemName: "globe")!
|
||||
} else {
|
||||
return UIImage(data: data!)!
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@main
|
||||
struct LatestWidget: Widget {
|
||||
private let kind: String = "com.ranchero.NetNewsWire.widget"
|
||||
|
||||
public var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind,
|
||||
provider: Provider(),
|
||||
placeholder: PlaceholderView()) { entry in
|
||||
NetNewsWireWidgetView(entry: entry)
|
||||
}
|
||||
.configurationDisplayName("NetNewsWire")
|
||||
.description("NetNewsWire")
|
||||
.supportedFamilies([.systemSmall, .systemMedium])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
struct Widget_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NetNewsWireWidgetView(entry: SummaryEntry(date: Date(), widgetData: WidgetDataDecoder.sampleData()))
|
||||
.previewContext(WidgetPreviewContext(family: .systemMedium))
|
||||
}
|
||||
}
|
10
Multiplatform/iOS/Widget/WidgetExtension.entitlements
Normal file
10
Multiplatform/iOS/Widget/WidgetExtension.entitlements
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.$(ORGANIZATION_IDENTIFIER).NetNewsWire.iOS</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
4
Multiplatform/iOS/Widget/widget-data-sample.json
Normal file
4
Multiplatform/iOS/Widget/widget-data-sample.json
Normal file
File diff suppressed because one or more lines are too long
@ -17,6 +17,9 @@
|
||||
1729529B24AA1FD200D65E66 /* MacSearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529A24AA1FD200D65E66 /* MacSearchField.swift */; };
|
||||
175942AA24AD533200585066 /* RefreshInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCE4226F4DFA0010922C /* RefreshInterval.swift */; };
|
||||
175942AB24AD533200585066 /* RefreshInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCE4226F4DFA0010922C /* RefreshInterval.swift */; };
|
||||
1772066324B946EC00970353 /* WidgetDataEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1772066224B946EC00970353 /* WidgetDataEncoder.swift */; };
|
||||
1772068624B9480800970353 /* WidgetDataDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1772068524B9480800970353 /* WidgetDataDecoder.swift */; };
|
||||
1772068724B9480800970353 /* WidgetDataDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1772068524B9480800970353 /* WidgetDataDecoder.swift */; };
|
||||
1776E88E24AC5F8A00E78166 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1776E88D24AC5F8A00E78166 /* AppDefaults.swift */; };
|
||||
1776E88F24AC5F8A00E78166 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1776E88D24AC5F8A00E78166 /* AppDefaults.swift */; };
|
||||
17930ED424AF10EE00A9BA52 /* AddWebFeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17930ED324AF10EE00A9BA52 /* AddWebFeedView.swift */; };
|
||||
@ -28,6 +31,14 @@
|
||||
17D5F17124B0BC6700375168 /* SidebarToolbarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D5F17024B0BC6700375168 /* SidebarToolbarModel.swift */; };
|
||||
17D5F17224B0BC6700375168 /* SidebarToolbarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D5F17024B0BC6700375168 /* SidebarToolbarModel.swift */; };
|
||||
17D5F19524B0C1DD00375168 /* SidebarToolbarModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199F024AB716900A31D04 /* SidebarToolbarModifier.swift */; };
|
||||
17E1AFE824B99D20009DD525 /* widget-data-sample.json in Resources */ = {isa = PBXBuildFile; fileRef = 17E1AFC624B99D20009DD525 /* widget-data-sample.json */; };
|
||||
17EEA7F524B8926700AAD8BF /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17EEA7F424B8926700AAD8BF /* WidgetKit.framework */; };
|
||||
17EEA7F724B8926700AAD8BF /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17EEA7F624B8926700AAD8BF /* SwiftUI.framework */; };
|
||||
17EEA7FA24B8926700AAD8BF /* LatestWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17EEA7F924B8926700AAD8BF /* LatestWidget.swift */; };
|
||||
17EEA7FC24B8926700AAD8BF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 17EEA7FB24B8926700AAD8BF /* Assets.xcassets */; };
|
||||
17EEA80024B8926800AAD8BF /* WidgetExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 17EEA7F324B8926700AAD8BF /* WidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
17EEA80624B8996100AAD8BF /* WidgetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17EEA80524B8996100AAD8BF /* WidgetData.swift */; };
|
||||
17EEA80724B8996100AAD8BF /* WidgetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17EEA80524B8996100AAD8BF /* WidgetData.swift */; };
|
||||
3B3A32A5238B820900314204 /* FeedWranglerAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */; };
|
||||
3B826DCB2385C84800FC1ADB /* AccountsFeedWrangler.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3B826DB02385C84800FC1ADB /* AccountsFeedWrangler.xib */; };
|
||||
3B826DCC2385C84800FC1ADB /* AccountsFeedWranglerWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B826DCA2385C84800FC1ADB /* AccountsFeedWranglerWindowController.swift */; };
|
||||
@ -1092,6 +1103,13 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
17EEA7FE24B8926800AAD8BF /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 849C64581ED37A5D003D8FC0 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 17EEA7F224B8926700AAD8BF;
|
||||
remoteInfo = WidgetExtension;
|
||||
};
|
||||
5102FD7A244008A700534F17 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 5102FD72244008A700534F17 /* Secrets.xcodeproj */;
|
||||
@ -1599,6 +1617,17 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
17EEA80424B8926800AAD8BF /* Embed App Extensions */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 13;
|
||||
files = (
|
||||
17EEA80024B8926800AAD8BF /* WidgetExtension.appex in Embed App Extensions */,
|
||||
);
|
||||
name = "Embed App Extensions";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
513C5CF1232571C2003D4054 /* Embed App Extensions */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -1788,12 +1817,23 @@
|
||||
1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralPreferencesView.swift; sourceTree = "<group>"; };
|
||||
1729529624AA1CD000D65E66 /* MacPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacPreferencesView.swift; sourceTree = "<group>"; };
|
||||
1729529A24AA1FD200D65E66 /* MacSearchField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacSearchField.swift; sourceTree = "<group>"; };
|
||||
1772066224B946EC00970353 /* WidgetDataEncoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDataEncoder.swift; sourceTree = "<group>"; };
|
||||
1772068524B9480800970353 /* WidgetDataDecoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetDataDecoder.swift; sourceTree = "<group>"; };
|
||||
1772068824B94F6700970353 /* WidgetExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WidgetExtension.entitlements; sourceTree = "<group>"; };
|
||||
1776E88D24AC5F8A00E78166 /* AppDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDefaults.swift; sourceTree = "<group>"; };
|
||||
17930ED324AF10EE00A9BA52 /* AddWebFeedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWebFeedView.swift; sourceTree = "<group>"; };
|
||||
179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsNewsBlurWindowController.swift; sourceTree = "<group>"; };
|
||||
17B223DB24AC24D2001E4592 /* TimelineLayoutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineLayoutView.swift; sourceTree = "<group>"; };
|
||||
17D232A724AFF10A0005F075 /* AddWebFeedModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWebFeedModel.swift; sourceTree = "<group>"; };
|
||||
17D5F17024B0BC6700375168 /* SidebarToolbarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarToolbarModel.swift; sourceTree = "<group>"; };
|
||||
17E1AFC624B99D20009DD525 /* widget-data-sample.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "widget-data-sample.json"; sourceTree = "<group>"; };
|
||||
17EEA7F324B8926700AAD8BF /* WidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
17EEA7F424B8926700AAD8BF /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
|
||||
17EEA7F624B8926700AAD8BF /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
|
||||
17EEA7F924B8926700AAD8BF /* LatestWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LatestWidget.swift; sourceTree = "<group>"; };
|
||||
17EEA7FB24B8926700AAD8BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
17EEA7FD24B8926700AAD8BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
17EEA80524B8996100AAD8BF /* WidgetData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetData.swift; sourceTree = "<group>"; };
|
||||
3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerAccountViewController.swift; sourceTree = "<group>"; };
|
||||
3B826DB02385C84800FC1ADB /* AccountsFeedWrangler.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AccountsFeedWrangler.xib; sourceTree = "<group>"; };
|
||||
3B826DCA2385C84800FC1ADB /* AccountsFeedWranglerWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsFeedWranglerWindowController.swift; sourceTree = "<group>"; };
|
||||
@ -2324,6 +2364,15 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
17EEA7F024B8926700AAD8BF /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
17EEA7F724B8926700AAD8BF /* SwiftUI.framework in Frameworks */,
|
||||
17EEA7F524B8926700AAD8BF /* WidgetKit.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
51314634235A7BBE00387FDC /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -2533,6 +2582,28 @@
|
||||
path = Add;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
17EEA7F824B8926700AAD8BF /* Widget */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1772068824B94F6700970353 /* WidgetExtension.entitlements */,
|
||||
17EEA7F924B8926700AAD8BF /* LatestWidget.swift */,
|
||||
17E1AFC624B99D20009DD525 /* widget-data-sample.json */,
|
||||
17EEA7FB24B8926700AAD8BF /* Assets.xcassets */,
|
||||
17EEA7FD24B8926700AAD8BF /* Info.plist */,
|
||||
);
|
||||
path = Widget;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
17EEA80824B8998900AAD8BF /* Widget Data */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
17EEA80524B8996100AAD8BF /* WidgetData.swift */,
|
||||
1772066224B946EC00970353 /* WidgetDataEncoder.swift */,
|
||||
1772068524B9480800970353 /* WidgetDataDecoder.swift */,
|
||||
);
|
||||
path = "Widget Data";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
510289CE2451BA1E00426DDF /* Twitter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -2904,6 +2975,8 @@
|
||||
5177476424B3BDAE00EB0F74 /* AttributedStringView.swift */,
|
||||
5177470B24B2FF2C00EB0F74 /* Article */,
|
||||
172199EB24AB228E00A31D04 /* Settings */,
|
||||
17EEA7F824B8926700AAD8BF /* Widget */,
|
||||
17EEA80824B8998900AAD8BF /* Widget Data */,
|
||||
);
|
||||
path = iOS;
|
||||
sourceTree = "<group>";
|
||||
@ -3108,6 +3181,8 @@
|
||||
51E4DAEC2425F6940091EB5B /* CloudKit.framework */,
|
||||
51E4989624A8065700B667CB /* CloudKit.framework */,
|
||||
51C452B32265141B00C03939 /* WebKit.framework */,
|
||||
17EEA7F424B8926700AAD8BF /* WidgetKit.framework */,
|
||||
17EEA7F624B8926700AAD8BF /* SwiftUI.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@ -3511,6 +3586,7 @@
|
||||
65ED409D235DEF770081F399 /* Subscribe to Feed.appex */,
|
||||
51C0513D24A77DF800194D5E /* NetNewsWire.app */,
|
||||
51C0514424A77DF800194D5E /* NetNewsWire.app */,
|
||||
17EEA7F324B8926700AAD8BF /* WidgetExtension.appex */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -3905,6 +3981,23 @@
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
17EEA7F224B8926700AAD8BF /* WidgetExtension */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 17EEA80124B8926800AAD8BF /* Build configuration list for PBXNativeTarget "WidgetExtension" */;
|
||||
buildPhases = (
|
||||
17EEA7EF24B8926700AAD8BF /* Sources */,
|
||||
17EEA7F024B8926700AAD8BF /* Frameworks */,
|
||||
17EEA7F124B8926700AAD8BF /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = WidgetExtension;
|
||||
productName = WidgetExtension;
|
||||
productReference = 17EEA7F324B8926700AAD8BF /* WidgetExtension.appex */;
|
||||
productType = "com.apple.product-type.app-extension";
|
||||
};
|
||||
51314636235A7BBE00387FDC /* NetNewsWire iOS Intents Extension */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 5131463F235A7BBE00387FDC /* Build configuration list for PBXNativeTarget "NetNewsWire iOS Intents Extension" */;
|
||||
@ -3965,10 +4058,12 @@
|
||||
51C0513A24A77DF800194D5E /* Frameworks */,
|
||||
51C0513B24A77DF800194D5E /* Resources */,
|
||||
51E4989524A8061400B667CB /* Embed Frameworks */,
|
||||
17EEA80424B8926800AAD8BF /* Embed App Extensions */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
17EEA7FF24B8926800AAD8BF /* PBXTargetDependency */,
|
||||
);
|
||||
name = "Multiplatform iOS";
|
||||
productName = iOS;
|
||||
@ -4147,48 +4242,53 @@
|
||||
LastUpgradeCheck = 0930;
|
||||
ORGANIZATIONNAME = "Ranchero Software";
|
||||
TargetAttributes = {
|
||||
17EEA7F224B8926700AAD8BF = {
|
||||
CreatedOnToolsVersion = 12.0;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
51314636235A7BBE00387FDC = {
|
||||
CreatedOnToolsVersion = 11.2;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
LastSwiftMigration = 1120;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
513C5CE5232571C2003D4054 = {
|
||||
CreatedOnToolsVersion = 11.0;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
518B2ED12351B3DD00400001 = {
|
||||
CreatedOnToolsVersion = 11.2;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
TestTargetID = 840D617B2029031C009BC708;
|
||||
};
|
||||
51C0513C24A77DF800194D5E = {
|
||||
CreatedOnToolsVersion = 12.0;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
51C0514324A77DF800194D5E = {
|
||||
CreatedOnToolsVersion = 12.0;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
6581C73220CED60000F4AD34 = {
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
65ED3FA2235DEF6C0081F399 = {
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
65ED4090235DEF770081F399 = {
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
840D617B2029031C009BC708 = {
|
||||
CreatedOnToolsVersion = 9.3;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
com.apple.BackgroundModes = {
|
||||
@ -4198,7 +4298,7 @@
|
||||
};
|
||||
849C645F1ED37A5D003D8FC0 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
com.apple.HardenedRuntime = {
|
||||
@ -4208,7 +4308,7 @@
|
||||
};
|
||||
849C64701ED37A5D003D8FC0 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = SHJK2V3AJG;
|
||||
DevelopmentTeam = FQLBNX3GP7;
|
||||
ProvisioningStyle = Automatic;
|
||||
TestTargetID = 849C645F1ED37A5D003D8FC0;
|
||||
};
|
||||
@ -4289,6 +4389,7 @@
|
||||
518B2ED12351B3DD00400001 /* NetNewsWire-iOSTests */,
|
||||
51C0513C24A77DF800194D5E /* Multiplatform iOS */,
|
||||
51C0514324A77DF800194D5E /* Multiplatform macOS */,
|
||||
17EEA7F224B8926700AAD8BF /* WidgetExtension */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@ -4605,6 +4706,15 @@
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
17EEA7F124B8926700AAD8BF /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
17EEA7FC24B8926700AAD8BF /* Assets.xcassets in Resources */,
|
||||
17E1AFE824B99D20009DD525 /* widget-data-sample.json in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
51314635235A7BBE00387FDC /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -4940,6 +5050,16 @@
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
17EEA7EF24B8926700AAD8BF /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1772068724B9480800970353 /* WidgetDataDecoder.swift in Sources */,
|
||||
17EEA7FA24B8926700AAD8BF /* LatestWidget.swift in Sources */,
|
||||
17EEA80724B8996100AAD8BF /* WidgetData.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
51314633235A7BBE00387FDC /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -4997,6 +5117,7 @@
|
||||
51E4996A24A8762D00B667CB /* ExtractedArticle.swift in Sources */,
|
||||
51919FF124AB864A00541E64 /* TimelineModel.swift in Sources */,
|
||||
51E498F124A8085D00B667CB /* StarredFeedDelegate.swift in Sources */,
|
||||
17EEA80624B8996100AAD8BF /* WidgetData.swift in Sources */,
|
||||
51E498FF24A808BB00B667CB /* SingleFaviconDownloader.swift in Sources */,
|
||||
51E4997224A8784300B667CB /* DefaultFeedsImporter.swift in Sources */,
|
||||
514E6C0924AD39AD00AC6F6E /* ArticleIconImageLoader.swift in Sources */,
|
||||
@ -5017,6 +5138,7 @@
|
||||
65ACE48A24B4C2D8003AE06A /* SettingsFeedbinAccountView.swift in Sources */,
|
||||
51E4993624A867E800B667CB /* UserInfoKey.swift in Sources */,
|
||||
51E4990924A808C500B667CB /* WebFeedIconDownloader.swift in Sources */,
|
||||
1772066324B946EC00970353 /* WidgetDataEncoder.swift in Sources */,
|
||||
51E498F524A8085D00B667CB /* TodayFeedDelegate.swift in Sources */,
|
||||
172199F124AB716900A31D04 /* SidebarToolbarModifier.swift in Sources */,
|
||||
65CBAD5A24AE03C20006DD91 /* ColorPaletteContainerView.swift in Sources */,
|
||||
@ -5071,6 +5193,7 @@
|
||||
51E4996824A8760C00B667CB /* ArticleStyle.swift in Sources */,
|
||||
51E4990024A808BB00B667CB /* FaviconGenerator.swift in Sources */,
|
||||
51E4997124A8764C00B667CB /* ActivityType.swift in Sources */,
|
||||
1772068624B9480800970353 /* WidgetDataDecoder.swift in Sources */,
|
||||
51E4991E24A8094300B667CB /* RSImage-AppIcons.swift in Sources */,
|
||||
51E499D824A912C200B667CB /* SceneModel.swift in Sources */,
|
||||
5177470E24B2FF6F00EB0F74 /* ArticleView.swift in Sources */,
|
||||
@ -5797,6 +5920,11 @@
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
17EEA7FF24B8926800AAD8BF /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 17EEA7F224B8926700AAD8BF /* WidgetExtension */;
|
||||
targetProxy = 17EEA7FE24B8926800AAD8BF /* PBXContainerItemProxy */;
|
||||
};
|
||||
5131463D235A7BBE00387FDC /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 51314636235A7BBE00387FDC /* NetNewsWire iOS Intents Extension */;
|
||||
@ -6056,6 +6184,148 @@
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
17EEA80224B8926800AAD8BF /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Multiplatform/iOS/Widget/WidgetExtension.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = FQLBNX3GP7;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = Multiplatform/iOS/Widget/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.stuartbreckenridge.opensource.NetNewsWire.iOS.Widget;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
17EEA80324B8926800AAD8BF /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Multiplatform/iOS/Widget/WidgetExtension.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = FQLBNX3GP7;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = Multiplatform/iOS/Widget/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.stuartbreckenridge.opensource.NetNewsWire.iOS.Widget;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
51314640235A7BBE00387FDC /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 51314617235A797400387FDC /* NetNewsWire_iOSintentextension_target.xcconfig */;
|
||||
@ -6102,6 +6372,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 51C0519724A7808F00194D5E /* NetNewsWire_multiplatform_iOSapp_target.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -6109,6 +6380,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 51C0519724A7808F00194D5E /* NetNewsWire_multiplatform_iOSapp_target.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@ -6233,6 +6505,15 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
17EEA80124B8926800AAD8BF /* Build configuration list for PBXNativeTarget "WidgetExtension" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
17EEA80224B8926800AAD8BF /* Debug */,
|
||||
17EEA80324B8926800AAD8BF /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
5131463F235A7BBE00387FDC /* Build configuration list for PBXNativeTarget "NetNewsWire iOS Intents Extension" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
35
Technotes/Widget.md
Normal file
35
Technotes/Widget.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Widget
|
||||
|
||||
## Supported Widget Styles
|
||||
|
||||
The NetNewsWire iOS widget supports the `systemSmall` and `systemMedium` styles.
|
||||
|
||||
For the purpose of this PoC: the `systemSmall` style displays the current Today and Unread counts; `systemMedium` displays the latest two articles.
|
||||
|
||||
## Passing Data from the App to the Widget
|
||||
|
||||
Data is made available to the widget by encoding smart feed and article data as JSON, and saving it to a file in a directory available to app extensions.
|
||||
|
||||
Three `struct`s are responsible for this:
|
||||
|
||||
- `WidgetDataEncoder` (which is available to the app);
|
||||
- `WidgetDataDecoder` (which is available to the widget); and,
|
||||
- `WidgetData` (which is available to both app and widget, and includes the data neccessary for the widget to function)
|
||||
|
||||
## When is JSON Data Saved?
|
||||
|
||||
1. When the app enters the background (monitored via the `scenePhase` changing (tested)); or,
|
||||
2. After a background refresh (untested at the time of writing)
|
||||
|
||||
Encoding tasks are fenced in
|
||||
```
|
||||
UIApplication.shared.beginBackgroundTask
|
||||
_{ encoding task }_
|
||||
UIApplication.shared.endBackgroundTask
|
||||
```
|
||||
in order to ensure that the file can be written with sufficient time to spare.
|
||||
|
||||
After JSON data is saved, Widget timelines are reloaded.
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user