Merge pull request #3678 from stuartbreckenridge/ios16-widgets

Adds iOS 16 Lock Screen Widget
This commit is contained in:
Maurice Parker
2022-09-17 19:38:44 -05:00
committed by GitHub
3 changed files with 50 additions and 56 deletions

View File

@@ -36,7 +36,6 @@
176814362564BCC000D98635 /* UnreadWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 176814352564BCC000D98635 /* UnreadWidget.swift */; };
1768143E2564BCC800D98635 /* TodayWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1768143D2564BCC800D98635 /* TodayWidget.swift */; };
176814462564BCD200D98635 /* StarredWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 176814452564BCD200D98635 /* StarredWidget.swift */; };
1768144E2564BCE000D98635 /* SmartFeedSummaryWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1768144D2564BCE000D98635 /* SmartFeedSummaryWidget.swift */; };
176814572564BD0600D98635 /* ArticleItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 176814562564BD0600D98635 /* ArticleItemView.swift */; };
1768145E2564BD7B00D98635 /* WidgetDataDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 176813C92564BA5400D98635 /* WidgetDataDecoder.swift */; };
176814652564BD7F00D98635 /* WidgetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 176813B62564B9F800D98635 /* WidgetData.swift */; };
@@ -847,6 +846,7 @@
D5F4EDB720074D6500B9E363 /* WebFeed+Scriptability.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F4EDB620074D6500B9E363 /* WebFeed+Scriptability.swift */; };
D5F4EDB920074D7C00B9E363 /* Folder+Scriptability.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F4EDB820074D7C00B9E363 /* Folder+Scriptability.swift */; };
DD82AB0A231003F6002269DF /* SharingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD82AB09231003F6002269DF /* SharingTests.swift */; };
DF5AD10128D6922200CA3BF7 /* SmartFeedSummaryWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1768144D2564BCE000D98635 /* SmartFeedSummaryWidget.swift */; };
DFD6AACF27ADE86E00463FAD /* NewsFax.nnwtheme in Resources */ = {isa = PBXBuildFile; fileRef = DFD6AACD27ADE86E00463FAD /* NewsFax.nnwtheme */; };
DFFB8FC2279B75E300AC21D7 /* Account in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 51BC2F4A24D343A500E90810 /* Account */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
DFFC199827A0D0D7004B7AEF /* NotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFFC199727A0D0D7004B7AEF /* NotificationsViewController.swift */; };
@@ -1766,10 +1766,10 @@
176814342564BCB500D98635 /* Widget Views */ = {
isa = PBXGroup;
children = (
1768144D2564BCE000D98635 /* SmartFeedSummaryWidget.swift */,
176814352564BCC000D98635 /* UnreadWidget.swift */,
1768143D2564BCC800D98635 /* TodayWidget.swift */,
176814452564BCD200D98635 /* StarredWidget.swift */,
1768144D2564BCE000D98635 /* SmartFeedSummaryWidget.swift */,
);
path = "Widget Views";
sourceTree = "<group>";
@@ -3176,7 +3176,7 @@
849C64581ED37A5D003D8FC0 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1240;
LastSwiftUpdateCheck = 1400;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Ranchero Software";
TargetAttributes = {
@@ -3715,6 +3715,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DF5AD10128D6922200CA3BF7 /* SmartFeedSummaryWidget.swift in Sources */,
176814362564BCC000D98635 /* UnreadWidget.swift in Sources */,
1768146C2564BD8100D98635 /* WidgetDeepLinks.swift in Sources */,
1768143E2564BCC800D98635 /* TodayWidget.swift in Sources */,
@@ -3726,7 +3727,6 @@
17E0084625941887000C23F0 /* SizeCategories.swift in Sources */,
176814462564BCD200D98635 /* StarredWidget.swift in Sources */,
176814572564BD0600D98635 /* ArticleItemView.swift in Sources */,
1768144E2564BCE000D98635 /* SmartFeedSummaryWidget.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4705,6 +4705,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 51121AA12265430A00BC0EC1 /* NetNewsWire_iOSapp_target.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
};
name = Debug;
};
@@ -4712,6 +4713,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 51121AA12265430A00BC0EC1 /* NetNewsWire_iOSapp_target.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
};
name = Release;
};

View File

@@ -17,48 +17,37 @@ struct SmartFeedSummaryWidgetView: View {
var entry: Provider.Entry
var body: some View {
smallWidget
rectangleWidget
.widgetURL(WidgetDeepLink.icon.url)
}
@ViewBuilder
var smallWidget: some View {
VStack(alignment: .leading) {
Spacer()
Link(destination: WidgetDeepLink.today.url, label: {
HStack {
todayImage
VStack(alignment: .leading, spacing: nil, content: {
Text(formattedCount(entry.widgetData.currentTodayCount)).font(Font.system(.caption, design: .rounded)).bold()
Text(L10n.today).bold().font(.caption).textCase(.uppercase)
}).foregroundColor(.white)
Spacer()
}
})
var rectangleWidget: some View {
VStack(alignment: .leading, spacing: 2) {
HStack {
todayImage
Text(L10n.today).bold().font(.body)
Spacer()
Text(formattedCount(entry.widgetData.currentTodayCount)).bold()
}
Link(destination: WidgetDeepLink.unread.url, label: {
HStack {
unreadImage
VStack(alignment: .leading, spacing: nil, content: {
Text(formattedCount(entry.widgetData.currentUnreadCount)).font(Font.system(.caption, design: .rounded)).bold()
Text(L10n.unread).bold().font(.caption).textCase(.uppercase)
}).foregroundColor(.white)
Spacer()
}
})
HStack {
unreadImage
Text(L10n.unread).bold().font(.body)
Spacer()
Text(formattedCount(entry.widgetData.currentUnreadCount)).bold()
}
Link(destination: WidgetDeepLink.starred.url, label: {
HStack {
starredImage
VStack(alignment: .leading, spacing: nil, content: {
Text(formattedCount(entry.widgetData.currentStarredCount)).font(Font.system(.caption, design: .rounded)).bold()
Text(L10n.starred).bold().font(.caption).textCase(.uppercase)
}).foregroundColor(.white)
Spacer()
}
})
Spacer()
}.padding()
HStack {
starredImage
Text(L10n.starred).bold().font(.body)
Spacer()
Text(formattedCount(entry.widgetData.currentStarredCount)).bold()
}
}
}
func formattedCount(_ count: Int) -> String {
@@ -71,37 +60,36 @@ struct SmartFeedSummaryWidgetView: View {
var unreadImage: some View {
Image(systemName: "largecircle.fill.circle")
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.foregroundColor(.white)
.frame(width: 12, height: 12, alignment: .center)
}
var nnwImage: some View {
Image("CornerIcon")
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.frame(width: 10, height: 10, alignment: .center)
.cornerRadius(4)
}
var starredImage: some View {
Image(systemName: "star.fill")
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.foregroundColor(.white)
.frame(width: 12, height: 12, alignment: .center)
}
var todayImage: some View {
Image(systemName: "sun.max.fill")
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.foregroundColor(.white)
.frame(width: 12, height: 12, alignment: .center)
}
}
@available(iOSApplicationExtension 16.0, *)
struct SmartFeedSummaryWidgetView_Previews: PreviewProvider {
static var previews: some View {
SmartFeedSummaryWidgetView(entry: Provider.Entry.init(date: Date(), widgetData: WidgetDataDecoder.sampleData()))
.previewContext(WidgetPreviewContext(family: .accessoryRectangular))
}
}

View File

@@ -65,6 +65,8 @@ struct StarredWidget: Widget {
}
}
@available(iOSApplicationExtension 16.0, *)
struct SmartFeedSummaryWidget: Widget {
let kind: String = "com.ranchero.NetNewsWire.SmartFeedSummaryWidget"
@@ -72,25 +74,27 @@ struct SmartFeedSummaryWidget: Widget {
return StaticConfiguration(kind: kind, provider: Provider(), content: { entry in
SmartFeedSummaryWidgetView(entry: entry)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color("AccentColor"))
})
.configurationDisplayName(L10n.smartFeedSummaryWidgetTitle)
.description(L10n.smartFeedSummaryWidgetDescription)
.supportedFamilies([.systemSmall])
.supportedFamilies([.accessoryRectangular])
}
}
// MARK: - WidgetBundle
@main
struct NetNewsWireWidgets: WidgetBundle {
@WidgetBundleBuilder
var body: some Widget {
UnreadWidget()
TodayWidget()
StarredWidget()
widgets()
}
func widgets() -> some Widget {
if #available(iOS 16.0, *) {
return WidgetBundleBuilder.buildBlock(UnreadWidget(), TodayWidget(), StarredWidget(), SmartFeedSummaryWidget())
} else {
return WidgetBundleBuilder.buildBlock(UnreadWidget(), TodayWidget(), StarredWidget())
}
}
}