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: a tap on a Recently played game starts it, and the rows get more space (#425)

v0lumehi19e6c1e64d28
diff --git a/frontend-ios/Sources/ShellUI/PortraitLibrary.swift b/frontend-ios/Sources/ShellUI/PortraitLibrary.swift
index 73d68ea6..84d3766e 100644
--- a/frontend-ios/Sources/ShellUI/PortraitLibrary.swift
+++ b/frontend-ios/Sources/ShellUI/PortraitLibrary.swift
@@ -1,5 +1,13 @@
import SwiftUI
+/// A Recently played row starts its game, or opens the same fix as Play (game data, an app update).
+enum RecentRow {
+ /// Space above and below the hairline between two rows, so a title never touches it.
+ static let separatorGap: CGFloat = 10
+ static let minHeight: CGFloat = 60
+ static func glyph(_ state: GameState) -> String { state.actionSymbol }
+}
+
/// The library when it is taller than it is wide: the chosen game's banner as the hero with the title under it,
/// then the collection, then recently played. In one column the primary action sits at the bottom for the thumb.
/// With regular width (an iPad or an unfolded foldable held upright) the collection becomes a grid of wide cards and
@@ -154,7 +162,7 @@ struct PortraitLibrary: View, Equatable {
VStack(alignment: .leading, spacing: 0) {
SectionHeading(title: ShellStrings.text("Recently played")).padding(.bottom, 8)
ForEach(recent) { detail in
- Button { select(detail.id) } label: {
+ Button { primary(detail) } label: {
HStack(spacing: 14) {
CoverView(game: detail.game, radius: 6).frame(width: 78, height: 44)
VStack(alignment: .leading, spacing: 3) {
@@ -162,14 +170,19 @@ struct PortraitLibrary: View, Equatable {
Text(detail.game.recentlyPlayed ?? "").shellText(12.5).foregroundStyle(.white.opacity(0.5))
}
Spacer(minLength: 8)
- Image(systemName: "chevron.right").font(.system(size: 12, weight: .semibold))
- .foregroundStyle(.white.opacity(0.28)).accessibilityHidden(true)
- }.frame(minHeight: 60).contentShape(Rectangle())
+ // The glyph of what the row does: the same one Play wears for this game's state.
+ Image(systemName: RecentRow.glyph(detail.game.state)).font(.system(size: 13, weight: .semibold))
+ .foregroundStyle(.white.opacity(0.5)).accessibilityHidden(true)
+ }.frame(minHeight: RecentRow.minHeight).contentShape(Rectangle())
}
.buttonStyle(.plain)
- .shellTarget("lib.recent.\(detail.id)") { select(detail.id) }
+ .accessibilityLabel(detail.game.state.actionTitle + ", " + detail.game.title)
+ .shellTarget("lib.recent.\(detail.id)") { primary(detail) }
.id("lib.recent.\(detail.id)")
- if detail.id != recent.last?.id { Rectangle().fill(ShellPalette.hairline).frame(height: 1).padding(.leading, 92) }
+ if detail.id != recent.last?.id {
+ Rectangle().fill(ShellPalette.hairline).frame(height: 1).padding(.leading, 92)
+ .padding(.vertical, RecentRow.separatorGap)
+ }
}
}.padding(.horizontal, 24)
}
diff --git a/frontend-ios/Tests/ShellUITests/RecentRowTests.swift b/frontend-ios/Tests/ShellUITests/RecentRowTests.swift
new file mode 100644
index 00000000..5306cf57
--- /dev/null
+++ b/frontend-ios/Tests/ShellUITests/RecentRowTests.swift
@@ -0,0 +1,17 @@
+import Testing
+@testable import ShellUI
+
+@Suite struct RecentRowTests {
+ /// The row does what Play does, so it wears Play's glyph for every state and never a chevron.
+ @Test func glyphMatchesTheAction() {
+ for state in [GameState.playable, .needsGameData, .needsAppUpdate, .broken(reason: "x")] {
+ #expect(RecentRow.glyph(state) == state.actionSymbol)
+ #expect(RecentRow.glyph(state) != "chevron.right")
+ }
+ }
+
+ @Test func hairlineHasSpaceAndRowKeepsItsHeight() {
+ #expect(RecentRow.separatorGap == 10)
+ #expect(RecentRow.minHeight == 60)
+ }
+}