-
Notifications
You must be signed in to change notification settings - Fork 2
feat(WhereUI): add a subtle personalized Locations background #324
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
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
07d7f20
Add a subtle personalized background to Locations
kyleve 1110b23
Tighten the Locations print with smaller staggered motifs
kyleve 7c19e27
Soften and shrink the Locations background print
kyleve ab94889
Match the Locations glow to the composited ink color
kyleve 929eeff
Use opaque printed ink for the Locations shadow mask
kyleve 9e27c1a
Diffuse Locations ink outward with clear region interiors
kyleve f2edc3e
Restore plain strokes for the Locations background
kyleve 7ff3fa0
Extend staggered Locations artwork beyond both edges
kyleve 152d474
Compose a monochrome region and rosette monogram
kyleve 97ca434
Restore full-view rosettes and staggered region rows
kyleve 4655a4c
Tighten Locations background region spacing
kyleve 0cfa21d
Remove globe motifs from Locations background
kyleve bd4cf43
Merge main into Locations background branch
kyleve c85ced1
Refresh welcome snapshots for Locations rosette background
kyleve 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
9 changes: 9 additions & 0 deletions
9
Where/WhereUI/SnapshotTests/LocationsBackgroundSnapshotTests.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,9 @@ | ||
| import SnapshotKitTesting | ||
| import Testing | ||
| @testable import WhereUI | ||
|
|
||
| struct LocationsBackgroundSnapshotTests { | ||
| @Test func locationsBackground() async { | ||
| await assertSnapshots(of: LocationsBackground.self) | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
...apshots__/LocationsBackgroundSnapshotTests/locationsBackground.Empty_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ts__/LocationsBackgroundSnapshotTests/locationsBackground.Empty_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...napshots__/LocationsBackgroundSnapshotTests/locationsBackground.Many_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots__/LocationsBackgroundSnapshotTests/locationsBackground.Many_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...Snapshots__/LocationsBackgroundSnapshotTests/locationsBackground.One_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...hots__/LocationsBackgroundSnapshotTests/locationsBackground.One_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ationsBackgroundSnapshotTests/locationsBackground.ReduceTransparency_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...sBackgroundSnapshotTests/locationsBackground.ReduceTransparency_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...shots__/LocationsBackgroundSnapshotTests/locationsBackground.Several_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...__/LocationsBackgroundSnapshotTests/locationsBackground.Several_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...tTests/__Snapshots__/LocationsViewSnapshotTests/locations.DotsHidden_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...s/__Snapshots__/LocationsViewSnapshotTests/locations.DotsHidden_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...sts/__Snapshots__/LocationsViewSnapshotTests/locations.ElsewhereOnly_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
..._Snapshots__/LocationsViewSnapshotTests/locations.ElsewhereOnly_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...apshotTests/__Snapshots__/LocationsViewSnapshotTests/locations.Empty_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...tTests/__Snapshots__/LocationsViewSnapshotTests/locations.Empty_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...s/__Snapshots__/LocationsViewSnapshotTests/locations.ForecastsHidden_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...napshots__/LocationsViewSnapshotTests/locations.ForecastsHidden_iPhone_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...napshotTests/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
..._Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPad_accessibility.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...hotTests/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPad_ax5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...sts/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPad_contrast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...otTests/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPad_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...pshotTests/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPhone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...napshots__/LocationsViewSnapshotTests/locations.Loaded_iPhone_accessibility.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...tTests/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPhone_ax5.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...s/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPhone_contrast.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...Tests/__Snapshots__/LocationsViewSnapshotTests/locations.Loaded_iPhone_dark.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...Tests/__Snapshots__/LocationsViewSnapshotTests/locations.MissingDays_iPhone.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
.../__Snapshots__/LocationsViewSnapshotTests/locations.MissingDays_iPhone_dark.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...Tests/__Snapshots__/LocationsViewSnapshotTests/locations.PlannedStay_iPhone.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
.../__Snapshots__/LocationsViewSnapshotTests/locations.PlannedStay_iPhone_dark.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...tTests/__Snapshots__/MainTabsSnapshotTests/mainTabs.WelcomeLocations_iPhone.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...hots__/MainTabsSnapshotTests/mainTabs.WelcomeLocations_iPhone_accessibility.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ts/__Snapshots__/MainTabsSnapshotTests/mainTabs.WelcomeLocations_iPhone_ax5.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...s/__Snapshots__/MainTabsSnapshotTests/mainTabs.WelcomeLocations_iPhone_dark.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...reUI/SnapshotTests/__Snapshots__/RootViewSnapshotTests/root.LoggedIn_iPhone.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...SnapshotTests/__Snapshots__/RootViewSnapshotTests/root.LoggedIn_iPhone_dark.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...Snapshots__/RootViewSnapshotTests/root.RecordingConfigurationWarning_iPhone.png
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...hots__/RootViewSnapshotTests/root.RecordingConfigurationWarning_iPhone_dark.png
Oops, something went wrong.
133 changes: 133 additions & 0 deletions
133
Where/WhereUI/Sources/Primary/LocationsBackground.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,133 @@ | ||
| import BroadwayUI | ||
| import RegionKit | ||
| import SwiftUI | ||
|
|
||
| /// Stationary, noninteractive paper texture for the root Locations viewport. | ||
| struct LocationsBackground: View { | ||
| let regions: [Region] | ||
|
|
||
| @Environment(\.stylesheet) private var stylesheet | ||
| @Environment(\.regionOutlinePathCache) private var cache | ||
| @State private var artwork: LocationsBackgroundArtwork? | ||
|
|
||
| private var style: WhereStylesheet.LocationsBackgroundStyle { | ||
| stylesheet.locationsBackground | ||
| } | ||
|
|
||
| private var requestedRegions: [Region] { | ||
| style.showsInk ? regions.filter { $0 != .other } : [] | ||
| } | ||
|
|
||
| var body: some View { | ||
| ZStack { | ||
| style.paper | ||
| if style.showsInk { | ||
| SecurityPrintRosette( | ||
| tint: style.ink, | ||
| wobble: style.rosette.wobble, | ||
| lineWidth: style.rosette.lineWidth, | ||
| primaryRingSpacing: style.rosette.primaryRingSpacing, | ||
| secondaryRingSpacing: style.rosette.secondaryRingSpacing, | ||
| primaryOpacity: style.rosetteOpacity, | ||
| secondaryOpacity: style.rosetteOpacity, | ||
| ) | ||
| silhouettes | ||
| } | ||
| } | ||
| .clipped() | ||
| .allowsHitTesting(false) | ||
| .accessibilityHidden(true) | ||
| .task(id: requestedRegions) { | ||
| guard let cache else { return } | ||
| if let loaded = await LocationsBackgroundArtwork.load( | ||
| regions: requestedRegions, | ||
| cache: cache, | ||
| ) { | ||
| guard !Task.isCancelled else { return } | ||
| artwork = loaded | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private var silhouettes: some View { | ||
| GeometryReader { proxy in | ||
| let items = artwork?.items(for: requestedRegions) ?? [] | ||
| let cells = LocationsBackgroundLayout.cells( | ||
| count: items.count, | ||
| in: proxy.size, | ||
| preferredCellSize: style.preferredCellSize, | ||
| ) | ||
| ZStack(alignment: .topLeading) { | ||
| ForEach(cells) { cell in | ||
| let item = items[cell.artworkIndex] | ||
| RegionOutlineArtwork( | ||
| path: item.path, | ||
| tint: style.ink, | ||
| style: balancedArtwork(for: item.path), | ||
| ) | ||
| .frame(width: cell.frame.width, height: cell.frame.height) | ||
| .position(x: cell.frame.midX, y: cell.frame.midY) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func balancedArtwork(for path: Path) -> WhereStylesheet.CardStyle.RegionShape.Artwork { | ||
| var artwork = style.artwork | ||
| let bounds = path.boundingRect | ||
| let shortSide = min(bounds.width, bounds.height) | ||
| guard shortSide > 0 else { return artwork } | ||
| // Give slender regions more room without changing the shared geographic projection. | ||
| artwork.scale *= min( | ||
| style.maximumAspectScale, | ||
| sqrt(max(bounds.width, bounds.height) / shortSide), | ||
| ) | ||
| return artwork | ||
| } | ||
| } | ||
|
|
||
| #if DEBUG | ||
| import SnapshotKit | ||
|
|
||
| extension LocationsBackground: SnapshotProviding { | ||
| static var snapshots: [SnapshotCase] { | ||
| artworkSnapshot(name: "Empty", regions: []) | ||
| artworkSnapshot(name: "One", regions: [.california]) | ||
| artworkSnapshot(name: "Several", regions: [.california, .newYork, .canada, .other]) | ||
| artworkSnapshot(name: "Many", regions: Array(Region.allCases.prefix(40))) | ||
| artworkSnapshot( | ||
| name: "ReduceTransparency", | ||
| regions: [.canada, .other], | ||
| reduceTransparency: true, | ||
| ) | ||
| } | ||
|
|
||
| private static func artworkSnapshot( | ||
| name: String, | ||
| regions: [Region], | ||
| reduceTransparency: Bool = false, | ||
| ) -> SnapshotCase { | ||
| let cache = RegionOutlinePathCache() | ||
| return whereSnapshot( | ||
| name: name, | ||
| configurations: .phoneLightDark, | ||
| measurementReadiness: .immediate, | ||
| onReadyToSnapshot: { | ||
| _ = await LocationsBackgroundArtwork.load(regions: regions, cache: cache) | ||
| }, | ||
| ) { | ||
| LocationsBackground(regions: regions) | ||
| .environment(\.regionOutlinePathCache, cache) | ||
| .bTraitOverrides { traits, overrides in | ||
| var accessibility = traits.accessibility | ||
| accessibility.isReduceTransparencyEnabled = reduceTransparency | ||
| overrides.accessibility = accessibility | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| LocationsBackground.snapshotPreviews | ||
| } | ||
| #endif | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Maybe not for this PR, but I think we have this duplicated in a few spots, maybe a good candidate for a shared modifier of some sort?
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.
Extracted this in #325 (commit b9b63d4). The Locations background, Elsewhere card, region cards, welcome card, and forecast panel now share regionArtworkTask plus RegionArtworkModel. The shared lifecycle handles cache injection, cancellation, and stale results, while the region card retains compatible outlines during point refreshes. Fifteen focused tests and six existing snapshot suites passed without reference changes. Since #324 has merged, the follow-up targets main.