Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Foundation
@objc static let userDefaultsSiteIdKey = "WordPressHomeWidgetsSiteId"
@objc static let userDefaultsLoggedInKey = "WordPressHomeWidgetsLoggedIn"
@objc static let userDefaultsJetpackFeaturesDisabledKey = "WordPressJPFeaturesDisabledKey"
@objc static let lockScreenTodayViewsKind = "WordPressLockScreenWidgetTodayViews"
@objc static let todayKind = "WordPressHomeWidgetToday"
@objc static let allTimeKind = "WordPressHomeWidgetAllTime"
@objc static let thisWeekKind = "WordPressHomeWidgetThisWeek"
Expand Down
7 changes: 7 additions & 0 deletions WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag {
case homepageSettings
case unifiedPrologueCarousel
case todayWidget
case lockScreenWidget
case milestoneNotifications
case bloggingReminders
case siteIconCreator
Expand Down Expand Up @@ -74,6 +75,8 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag {
return true
case .todayWidget:
return true
case .lockScreenWidget:
return true
case .milestoneNotifications:
return true
case .bloggingReminders:
Expand Down Expand Up @@ -218,6 +221,8 @@ extension FeatureFlag {
return "Unified Prologue Carousel"
case .todayWidget:
return "iOS 14 Today Widget"
case .lockScreenWidget:
return "iOS 16 Widget in Lock Screen"
case .milestoneNotifications:
return "Milestone notifications"
case .bloggingReminders:
Expand Down Expand Up @@ -301,6 +306,8 @@ extension FeatureFlag {
return false
case .todayWidget:
return false
case .lockScreenWidget:
return false
case .weeklyRoundup:
return false
case .weeklyRoundupStaticNotification:
Expand Down
1 change: 1 addition & 0 deletions WordPress/Jetpack/WidgetConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Foundation
@objc static let userDefaultsSiteIdKey = "JetpackHomeWidgetsSiteId"
@objc static let userDefaultsLoggedInKey = "JetpackHomeWidgetsLoggedIn"
@objc static let userDefaultsJetpackFeaturesDisabledKey = "JetpackJPFeaturesDisabledKey"
@objc static let lockScreenTodayViewsKind = "JetpackLockScreenWidgetTodayViews"
@objc static let todayKind = "JetpackHomeWidgetToday"
@objc static let allTimeKind = "JetpackHomeWidgetAllTime"
@objc static let thisWeekKind = "JetpackHomeWidgetThisWeek"
Expand Down
28 changes: 28 additions & 0 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,10 @@
C957C20626DCC1770037628F /* LandInTheEditorHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C957C20526DCC1770037628F /* LandInTheEditorHelper.swift */; };
C957C20726DCC1770037628F /* LandInTheEditorHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C957C20526DCC1770037628F /* LandInTheEditorHelper.swift */; };
C99B08FC26081AD600CA71EB /* TemplatePreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99B08FB26081AD600CA71EB /* TemplatePreviewViewController.swift */; };
C9C21D7729BECFC1009F68E5 /* LockScreenStatsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C21D7629BECFC1009F68E5 /* LockScreenStatsWidget.swift */; };
C9C21D7829BECFC7009F68E5 /* LockScreenStatsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C21D7629BECFC1009F68E5 /* LockScreenStatsWidget.swift */; };
C9C21D7B29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C21D7A29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift */; };
C9C21D7C29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C21D7A29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift */; };
C9F1D4B72706ED7C00BDF917 /* EditHomepageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9F1D4B62706ED7C00BDF917 /* EditHomepageViewController.swift */; };
C9F1D4B82706ED7C00BDF917 /* EditHomepageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9F1D4B62706ED7C00BDF917 /* EditHomepageViewController.swift */; };
C9F1D4BA2706EEEB00BDF917 /* HomepageEditorNavigationBarManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9F1D4B92706EEEB00BDF917 /* HomepageEditorNavigationBarManager.swift */; };
Expand Down Expand Up @@ -8090,6 +8094,8 @@
C957C20526DCC1770037628F /* LandInTheEditorHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandInTheEditorHelper.swift; sourceTree = "<group>"; };
C99B039B2602F3CB00CA71EB /* WordPress 117.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 117.xcdatamodel"; sourceTree = "<group>"; };
C99B08FB26081AD600CA71EB /* TemplatePreviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplatePreviewViewController.swift; sourceTree = "<group>"; };
C9C21D7629BECFC1009F68E5 /* LockScreenStatsWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenStatsWidget.swift; sourceTree = "<group>"; };
C9C21D7A29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenStatsWidgetsView.swift; sourceTree = "<group>"; };
C9D7DDBF2613B84500104E95 /* WordPress 119.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 119.xcdatamodel"; sourceTree = "<group>"; };
C9F1D4B62706ED7C00BDF917 /* EditHomepageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditHomepageViewController.swift; sourceTree = "<group>"; };
C9F1D4B92706EEEB00BDF917 /* HomepageEditorNavigationBarManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomepageEditorNavigationBarManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -11028,6 +11034,7 @@
children = (
3F8EEC4D25B4817000EC9DAE /* StatsWidgets.swift */,
3F8EEC6F25B4849A00EC9DAE /* SiteListProvider.swift */,
C9C21D7529BECFAE009F68E5 /* LockScreenWidgets */,
3FFDDCB925B8A65F008D5BDD /* Widgets */,
3FB34ABB25672A59001A74A6 /* Model */,
3FFDDC0325B89F0C008D5BDD /* Cache */,
Expand Down Expand Up @@ -15630,6 +15637,23 @@
path = Tenor;
sourceTree = "<group>";
};
C9C21D7529BECFAE009F68E5 /* LockScreenWidgets */ = {
isa = PBXGroup;
children = (
C9C21D7629BECFC1009F68E5 /* LockScreenStatsWidget.swift */,
C9C21D8829BF4998009F68E5 /* Views */,
);
path = LockScreenWidgets;
sourceTree = "<group>";
};
C9C21D8829BF4998009F68E5 /* Views */ = {
isa = PBXGroup;
children = (
C9C21D7A29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift */,
);
path = Views;
sourceTree = "<group>";
};
CC098B8116A9EB0400450976 /* HTML */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -20386,6 +20410,7 @@
files = (
0107E0B428F97D5000DE87DB /* Constants.m in Sources */,
01CE5012290A890B00A9C2E0 /* TracksConfiguration.swift in Sources */,
C9C21D7C29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift in Sources */,
0107E0B528F97D5000DE87DB /* StatsWidgetEntry.swift in Sources */,
0107E0B628F97D5000DE87DB /* HomeWidgetCache.swift in Sources */,
0107E18C29000E2A00DE87DB /* AppStyleGuide.swift in Sources */,
Expand All @@ -20406,6 +20431,7 @@
0107E0C328F97D5000DE87DB /* ThisWeekWidgetStats.swift in Sources */,
0107E0C428F97D5000DE87DB /* HomeWidgetAllTimeData.swift in Sources */,
0107E0C528F97D5000DE87DB /* GroupedViewData.swift in Sources */,
C9C21D7829BECFC7009F68E5 /* LockScreenStatsWidget.swift in Sources */,
0107E0C628F97D5000DE87DB /* FeatureFlag.swift in Sources */,
0107E0C728F97D5000DE87DB /* StatsWidgets.swift in Sources */,
0107E18F29000EA200DE87DB /* UIColor+MurielColors.swift in Sources */,
Expand Down Expand Up @@ -22241,6 +22267,7 @@
files = (
3F1FD30D2548B0A80060C53A /* Constants.m in Sources */,
01CE500C290A88BF00A9C2E0 /* TracksConfiguration.swift in Sources */,
C9C21D7B29BED18C009F68E5 /* LockScreenStatsWidgetsView.swift in Sources */,
3F63B93C258179D100F581BE /* StatsWidgetEntry.swift in Sources */,
3FA53E9D256571D800F4D9A2 /* HomeWidgetCache.swift in Sources */,
0107E18D29000E3300DE87DB /* AppStyleGuide.swift in Sources */,
Expand All @@ -22261,6 +22288,7 @@
3F5C861A25C9EA2500BABE64 /* HomeWidgetAllTimeData.swift in Sources */,
3FE20C1525CF165700A15525 /* GroupedViewData.swift in Sources */,
3F6BC04B25B2474C007369D3 /* FeatureFlag.swift in Sources */,
C9C21D7729BECFC1009F68E5 /* LockScreenStatsWidget.swift in Sources */,
3F8EEC4E25B4817000EC9DAE /* StatsWidgets.swift in Sources */,
3FA59B9A258289E30073772F /* StatsValueView.swift in Sources */,
0107E18E29000EA100DE87DB /* UIColor+MurielColors.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import WidgetKit
import SwiftUI

@available(iOS 16.0, *)
struct LockScreenStatsWidget: Widget {
private let placeholderContent = HomeWidgetTodayData(
siteID: 0,
siteName: "My WordPress Site",
url: "",
timeZone: TimeZone.current,
date: Date(),
stats: TodayWidgetStats(views: 649,
visitors: 572,
likes: 16,
comments: 8))

var body: some WidgetConfiguration {
IntentConfiguration(
kind: AppConfiguration.Widget.Stats.lockScreenTodayViewsKind,
intent: SelectSiteIntent.self,
provider: SiteListProvider<HomeWidgetTodayData>(
service: StatsWidgetsService(),
placeholderContent: placeholderContent,
widgetKind: .today
)
) { (entry: StatsWidgetEntry) -> LockScreenStatsWidgetsView in
return LockScreenStatsWidgetsView(timelineEntry: entry)
}
.configurationDisplayName(LocalizableStrings.todayWidgetTitle)
.description(LocalizableStrings.todayPreviewDescription)
.supportedFamilies(FeatureFlag.lockScreenWidget.enabled ? [.accessoryRectangular] : [])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, is this [.accessoryRectangular] the line that enables the widget to appear on the lock screen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, accessoryRectangular, accessoryInline, and accessoryCircular can appear in watchOS or on the Lock Screen in iOS.

So another solution is we can just extend existing widget support by adding accessoryRectangular,
and provide the view based on the currently family, but that's not good for scalable when more widgets in the future :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for explaining!

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import SwiftUI
import WidgetKit

struct LockScreenStatsWidgetsView: View {
let timelineEntry: StatsWidgetEntry

@ViewBuilder
var body: some View {
Text("Build Later")
}
}
3 changes: 3 additions & 0 deletions WordPress/WordPressStatsWidgets/StatsWidgets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ struct WordPressStatsWidgets: WidgetBundle {
WordPressHomeWidgetToday()
WordPressHomeWidgetThisWeek()
WordPressHomeWidgetAllTime()
if AppConfiguration.isJetpack, #available(iOS 16.0, *) {
LockScreenStatsWidget()
}
}
}