Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

iOS shell: 16:9 banners, a deck Cover Flow and real art in the demo

v0lumehicee4138c861d
diff --git a/frontend-ios/.gitignore b/frontend-ios/.gitignore
index 308fb0ab..fad3453c 100644
--- a/frontend-ios/.gitignore
+++ b/frontend-ios/.gitignore
@@ -4,3 +4,8 @@ DerivedData/
*.xcresult/
xcuserdata/
QA/
+# The demo reads real game art at runtime from outside the package. No picture belongs here.
+*.jpg
+*.jpeg
+*.png
+*.webp
diff --git a/frontend-ios/Demo/ShellDemo.xcodeproj/project.pbxproj b/frontend-ios/Demo/ShellDemo.xcodeproj/project.pbxproj
index dd4ed636..22d942b3 100644
--- a/frontend-ios/Demo/ShellDemo.xcodeproj/project.pbxproj
+++ b/frontend-ios/Demo/ShellDemo.xcodeproj/project.pbxproj
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
2861C1407044359116FE0A66 /* ShellCaptureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8694319745E3759D50772855 /* ShellCaptureTests.swift */; };
+ 2EEF6A8F9A7D58C09181EAB5 /* RealArt.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF911DEE5C19B0D069418726 /* RealArt.swift */; };
3E143B39E0F97A669D2F6EFF /* ShellAdditionalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF3DBBE6BC067DDD34E3560C /* ShellAdditionalTests.swift */; };
44E0EBFDB9557A0C8BB741BE /* ShellUI in Frameworks */ = {isa = PBXBuildFile; productRef = 7F6858A53523100F9E10590E /* ShellUI */; };
4749F987D74B27CAA0E02480 /* ShellDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59E0A7AE45425C5BA9689FE4 /* ShellDemoApp.swift */; };
@@ -40,6 +41,7 @@
CEB77983EFFD9EA46FE3DFDF /* ShellDemoUITests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = ShellDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
D1591481D38DDC20A1A9B215 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
DF3DBBE6BC067DDD34E3560C /* ShellAdditionalTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellAdditionalTests.swift; sourceTree = "<group>"; };
+ FF911DEE5C19B0D069418726 /* RealArt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealArt.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -66,6 +68,7 @@
isa = PBXGroup;
children = (
779E0E026682ED6CDDF647C6 /* DemoControllerInput.swift */,
+ FF911DEE5C19B0D069418726 /* RealArt.swift */,
39DB78D11BCF59879A3712F5 /* SampleArt.swift */,
CBE23919FFDC3D06EF0D3065 /* SampleData.swift */,
59E0A7AE45425C5BA9689FE4 /* ShellDemoApp.swift */,
@@ -208,6 +211,7 @@
buildActionMask = 2147483647;
files = (
E305EAC2B52CE23FC907C7C7 /* DemoControllerInput.swift in Sources */,
+ 2EEF6A8F9A7D58C09181EAB5 /* RealArt.swift in Sources */,
D94D715334EE4F5E0CCBA788 /* SampleArt.swift in Sources */,
E71FEFEAE303CA4343BBDE2E /* SampleData.swift in Sources */,
4749F987D74B27CAA0E02480 /* ShellDemoApp.swift in Sources */,
diff --git a/frontend-ios/README.md b/frontend-ios/README.md
index c9e5bffb..b0dcef02 100644
--- a/frontend-ios/README.md
+++ b/frontend-ios/README.md
@@ -23,8 +23,8 @@ xcodebuild -project frontend-ios/Demo/ShellDemo.xcodeproj -scheme ShellDemo \
All boundary types are in `Sources/ShellUI/ShellInputs.swift` and `ShellArtwork.swift`:
-- `GameTile` and `GameDetail`: title, a short subtitle, the cover, optional wider hero art, state, recent-play text, settings, game-data source, cloud saves and additional content.
-- `Artwork`: a picture decoded once by the host, from the NACP icon's bytes (`Artwork(id:data:)`) or a `CGImage`. The views draw it and make their blurred backdrops from a small copy. Without one, a calm placeholder is drawn from the title.
+- `GameTile` and `GameDetail`: title, a short subtitle, the 16:9 banner, the optional square icon, state, recent-play text, settings, game-data source, cloud saves and additional content.
+- `Artwork`: a picture decoded once by the host, from file bytes (`Artwork(id:data:)`) or a `CGImage`. The banner is the game's 16:9 key art, the eShop banner the Mac launcher caches per title ID. Covers, Cover Flow cards and the hero all use it. Without a banner the square NACP icon is shown whole inside the 16:9 card on a blurred copy of itself, never stretched. Without either, a calm placeholder is drawn from the title.
- `GameState`: playable, needs game data, needs an app update, or broken with a reason.
- `SettingSection`, `SettingRow`, `SettingKind`, `SettingOption`: ordered toggle, choice and range rows with string values, as in launcher.json. The caller resolves dependencies, defaults and locked rows (`enabled`).
- `ControllerInfo`: a connected controller, its player and an optional battery level.
@@ -49,18 +49,20 @@ Only the available size decides, never the device model, idiom or orientation (`
| Size | Layout |
| --- | --- |
-| Compact, taller than wide (iPhone portrait, a folded foldable, Split View) | One column: the chosen game's art as a full-bleed hero with the title over it, a row of covers, recently played, Play and settings at the bottom for the thumb. Settings push over the library. |
-| Regular width and height, not wide (iPad portrait, an unfolded foldable held like a book) | Two panes: the same library with a cover grid and Play in the hero, settings inline beside it. |
-| Wider than tall (iPhone and iPad landscape, an unfolded foldable on its side) | Cover Flow over the blurred cover. Settings open as a panel on the right (regular) or over the library (compact). |
+| Compact, taller than wide (iPhone portrait, a folded foldable, Split View) | One column: the chosen game's banner edge to edge at the top, flowing into its blurred colour where the title sits, a row of wide cards, recently played, Play and settings at the bottom for the thumb. Settings push over the library. |
+| Regular width and height, not wide (iPad portrait, an unfolded foldable held like a book) | Two panes: the same library with a grid of wide cards and Play in the hero, settings inline beside it. |
+| Wider than tall (iPhone and iPad landscape, an unfolded foldable on its side) | Cover Flow over the blurred banner, wide cards in a calm deck. Settings open as a panel on the right (regular) or over the library (compact). |
The settings pane is one view in one place for every layout, so the selected game, open settings and both scroll positions survive a fold, a rotation or a Stage Manager resize.
-Controller first: the D-pad and stick move a cream focus ring, A activates, B backs out, X opens settings, Y opens controllers. In Cover Flow, left and right move the carousel by one cover and the focused cover is always the middle one. Keyboard arrows, Return and Escape take the same path. Touch and pointer use ordinary controls.
+Controller first: the D-pad and stick move a cream focus ring, A activates, B backs out, X opens settings, Y opens controllers. In Cover Flow, left and right move the carousel by one card and the focused card is always the middle one. Keyboard arrows, Return and Escape take the same path. Touch and pointer use ordinary controls.
Manrope and its SIL OFL licence are bundled and registered at runtime, with the system font as fallback. Reduce Motion turns the Cover Flow tilt and the slides into plain crossfades. Shell strings are in `Resources/Localizable.xcstrings`.
## Demo
-Seven fictional games with their own drawn cover art (`Sources/ShellDemo/SampleArt.swift`, rendered to images at launch so the views get them exactly as real icons). Launch arguments: `--screen library|settings|needs-data|needs-update|broken|empty|controllers|controllers-empty|focus`, `--games <n>`, `--select <id>`, `--input-test` (on-screen controller buttons) and `--fold-test` (the foldable stand-in: the running shell in a frame that switches between a 1.4:1 folded size and a larger unfolded one).
+Seven sample games. With `--real-art` the demo reads real Switch art at runtime from where the Mac launcher keeps it: the banner cache in the host's `~/Library/Application Support/NS Port Builder/artwork/<TITLEID>.jpg` and this checkout's `docs/images`, which the Simulator can read. `--art-dir <folder>` (repeatable) names other folders. A sample entry whose art is found becomes that real game (name and title ID in `SampleData.swift`). Without the files every entry stays fictional, with a square icon drawn in `SampleArt.swift`, so the demo and its tests work on any machine. No picture is part of this package, and `.gitignore` keeps them out.
-`UITests/` checks navigation, controller input, setting edits, rotation and the fold. `ShellCaptureTests` captures every screen. With `TEST_RUNNER_SHOT_DIR` set it also writes the PNGs to that folder.
+Other launch arguments: `--screen library|settings|needs-data|needs-update|broken|empty|controllers|controllers-empty|focus`, `--games <n>`, `--select <id>`, `--input-test` (on-screen controller buttons) and `--fold-test` (the foldable stand-in: the running shell in a frame that switches between a 1.4:1 folded size and a larger unfolded one, `--unfolded` to start open).
+
+`UITests/` checks navigation, controller input, setting edits, rotation and the fold. `ShellCaptureTests` captures every screen. With `TEST_RUNNER_SHOT_DIR` set it also writes the PNGs to that folder, and `TEST_RUNNER_SHOT_REAL_ART=1` launches the demo with `--real-art`.
diff --git a/frontend-ios/Sources/ShellDemo/RealArt.swift b/frontend-ios/Sources/ShellDemo/RealArt.swift
new file mode 100644
index 00000000..3016d933
--- /dev/null
+++ b/frontend-ios/Sources/ShellDemo/RealArt.swift
@@ -0,0 +1,60 @@
+import Foundation
+import ShellUI
+
+/// A real game a sample entry stands for when its art is on this machine: its name, title ID and the file name of
+/// its picture in the repository's docs/images.
+struct RealTitle {
+ let title: String
+ let titleID: String
+ let docsImage: String
+ init(_ title: String, _ titleID: String, _ docsImage: String) {
+ self.title = title
+ self.titleID = titleID
+ self.docsImage = docsImage
+ }
+}
+
+/// Real Switch art for the demo, read at runtime from where the Mac launcher keeps it and never from this package:
+/// the eShop banner cache (`<TITLEID>.jpg`) and the repository's docs/images. Nothing is copied into the app.
+///
+/// `--art-dir <folder>` (repeatable) names the folders. `--real-art` uses the Mac launcher's cache in the host's home
+/// and this checkout's docs/images, which the Simulator can read. Without either, every sample stays fictional.
+enum RealArt {
+ static let folders: [URL] = {
+ let args = ProcessInfo.processInfo.arguments
+ var folders = args.indices.filter { args[$0] == "--art-dir" && args.indices.contains($0 + 1) }.map { URL(fileURLWithPath: args[$0 + 1]) }
+ if args.contains("--real-art") {
+ let env = ProcessInfo.processInfo.environment
+ let home = env["SIMULATOR_HOST_HOME"] ?? NSHomeDirectory()
+ folders.append(URL(fileURLWithPath: home).appendingPathComponent("Library/Application Support/NS Port Builder/artwork"))
+ // This file is frontend-ios/Sources/ShellDemo/RealArt.swift: four levels up is the checkout.
+ let repo = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent()
+ .deletingLastPathComponent().deletingLastPathComponent()
+ folders.append(repo.appendingPathComponent("docs/images"))
+ }
+ return folders
+ }()
+
+ /// The title's banner, else its docs/images picture, from the first folder that has one.
+ static func banner(for title: RealTitle) -> Artwork? {
+ for name in [title.titleID.uppercased() + ".jpg", title.docsImage] {
+ for folder in folders {
+ let url = folder.appendingPathComponent(name)
+ if let data = try? Data(contentsOf: url), let art = Artwork(id: "real.\(name)", data: data) { return art }
+ }
+ }
+ return nil
+ }
+}
+
+extension SampleArt {
+ /// A sample game: the real title with its banner when the art is found, else the fictional one with its drawn icon.
+ static func tile(_ id: String, title: String, version: String, real: RealTitle?, state: GameState = .playable,
+ recentlyPlayed: String? = nil) -> GameTile {
+ let subtitle = demoText("Version \(version)")
+ if let real, let banner = RealArt.banner(for: real) {
+ return GameTile(id: id, title: real.title, subtitle: subtitle, banner: banner, state: state, recentlyPlayed: recentlyPlayed)
+ }
+ return GameTile(id: id, title: title, subtitle: subtitle, icon: icon(id), state: state, recentlyPlayed: recentlyPlayed)
+ }
+}
diff --git a/frontend-ios/Sources/ShellDemo/Resources/Localizable.xcstrings b/frontend-ios/Sources/ShellDemo/Resources/Localizable.xcstrings
index ccbe8a07..9a9cd316 100644
--- a/frontend-ios/Sources/ShellDemo/Resources/Localizable.xcstrings
+++ b/frontend-ios/Sources/ShellDemo/Resources/Localizable.xcstrings
@@ -381,72 +381,12 @@
}
}
},
- "Version 1.0.0": {
+ "Version %@": {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
- "value": "Version 1.0.0"
- }
- }
- }
- },
- "Version 1.0.2": {
- "localizations": {
- "en": {
- "stringUnit": {
- "state": "translated",
- "value": "Version 1.0.2"
- }
- }
- }
- },
- "Version 1.1.0": {
- "localizations": {
- "en": {
- "stringUnit": {
- "state": "translated",
- "value": "Version 1.1.0"
- }
- }
- }
- },
- "Version 1.2.0": {
- "localizations": {
- "en": {
- "stringUnit": {
- "state": "translated",
- "value": "Version 1.2.0"
- }
- }
- }
- },
- "Version 1.4.0": {
- "localizations": {
- "en": {
- "stringUnit": {
- "state": "translated",
- "value": "Version 1.4.0"
- }
- }
- }
- },
- "Version 2.0.1": {
- "localizations": {
- "en": {
- "stringUnit": {
- "state": "translated",
- "value": "Version 2.0.1"
- }
- }
- }
- },
- "Version 3.1.0": {
- "localizations": {
- "en": {
- "stringUnit": {
- "state": "translated",
- "value": "Version 3.1.0"
+ "value": "Version %@"
}
}
}
diff --git a/frontend-ios/Sources/ShellDemo/SampleArt.swift b/frontend-ios/Sources/ShellDemo/SampleArt.swift
index 988b640d..9b4bf131 100644
--- a/frontend-ios/Sources/ShellDemo/SampleArt.swift
+++ b/frontend-ios/Sources/ShellDemo/SampleArt.swift
@@ -1,16 +1,14 @@
import SwiftUI
import ShellUI
-/// Cover art for the fictional sample games, drawn here and rendered to images at launch. The views receive them
-/// exactly as they will receive a real game's icon. Each game has its own palette, composition and lettering, so the
+/// Square icons for the fictional sample games, drawn here and rendered to images at launch. The views receive them
+/// exactly as they will receive a real game's NACP icon, the fallback when a game has no banner. Each game has its own palette, composition and lettering, so the
/// library reads as a shelf of different games. Nothing here is taken from a real game.
@MainActor enum SampleArt {
private static var cache: [String: Artwork] = [:]
/// The square icon, with the game's lettering, as a NACP icon has it.
- static func cover(_ id: String) -> Artwork? { render(id, lettering: true) }
- /// Key art: the same picture without lettering, for the hero.
- static func keyArt(_ id: String) -> Artwork? { render(id, lettering: false) }
+ static func icon(_ id: String) -> Artwork? { render(id, lettering: true) }
private static func render(_ id: String, lettering: Bool) -> Artwork? {
let key = "\(id).\(lettering)"
@@ -38,7 +36,7 @@ import ShellUI
}
}
-/// Off for the key art: the same picture without the game's lettering, as a hero behind the shell's own title.
+/// The game's lettering in the picture. Always on for icons, kept switchable for previews of the bare art.
private struct LetteringKey: EnvironmentKey { static let defaultValue = true }
private extension EnvironmentValues {
var lettering: Bool {
diff --git a/frontend-ios/Sources/ShellDemo/SampleData.swift b/frontend-ios/Sources/ShellDemo/SampleData.swift
index 38d5f9fc..d220b66c 100644
--- a/frontend-ios/Sources/ShellDemo/SampleData.swift
+++ b/frontend-ios/Sources/ShellDemo/SampleData.swift
@@ -13,13 +13,19 @@ func demoText(_ key: String.LocalizationValue) -> String {
@MainActor enum SampleData {
static var games: [GameDetail] {
let tiles: [GameTile] = [
- GameTile(id: "orbit", title: "Orbit Valley", subtitle: demoText("Version 1.4.0"), cover: SampleArt.cover("orbit"), heroArt: SampleArt.keyArt("orbit"), recentlyPlayed: demoText("Played today")),
- GameTile(id: "tide", title: "The Quiet Tide", subtitle: demoText("Version 2.0.1"), cover: SampleArt.cover("tide"), heroArt: SampleArt.keyArt("tide"), recentlyPlayed: demoText("Played yesterday")),
- GameTile(id: "paper", title: "Paper Trails", subtitle: demoText("Version 1.0.0"), cover: SampleArt.cover("paper"), heroArt: SampleArt.keyArt("paper"), state: .needsGameData),
- GameTile(id: "moon", title: "Moonlit Express", subtitle: demoText("Version 3.1.0"), cover: SampleArt.cover("moon"), heroArt: SampleArt.keyArt("moon"), state: .needsAppUpdate),
- GameTile(id: "wild", title: "Wild Gardens", subtitle: demoText("Version 1.2.0"), cover: SampleArt.cover("wild"), heroArt: SampleArt.keyArt("wild"), state: .broken(reason: demoText("This game's bundled files could not be verified. Rebuild the app to restore them."))),
- GameTile(id: "drift", title: "Drift Atlas", subtitle: demoText("Version 1.1.0"), cover: SampleArt.cover("drift"), heroArt: SampleArt.keyArt("drift")),
- GameTile(id: "amber", title: "Amber Hours", subtitle: demoText("Version 1.0.2"), cover: SampleArt.cover("amber"))
+ SampleArt.tile("orbit", title: "Orbit Valley", version: "1.4.0", real: RealTitle("The Legend of Zelda: Breath of the Wild", "01007EF00011E000", "zelda-breath-of-the-wild.jpg"),
+ recentlyPlayed: demoText("Played today")),
+ SampleArt.tile("tide", title: "The Quiet Tide", version: "2.0.1", real: RealTitle("Hades", "0100535012974000", "hades.jpg"),
+ recentlyPlayed: demoText("Played yesterday")),
+ SampleArt.tile("paper", title: "Paper Trails", version: "1.0.0", real: RealTitle("The Legend of Zelda: Tears of the Kingdom", "0100F2C0115B6000", "zelda-tears-of-the-kingdom.jpg"),
+ state: .needsGameData),
+ SampleArt.tile("moon", title: "Moonlit Express", version: "3.1.0", real: RealTitle("Super Smash Bros. Ultimate", "01006A800016E000", "super-smash-bros-ultimate.jpg"),
+ state: .needsAppUpdate),
+ SampleArt.tile("wild", title: "Wild Gardens", version: "1.2.0", real: RealTitle("Batman: Arkham Knight", "0100ACD0163D0000", "batman-arkham-knight.jpg"),
+ state: .broken(reason: demoText("This game's bundled files could not be verified. Rebuild the app to restore them."))),
+ SampleArt.tile("drift", title: "Drift Atlas", version: "1.1.0", real: RealTitle("Celeste", "01002B30028F6000", "celeste.jpg")),
+ // Always fictional: the icon-only fallback, a square icon inside a wide card.
+ SampleArt.tile("amber", title: "Amber Hours", version: "1.0.2", real: nil)
]
return tiles.map { tile in
GameDetail(game: tile, sections: [
diff --git a/frontend-ios/Sources/ShellUI/CoverFlowView.swift b/frontend-ios/Sources/ShellUI/CoverFlowView.swift
index 45f8d008..7bd4898b 100644
--- a/frontend-ios/Sources/ShellUI/CoverFlowView.swift
+++ b/frontend-ios/Sources/ShellUI/CoverFlowView.swift
@@ -21,14 +21,16 @@ struct CoverFlowView: View {
var body: some View {
GeometryReader { geometry in
let short = geometry.size.height < 520
- // The cover takes what the height allows, and never so much that no neighbour shows.
- let cover = max(110, min(geometry.size.height * (short ? 0.50 : 0.44), geometry.size.width * 0.34, 400))
+ // A wide card as large as the Mac console's focused tile: what the height allows, never so wide that the
+ // neighbours vanish.
+ let cardHeight = max(90, min(geometry.size.height * (short ? 0.5 : 0.42), geometry.size.width * 0.52 * 9 / 16))
+ let cover = cardHeight * 16 / 9
VStack(spacing: 0) {
topBar.padding(.horizontal, 24).padding(.top, short ? 4 : 16)
Spacer(minLength: short ? 4 : 12)
Group {
- if games.count <= 3 { shelf(cover: cover) } else { carousel(width: geometry.size.width, cover: cover) }
- }.frame(height: cover * 1.04)
+ if games.count <= 3 { shelf(width: geometry.size.width, cover: cover) } else { carousel(width: geometry.size.width, cover: cover) }
+ }.frame(height: cover * 9 / 16 * 1.06)
info(short: short, width: geometry.size.width)
.padding(.top, short ? 14 : 28).padding(.horizontal, 24)
Spacer(minLength: short ? 4 : 12)
@@ -61,9 +63,10 @@ struct CoverFlowView: View {
}
private var position: Int { (games.firstIndex { $0.id == selected.id } ?? 0) + 1 }
- /// More than three games: a snapping carousel with the neighbours turned toward the middle.
+ /// More than three games: a snapping carousel. The neighbours turn back a little and tuck behind the middle card,
+ /// a deck rather than a row, which suits wide banners better than the steep turn of square covers.
private func carousel(width: CGFloat, cover: CGFloat) -> some View {
- let spacing = cover * 0.06
+ let spacing = cover * 0.04
let stride = cover + spacing
return ScrollView(.horizontal) {
LazyHStack(spacing: spacing) {
@@ -94,14 +97,18 @@ struct CoverFlowView: View {
.scrollClipDisabled()
}
- /// One to three games: they sit together in the middle, the chosen one larger. No empty track.
- private func shelf(cover: CGFloat) -> some View {
- HStack(spacing: cover * 0.12) {
- ForEach(games) { detail in
- let chosen = detail.id == selected.id
- coverButton(detail, cover: cover)
+ /// One to three games: they sit together in the middle, the chosen one in front and larger. No empty track.
+ private func shelf(width: CGFloat, cover: CGFloat) -> some View {
+ let card = min(cover, width / (1 + CGFloat(games.count - 1) * 0.8))
+ let chosenIndex = games.firstIndex { $0.id == selected.id } ?? 0
+ return ZStack {
+ ForEach(Array(games.enumerated()), id: \.element.id) { index, detail in
+ let chosen = index == chosenIndex
+ coverButton(detail, cover: card)
.scaleEffect(chosen ? 1 : 0.8)
- .brightness(chosen ? 0 : -0.18)
+ .brightness(chosen ? 0 : -0.22)
+ .offset(x: (CGFloat(index) - CGFloat(games.count - 1) / 2) * card * 0.78)
+ .zIndex(chosen ? 10 : -Double(abs(index - chosenIndex)))
}
}
.animation(reduceMotion ? nil : .smooth(duration: 0.3), value: selected.id)
@@ -115,12 +122,12 @@ struct CoverFlowView: View {
withAnimation(reduceMotion ? nil : .smooth(duration: 0.32)) { centredID = detail.id }
select(detail.id)
} label: {
- CoverView(game: detail.game, radius: cover * 0.06)
- .frame(width: cover, height: cover)
- .shadow(color: .black.opacity(0.45), radius: cover * 0.08, y: cover * 0.05)
+ CoverView(game: detail.game, radius: cover * 0.03)
+ .frame(width: cover, height: cover * 9 / 16)
+ .shadow(color: .black.opacity(0.5), radius: cover * 0.05, y: cover * 0.03)
}
.buttonStyle(.plain)
- .shellTarget("lib.tile.\(detail.id)", radius: cover * 0.06) { primary(detail) }
+ .shellTarget("lib.tile.\(detail.id)", radius: cover * 0.03) { primary(detail) }
.accessibilityLabel(detail.game.title + ", " + detail.game.state.title)
.accessibilityAddTraits(chosen ? .isSelected : [])
.accessibilityIdentifier("tile.\(detail.id)")
@@ -132,7 +139,7 @@ struct CoverFlowView: View {
// A phone on its side: one line of title and state beside the buttons, so the cover keeps the height.
HStack(spacing: 28) {
VStack(alignment: .leading, spacing: 5) {
- title(game, size: 22).lineLimit(1)
+ title(game, size: 20).lineLimit(2).minimumScaleFactor(0.85)
StatusLabel(state: game.state)
}.frame(maxWidth: min(340, width * 0.4), alignment: .leading).fixedSize(horizontal: true, vertical: true)
actions(game)
@@ -185,8 +192,8 @@ struct CoverFlowView: View {
}
}
-/// A cover's turn by its place: up to 40 degrees back, a little smaller and darker, the farther ones closer together.
-/// Reduced motion keeps them flat.
+/// A card's turn by its place: up to 24 degrees back, smaller and darker, pulled in behind its nearer neighbour.
+/// The nearer card is always drawn on top. Reduced motion keeps them flat.
private struct FlowTilt: ViewModifier {
let place: CGFloat
let cover: CGFloat
@@ -195,10 +202,11 @@ private struct FlowTilt: ViewModifier {
let near = max(-1, min(1, place))
let far = place > 1 ? place - 1 : place < -1 ? place + 1 : 0
content
- .rotation3DEffect(.degrees(flat ? 0 : -near * 40), axis: (x: 0, y: 1, z: 0), perspective: 0.45)
- .scaleEffect(1 - abs(near) * (flat ? 0.10 : 0.16))
- .offset(x: -near * cover * 0.10 - far * cover * (flat ? 0.2 : 0.34))
- .brightness(-abs(near) * 0.18)
+ .rotation3DEffect(.degrees(flat ? 0 : -near * 24), axis: (x: 0, y: 1, z: 0), perspective: 0.35)
+ .scaleEffect(1 - abs(near) * 0.22)
+ .offset(x: -near * cover * 0.28 - far * cover * 0.55)
+ .brightness(-abs(near) * 0.25 - min(abs(far), 1) * 0.1)
+ .zIndex(-Double(abs(place)))
}
}
@@ -209,7 +217,7 @@ struct CoverFlowBackdrop: View {
var body: some View {
ZStack {
ShellPalette.background
- ArtView(art: game.cover, title: game.title, seed: game.id, backdrop: true)
+ ArtView(game: game, backdrop: true)
.scaleEffect(1.3)
.blur(radius: 60, opaque: true)
.saturation(1.25)
diff --git a/frontend-ios/Sources/ShellUI/GameDetailView.swift b/frontend-ios/Sources/ShellUI/GameDetailView.swift
index 9a4f92a4..2fa54bb7 100644
--- a/frontend-ios/Sources/ShellUI/GameDetailView.swift
+++ b/frontend-ios/Sources/ShellUI/GameDetailView.swift
@@ -69,7 +69,7 @@ public struct GameDetailView: View {
private var header: some View {
VStack(alignment: .leading, spacing: 16) {
HStack(alignment: .center, spacing: 16) {
- CoverView(game: detail.game, radius: 10).frame(width: 64, height: 64)
+ CoverView(game: detail.game, radius: 8).frame(width: 112, height: 63)
VStack(alignment: .leading, spacing: 6) {
Text(detail.game.title).shellText(24, .heavy, relativeTo: .title).tracking(-0.6)
.fixedSize(horizontal: false, vertical: true)
diff --git a/frontend-ios/Sources/ShellUI/PortraitLibrary.swift b/frontend-ios/Sources/ShellUI/PortraitLibrary.swift
index 681b8a4c..655fa8f1 100644
--- a/frontend-ios/Sources/ShellUI/PortraitLibrary.swift
+++ b/frontend-ios/Sources/ShellUI/PortraitLibrary.swift
@@ -15,6 +15,9 @@ struct PortraitLibrary: View {
let openSettings: () -> Void
let openControllers: () -> Void
@Binding var position: ScrollPosition
+ @State private var rowID: String?
+ /// Set while the row itself chose the game, so it does not scroll under the finger.
+ @State private var rowSelecting = false
@Environment(\.shellFocus) private var focus
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@Environment(\.dynamicTypeSize) private var typeSize
@@ -22,25 +25,21 @@ struct PortraitLibrary: View {
/// A short screen (the folded foldable is about 1.4:1) gets a smaller hero and smaller covers, so the hero,
/// the row and Play all fit without scrolling.
private var short: Bool { size.height + topInset < 700 }
- private var heroHeight: CGFloat {
- let tall = size.height + topInset
- return twoPanes ? min(size.width * 0.95, tall * 0.5) : min(size.width * 1.02, tall * (short ? 0.44 : 0.52))
- }
- /// Whole covers and a third of the next one: the row shows it scrolls, and the edge cuts through a cover,
- /// never through a name or a status.
+ /// Whole cards only, the gap as wide as the margin: the next card starts exactly at the screen edge, so the edge
+ /// falls between cards and never through a name or a status. Long names end in an ellipsis inside their card.
private var coverSize: CGFloat {
- let target: CGFloat = typeSize.isAccessibilitySize ? 170 : short ? 100 : 128
- let available = size.width - 24
- let whole = max(1, ((available + 16) / (target + 16)).rounded(.down))
- return available / (whole + 0.34) - 16
+ let target: CGFloat = typeSize.isAccessibilitySize ? 300 : short ? 140 : 160
+ let available = size.width - 48
+ let count = max(1, ((available + 24) / (target + 24)).rounded(.down))
+ return (available - (count - 1) * 24) / count
}
var body: some View {
ScrollViewReader { proxy in
ScrollView {
VStack(alignment: .leading, spacing: 0) {
- HeroView(game: selected.game, height: heroHeight, topInset: topInset,
- titleSize: twoPanes ? 36 : short ? 28 : 34) {
+ HeroView(game: selected.game, width: size.width, topInset: topInset,
+ titleSize: twoPanes ? 34 : short ? 26 : 32) {
if twoPanes {
Button { primary(selected) } label: {
Label(selected.game.state.actionTitle, systemImage: selected.game.state.actionSymbol)
@@ -75,22 +74,26 @@ struct PortraitLibrary: View {
VStack(alignment: .leading, spacing: 14) {
SectionHeading(title: ShellStrings.text("Your games"), trailing: "\(games.count)").padding(.horizontal, 24)
if twoPanes {
- LazyVGrid(columns: [GridItem(.adaptive(minimum: 116, maximum: 180), spacing: 18, alignment: .top)],
+ LazyVGrid(columns: [GridItem(.adaptive(minimum: 170, maximum: 260), spacing: 18, alignment: .top)],
alignment: .leading, spacing: 24) {
ForEach(games) { tile($0) }
}.padding(.horizontal, 24)
} else {
ScrollView(.horizontal) {
// Not lazy: every cover is a focus target, so the D-pad can reach the ones still off screen.
- HStack(alignment: .top, spacing: 16) {
+ HStack(alignment: .top, spacing: 24) {
ForEach(games) { tile($0).frame(width: coverSize) }
- }.scrollTargetLayout().padding(.horizontal, 24).padding(.vertical, 6)
+ }.scrollTargetLayout().padding(.vertical, 6)
}
+ .contentMargins(.horizontal, 24, for: .scrollContent)
.scrollIndicators(.hidden)
.scrollTargetBehavior(.viewAligned)
- .mask {
- LinearGradient(stops: [.init(color: .black, location: 0), .init(color: .black, location: 0.92),
- .init(color: .black.opacity(0), location: 1)], startPoint: .leading, endPoint: .trailing)
+ .scrollPosition(id: $rowID, anchor: .leading)
+ // A game chosen elsewhere (at launch, in Recently played, after a fold) comes into view.
+ .onAppear { rowID = selected.id }
+ .onChange(of: selected.id) { _, id in
+ guard !rowSelecting else { rowSelecting = false; return }
+ withAnimation(reduceMotion ? nil : .smooth(duration: 0.3)) { rowID = id }
}
.padding(.vertical, -6)
}
@@ -99,7 +102,7 @@ struct PortraitLibrary: View {
private func tile(_ detail: GameDetail) -> some View {
let chosen = detail.id == selected.id
- return Button { select(detail.id) } label: {
+ return Button { rowSelecting = !chosen; select(detail.id) } label: {
VStack(alignment: .leading, spacing: 0) {
CoverView(game: detail.game)
.shellTarget("lib.tile.\(detail.id)") { primary(detail) }
@@ -126,7 +129,7 @@ struct PortraitLibrary: View {
ForEach(recent) { detail in
Button { select(detail.id) } label: {
HStack(spacing: 14) {
- CoverView(game: detail.game, radius: 8).frame(width: 44, height: 44)
+ CoverView(game: detail.game, radius: 6).frame(width: 78, height: 44)
VStack(alignment: .leading, spacing: 3) {
Text(detail.game.title).shellText(15, .semibold).multilineTextAlignment(.leading)
Text(detail.game.recentlyPlayed ?? "").shellText(12.5).foregroundStyle(.white.opacity(0.5))
@@ -139,7 +142,7 @@ struct PortraitLibrary: View {
.buttonStyle(.plain)
.shellTarget("lib.recent.\(detail.id)") { select(detail.id) }
.id("lib.recent.\(detail.id)")
- if detail.id != recent.last?.id { Rectangle().fill(ShellPalette.hairline).frame(height: 1).padding(.leading, 58) }
+ if detail.id != recent.last?.id { Rectangle().fill(ShellPalette.hairline).frame(height: 1).padding(.leading, 92) }
}
}.padding(.horizontal, 24)
}
@@ -170,21 +173,22 @@ struct PortraitLibrary: View {
}
}
-/// The chosen game's art edge to edge, darkened toward the type, with the state, the title and what to do next.
+/// The chosen game's banner, whole and edge to edge at the top, flowing into a blurred copy of itself where the
+/// state, the title and what to do next sit. The banner's own logo and the shell's title never overlap.
struct HeroView<Accessory: View>: View {
let game: GameTile
- let height: CGFloat
+ let width: CGFloat
let topInset: CGFloat
var titleSize: CGFloat = 34
@ViewBuilder let accessory: () -> Accessory
@Environment(\.accessibilityReduceMotion) private var reduceMotion
var body: some View {
+ let bannerHeight = width * 9 / 16
VStack(alignment: .leading, spacing: 10) {
StatusLabel(state: game.state, prominent: true)
Text(game.title).shellText(titleSize, .heavy, relativeTo: .largeTitle).tracking(-titleSize * 0.03)
.lineLimit(3).minimumScaleFactor(0.75).fixedSize(horizontal: false, vertical: true)
- .shadow(color: .black.opacity(0.35), radius: 14)
.accessibilityAddTraits(.isHeader).accessibilityIdentifier("hero.title")
if !meta.isEmpty {
Text(meta).shellText(13).foregroundStyle(.white.opacity(0.62))
@@ -195,35 +199,37 @@ struct HeroView<Accessory: View>: View {
}
accessory()
}
- .padding(.horizontal, 24).padding(.top, topInset + 64).padding(.bottom, 14)
- .frame(maxWidth: .infinity, minHeight: height, alignment: .bottomLeading)
+ .padding(.horizontal, 24)
+ .padding(.top, max(topInset, bannerHeight - 26))
+ .padding(.bottom, 18)
+ .frame(maxWidth: .infinity, alignment: .bottomLeading)
.background {
- ZStack {
- // Key art is made to sit behind a title. An icon carries its own lettering, which must not compete
- // with the shell's title: it is softened, enlarged and darkened further.
- ArtView(art: game.heroArt ?? game.cover, title: game.title, seed: game.id, lettering: false)
- .blur(radius: iconOnly ? 14 : 0, opaque: true)
- .scaleEffect(iconOnly ? 1.15 : 1)
- .overlay { if iconOnly { Color.black.opacity(0.22) } }
- .id(game.id).transition(.opacity)
- // Clear only in the upper part: the type below must win over whatever lettering the art has.
- LinearGradient(stops: [.init(color: .black.opacity(0.55), location: 0),
- .init(color: .clear, location: 0.2),
- .init(color: .clear, location: 0.32),
- .init(color: .black.opacity(0.55), location: 0.58),
- .init(color: ShellPalette.background.opacity(0.94), location: 0.82),
- .init(color: ShellPalette.background, location: 1)],
+ ZStack(alignment: .top) {
+ ArtView(game: game, backdrop: true)
+ .scaleEffect(1.4)
+ .blur(radius: 50, opaque: true)
+ .saturation(1.2)
+ .overlay(Color.black.opacity(0.35))
+ ArtView(game: game, lettering: false)
+ .frame(width: width, height: bannerHeight)
+ .mask {
+ LinearGradient(stops: [.init(color: .black, location: 0), .init(color: .black, location: 0.72),
+ .init(color: .clear, location: 1)], startPoint: .top, endPoint: .bottom)
+ }
+ LinearGradient(stops: [.init(color: .black.opacity(0.45), location: 0),
+ .init(color: .clear, location: min(0.3, (topInset + 40) / max(1, bannerHeight * 2)))],
+ startPoint: .top, endPoint: .bottom)
+ // The blurred colour settles into the page at the bottom edge.
+ LinearGradient(stops: [.init(color: .clear, location: 0.55), .init(color: ShellPalette.background, location: 1)],
startPoint: .top, endPoint: .bottom)
- LinearGradient(colors: [.black.opacity(0.28), .clear], startPoint: .leading, endPoint: .trailing)
}
+ .id(game.id).transition(.opacity)
.animation(reduceMotion ? .linear(duration: 0.15) : .easeInOut(duration: 0.35), value: game.id)
.accessibilityHidden(true)
}
.clipped()
}
- private var iconOnly: Bool { game.heroArt == nil && game.cover != nil }
-
private var meta: String {
[game.subtitle, game.recentlyPlayed ?? ""].filter { !$0.isEmpty }.joined(separator: " · ")
}
diff --git a/frontend-ios/Sources/ShellUI/ShellArtwork.swift b/frontend-ios/Sources/ShellUI/ShellArtwork.swift
index cd82e79c..13cc2182 100644
--- a/frontend-ios/Sources/ShellUI/ShellArtwork.swift
+++ b/frontend-ios/Sources/ShellUI/ShellArtwork.swift
@@ -2,7 +2,7 @@ import CoreGraphics
import Foundation
import ImageIO
-/// A game's picture, decoded once by the host: the square NACP icon, or wider key art when there is some.
+/// A game's picture, decoded once by the host: the 16:9 key art (the eShop banner) or the square NACP icon.
/// The views only draw it. A tiny copy and the mean colour are made here, so the blurred backgrounds stay cheap.
public struct Artwork: Equatable, @unchecked Sendable {
public let id: String
diff --git a/frontend-ios/Sources/ShellUI/ShellInputs.swift b/frontend-ios/Sources/ShellUI/ShellInputs.swift
index ec23aaef..da73fb20 100644
--- a/frontend-ios/Sources/ShellUI/ShellInputs.swift
+++ b/frontend-ios/Sources/ShellUI/ShellInputs.swift
@@ -13,20 +13,20 @@ public struct GameTile: Identifiable, Equatable, Sendable {
public var title: String
/// One short line under the title, such as the version.
public var subtitle: String
- /// The square cover, normally the game's NACP icon. Nil draws a calm placeholder from the title.
- public var cover: Artwork?
- /// Wider key art for the hero, when the game data has some. Nil uses the cover.
- public var heroArt: Artwork?
+ /// The game's 16:9 key art, such as its eShop banner. Covers, Cover Flow cards and the hero all use it.
+ public var banner: Artwork?
+ /// The square NACP icon. Only a fallback without a banner: shown whole inside a 16:9 card, never stretched.
+ public var icon: Artwork?
public var state: GameState
/// Already localized, such as "Played today". Nil leaves the game out of Recently played.
public var recentlyPlayed: String?
- public init(id: String, title: String, subtitle: String = "", cover: Artwork? = nil, heroArt: Artwork? = nil,
+ public init(id: String, title: String, subtitle: String = "", banner: Artwork? = nil, icon: Artwork? = nil,
state: GameState = .playable, recentlyPlayed: String? = nil) {
self.id = id
self.title = title
self.subtitle = subtitle
- self.cover = cover
- self.heroArt = heroArt
+ self.banner = banner
+ self.icon = icon
self.state = state
self.recentlyPlayed = recentlyPlayed
}
diff --git a/frontend-ios/Sources/ShellUI/ShellStyle.swift b/frontend-ios/Sources/ShellUI/ShellStyle.swift
index 13a33313..5740438a 100644
--- a/frontend-ios/Sources/ShellUI/ShellStyle.swift
+++ b/frontend-ios/Sources/ShellUI/ShellStyle.swift
@@ -139,27 +139,54 @@ struct CreamToggleStyle: ToggleStyle {
}
}
-/// A game's picture filling whatever frame it gets, or the placeholder when there is none.
+/// A game's picture filling whatever frame it gets: the banner, else the icon whole on a blurred copy of itself,
+/// else the placeholder.
struct ArtView: View {
- let art: Artwork?
- let title: String
- let seed: String
+ let game: GameTile
/// Draw from the small copy, for a backdrop that is blurred anyway.
var backdrop = false
/// The placeholder's lettering. Off where the title is set beside the art already, as in the hero.
var lettering = true
var body: some View {
Color.clear.overlay {
- if let art {
- Image(decorative: backdrop ? art.thumbnail : art.image, scale: 1)
+ if let banner = game.banner {
+ Image(decorative: backdrop ? banner.thumbnail : banner.image, scale: 1)
.resizable().interpolation(backdrop ? .medium : .high).scaledToFill()
+ } else if let icon = game.icon {
+ if backdrop {
+ Image(decorative: icon.thumbnail, scale: 1).resizable().scaledToFill()
+ } else {
+ IconCard(icon: icon)
+ }
} else {
- PlaceholderArt(title: title, seed: seed, lettering: lettering && !backdrop)
+ PlaceholderArt(title: game.title, seed: game.id, lettering: lettering && !backdrop)
}
}.clipped()
}
}
+/// A square icon in a wide frame: whole and sharp in the middle, on a blurred and darkened copy of itself.
+private struct IconCard: View {
+ let icon: Artwork
+ var body: some View {
+ GeometryReader { geometry in
+ let side = min(geometry.size.height * 0.74, geometry.size.width * 0.74)
+ ZStack {
+ Image(decorative: icon.thumbnail, scale: 1).resizable().interpolation(.medium).scaledToFill()
+ .frame(width: geometry.size.width, height: geometry.size.height)
+ .blur(radius: max(8, geometry.size.height * 0.14), opaque: true)
+ .saturation(1.15)
+ .overlay(Color.black.opacity(0.3))
+ Image(decorative: icon.image, scale: 1).resizable().interpolation(.high).scaledToFit()
+ .frame(width: side, height: side)
+ .clipShape(RoundedRectangle(cornerRadius: side * 0.1))
+ .shadow(color: .black.opacity(0.35), radius: side * 0.06, y: side * 0.03)
+ }
+ .frame(width: geometry.size.width, height: geometry.size.height)
+ }
+ }
+}
+
/// For a game without a picture: a deep tone from its name, a soft disc and the title set like a book cover.
/// It has to read as a deliberate cover, not as missing data.
struct PlaceholderArt: View {
@@ -176,26 +203,26 @@ struct PlaceholderArt: View {
Color(hue: hue, saturation: 0.55, brightness: 0.13)],
startPoint: .topTrailing, endPoint: .bottomLeading)
Circle().fill(Color(hue: hue, saturation: 0.30, brightness: 0.62).opacity(0.30))
- .frame(width: side * 0.95, height: side * 0.95)
- .position(x: geometry.size.width * 0.78, y: geometry.size.height * 0.24)
+ .frame(width: side * 1.1, height: side * 1.1)
+ .position(x: geometry.size.width * 0.8, y: geometry.size.height * 0.22)
if lettering {
- Text(title).font(ShellFonts.fixed(max(9, side * 0.12), weight: .heavy)).tracking(-side * 0.003)
+ Text(title).font(ShellFonts.fixed(max(9, side * 0.16), weight: .heavy)).tracking(-side * 0.004)
.foregroundStyle(ShellPalette.cream.opacity(0.92))
- .lineLimit(3).minimumScaleFactor(0.5).multilineTextAlignment(.leading)
- .padding(side * 0.09)
+ .lineLimit(2).minimumScaleFactor(0.5).multilineTextAlignment(.leading)
+ .padding(side * 0.11)
}
}
}
}
}
-/// A square cover with the hairline every picture gets, so dark art keeps its edge on the dark page.
+/// A 16:9 card with the hairline every picture gets, so dark art keeps its edge on the dark page.
struct CoverView: View {
let game: GameTile
- var radius: CGFloat = 12
+ var radius: CGFloat = 10
var body: some View {
- ArtView(art: game.cover, title: game.title, seed: game.id)
- .aspectRatio(1, contentMode: .fit)
+ ArtView(game: game)
+ .aspectRatio(16 / 9, contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: radius))
.overlay(RoundedRectangle(cornerRadius: radius).strokeBorder(.white.opacity(0.10)))
.accessibilityHidden(true)
diff --git a/frontend-ios/UITests/ShellCaptureTests.swift b/frontend-ios/UITests/ShellCaptureTests.swift
index ba27a258..9556ade7 100644
--- a/frontend-ios/UITests/ShellCaptureTests.swift
+++ b/frontend-ios/UITests/ShellCaptureTests.swift
@@ -19,7 +19,8 @@ import XCTest
}
private func launch(_ arguments: [String]) {
app.terminate()
- app.launchArguments = arguments
+ // TEST_RUNNER_SHOT_REAL_ART=1: the demo reads real game art from the host (see RealArt.swift).
+ app.launchArguments = arguments + ((ProcessInfo.processInfo.environment["SHOT_REAL_ART"] ?? "").isEmpty ? [] : ["--real-art"])
app.launch()
_ = app.buttons["controllers.open"].firstMatch.waitForExistence(timeout: 10)
|| app.buttons["controllers.close"].waitForExistence(timeout: 2)