Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Library: the hero takes what the collection row leaves, so the cards fit in fullscreen
v0lumehibac3a2936f9e
diff --git a/frontend/Sources/NSPortBuilder/LauncherView.swift b/frontend/Sources/NSPortBuilder/LauncherView.swiftindex 0da50194..5cbd6e60 100644--- a/frontend/Sources/NSPortBuilder/LauncherView.swift+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift@@ -216,6 +216,9 @@ struct ContentView: View {withAnimation(.easeOut(duration: 0.2)) { searching = false }}+ /// The collection row's measured height (CollectionHeightKey); the hero above it takes the rest of the page.+ @State private var collectionHeight: CGFloat = 274+private var libraryPage: some View {GeometryReader { geometry inif library.games.isEmpty {@@ -224,11 +227,15 @@ struct ContentView: View {ScrollView {VStack(alignment: .leading, spacing: 0) {if let game = library.selected {- hero(game, width: geometry.size.width, height: max(240, geometry.size.height - 274))+ hero(game, width: geometry.size.width, height: max(240, geometry.size.height - collectionHeight))}+ // The hero takes what the collection leaves: the row's height grows with the window's width (its cards+ // do, up to 300 pt), so a fixed share left a fullscreen window's cards cut off at the bottomcollection(width: geometry.size.width)+ .background(GeometryReader { g in Color.clear.preference(key: CollectionHeightKey.self, value: g.size.height) })}}+ .onPreferenceChange(CollectionHeightKey.self) { h in if h > 0, abs(h - collectionHeight) > 0.5 { collectionHeight = h } }}}}@@ -683,3 +690,9 @@ private struct EnclosingScrollView: NSViewRepresentable {DispatchQueue.main.async { if let view = probe.enclosingScrollView { row.attach(view) } }}}++/// The library's collection row reports its height, so the hero above it fills exactly what is left.+private struct CollectionHeightKey: PreferenceKey {+ static var defaultValue: CGFloat = 0+ static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { value = max(value, nextValue()) }+}diff --git a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift b/frontend/Tests/NSPortBuilderTests/LibraryTests.swiftindex 2d47100c..5904319c 100644--- a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift+++ b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift@@ -656,6 +656,7 @@ final class LibraryTests: XCTestCase {try capture("library")try capture("library-search", search: "zel")try capture("library-small", width: 900, height: 680)+ try capture("library-fullscreen", width: 2000, height: 1125) // the cards at their widest: the row must fit under the herotry capture("empty", empty: true)try capture("build", page: .builds)try capture("build-small", width: 900, height: 680, page: .builds)