-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add new feature flag for lock screen widgets in Jetpack #20309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
staskus
merged 6 commits into
wordpress-mobile:feature/19411-add-lock-screen-stats-widgets
from
tzef:feature/beemotrial/lockscreen-widgets-featureflag
Mar 15, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f3bbd84
Add new feature flag for widget in lock screen
tzef 61b762d
Add new widget kind to widget configuration
tzef 0e4ea31
Add empty lock screen widget
tzef 6861fb6
Add JETPACK_STATS_WIDGETS compilation condition
tzef b985e60
Move LockScreenStatsWidgetsView to views folder group
tzef 1629d3b
Revert compilation condition, change to isJetpack of AppCondiguration
tzef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
WordPress/WordPressStatsWidgets/LockScreenWidgets/LockScreenStatsWidget.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] : []) | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
WordPress/WordPressStatsWidgets/LockScreenWidgets/Views/LockScreenStatsWidgetsView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
accessoryRectangular,accessoryInline, andaccessoryCircularcan 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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for explaining!