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
Move the Library page out of LauncherView.swift
v0lumehi69da9a72a21f
diff --git a/frontend/ARCHITECTURE.md b/frontend/ARCHITECTURE.mdindex ee071821..7ee855a2 100644--- a/frontend/ARCHITECTURE.md+++ b/frontend/ARCHITECTURE.md@@ -80,7 +80,7 @@ A view observes only the stores it shows. A change in one store invalidates only## File size-No Swift file under `frontend/Sources` is above 800 lines. `SourceSizeTests` fails otherwise. The files that are above it today are listed in that test with their size, and they may only shrink. When one drops to 800 lines or fewer, remove its entry.+No Swift file under `frontend/Sources` is above 800 lines. `SourceSizeTests` fails otherwise. No file is above it today, so `SourceSizeTests.aboveTheLimit` is empty. A file that cannot be split gets an entry there with its size, and it may only shrink. `LauncherView.swift` was the last one: its Library page (the hero, the collection row and the status line) moved to `LauncherView+Library.swift` as an extension, and `LauncherPage` and `LibraryFilter` moved to `LauncherPage.swift`. The state stays in `LauncherView`, so a member the extension reads is internal, not private.## Names that staydiff --git a/frontend/Sources/NX2Apple/LauncherPage.swift b/frontend/Sources/NX2Apple/LauncherPage.swiftnew file mode 100644index 00000000..2092d636--- /dev/null+++ b/frontend/Sources/NX2Apple/LauncherPage.swift@@ -0,0 +1,38 @@+import SwiftUI+import NXCore++enum LauncherPage: String, CaseIterable {+ case library, builds, settings+ var symbol: String {+ switch self {+ case .library: return "gamecontroller"+ case .builds: return "shippingbox"+ case .settings: return "slider.horizontal.3"+ }+ }+}++/// The library's filter: every game in the games folder, or only those with a build. Remembered between launches.+enum LibraryFilter: String, CaseIterable, Identifiable {+ case owned, built+ var id: String { rawValue }+ var labelKey: String { "filter." + rawValue }++ /// Owned shows every game without reading its build, so the default filter costs nothing per card.+ func includes(_ game: LibraryGame) -> Bool { self == .owned || game.isReady || game.hasIOSBuild }++ static func load(_ defaults: UserDefaults = .standard) -> LibraryFilter {+ LibraryFilter(rawValue: defaults.string(forKey: "libraryFilter") ?? "") ?? .owned+ }+ func save(_ defaults: UserDefaults = .standard) { defaults.set(rawValue, forKey: "libraryFilter") }++ /// The selection and the controller's focus after a switch to this filter. A selected game the filter hides gives way to the+ /// first one it shows, and a focus on a hidden card is dropped, so neither the hero nor the A button reaches a game that is not+ /// on screen.+ func reconcile(games: [LibraryGame], selectedID: UUID?, focused: String?) -> (selectedID: UUID?, focused: String?) {+ let shown = games.filter(includes)+ let selection = shown.contains { $0.id == selectedID } ? selectedID : shown.first?.id+ guard let focused, focused.hasPrefix("card.") else { return (selection, focused) }+ return (selection, shown.contains { "card." + $0.id.uuidString == focused } ? focused : nil)+ }+}diff --git a/frontend/Sources/NX2Apple/LauncherView+Library.swift b/frontend/Sources/NX2Apple/LauncherView+Library.swiftnew file mode 100644index 00000000..39a47c4d--- /dev/null+++ b/frontend/Sources/NX2Apple/LauncherView+Library.swift@@ -0,0 +1,259 @@+import SwiftUI+import NXCore+import NXModel+import NXLauncher++/// The Library page of the launcher: the hero, the collection row and the status line of a game. A move out of LauncherView.swift+/// (LNPANDY/NX2Apple#387), the state stays in LauncherView.+extension LauncherView {+ var libraryPage: some View {+ GeometryReader { geometry in+ if library.games.isEmpty {+ emptyLibrary+ } else {+ ScrollView {+ VStack(alignment: .leading, spacing: 0) {+ if let game = heroGame {+ 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 bottom+ collection(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 } }+ }+ }+ }++ var emptyLibrary: some View {+ VStack(alignment: .leading, spacing: 22) {+ Spacer()+ Image(systemName: "gamecontroller").font(.system(size: 44, weight: .light))+ .foregroundStyle(LauncherPalette.cream)+ Text(loc.t("library.welcome")).font(.manrope(54, .bold)).tracking(-1.8)+ Text(loc.t("library.welcomeNote")).font(.manrope(17)).foregroundStyle(.secondary)+ .frame(maxWidth: 490, alignment: .leading).fixedSize(horizontal: false, vertical: true)+ Button { newBuild() } label: {+ Label(loc.t("library.firstBuild"), systemImage: "plus")+ .font(.manrope(16, .semibold))+ .padding(.horizontal, 24).padding(.vertical, 15)+ .foregroundStyle(.black).background(LauncherPalette.cream, in: Capsule())+ }+ .buttonStyle(.plain).padding(.top, 8)+ Button(action: chooseLibraryFolder) {+ Label(loc.t("library.chooseFolder"), systemImage: "folder")+ .font(.manrope(14)).foregroundStyle(.secondary)+ }.buttonStyle(.plain)+ Spacer()+ Text(loc.t("library.localNote")).font(.manrope(12)).foregroundStyle(.secondary)+ }+ .padding(48).frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)+ }++ func hero(_ game: LibraryGame, width: CGFloat, height: CGFloat) -> some View {+ ZStack(alignment: .bottomLeading) {+ if let image = artwork[game.id] {+ Image(nsImage: image).resizable().scaledToFill()+ .frame(width: width, height: height).clipped()+ } else {+ LauncherPalette.surface+ Image(systemName: "gamecontroller").font(.system(size: 160, weight: .ultraLight))+ .foregroundStyle(Color.white.opacity(0.05))+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing).padding(60)+ }+ LinearGradient(stops: [.init(color: .clear, location: 0.25),+ .init(color: .black.opacity(0.25), location: 0.45),+ .init(color: LauncherPalette.background, location: 1)],+ startPoint: .top, endPoint: .bottom)+ LinearGradient(colors: [.black.opacity(0.24), .clear], startPoint: .leading, endPoint: .trailing)+ VStack(alignment: .leading, spacing: 14) {+ HStack(spacing: 14) {+ status(game, prominent: true)+ if toolsAge.older.contains(game.id) && !(m.running && activeBuildID == game.id) {+ Button { configureBuild(game) } label: {+ Label(loc.t("library.rebuildShort"), systemImage: "arrow.clockwise")+ .font(.manrope(12, .semibold)).foregroundStyle(LauncherPalette.cream)+ .padding(.horizontal, 10).padding(.vertical, 4)+ .overlay(Capsule().strokeBorder(LauncherPalette.cream.opacity(0.35)))+ .contentShape(Capsule())+ }+ .buttonStyle(.plain).disabled(m.running || game.inputs["base", default: []].isEmpty)+ .help(loc.t("library.olderToolsHelp"))+ .padTarget("hero.rebuild", scope: "main", radius: 12) { if !m.running { configureBuild(game) } }+ }+ }+ Text(game.name).font(.manrope(min(68, width * 0.052), .heavy))+ .tracking(-1.6).lineLimit(2).shadow(color: .black.opacity(0.25), radius: 12)+ HStack(spacing: 18) {+ Button { primaryAction(game) } label: {+ LauncherHeroActionLabel(+ title: game.primary == .play ? loc.t("library.play")+ : (game.primary == .openOnDevice ? String(format: loc.t("dev.open"), devices.deviceName(game.installedDevice))+ : loc.t("library.newBuild")),+ symbol: game.primary == .play ? "play.fill" : (game.primary == .openOnDevice ? "iphone" : "hammer.fill"))+ }+ .buttonStyle(.plain).disabled(launching || (m.running && !game.isReady))+ .keyboardShortcut(.return, modifiers: [])+ .padTarget("hero.play", scope: "main", radius: 30) { if !launching { primaryAction(game) } }+ if game.isReady {+ Button { optionsFor = game.id } label: {+ Image(systemName: "slider.horizontal.3").font(.system(size: 17))+ .frame(width: 48, height: 48)+ .background(Color.white.opacity(0.10), in: Circle())+ .overlay(Circle().strokeBorder(Color.white.opacity(0.14)))+ }+ .buttonStyle(.plain).help(loc.t("launch.title")).accessibilityLabel(loc.t("launch.title"))+ .padTarget("hero.options", scope: "main", radius: 24) { optionsFor = game.id }+ }+ Button { manageOpenFor = manageOpenFor == nil ? game.id : nil } label: { ManageButtonLabel(title: loc.t("library.manage")) }+ .buttonStyle(.plain).accessibilityLabel(loc.t("library.manage"))+ .anchorPreference(key: ManageAnchorKey.self, value: .bounds) { $0 }+ .padTarget("hero.manage", scope: "main", radius: 12) { manageOpenFor = game.id }+ }+ // A free Apple ID's provisioning profile lasts 7 days. Say when this app's runs out, and offer the+ // re-sign at any time: renewing early (before a trip, say) is as valid as renewing just in time.+ if game.onDevice && !game.isOlderIOSBuild {+ HStack(spacing: 10) {+ Image(systemName: "checkmark.seal").font(.system(size: 12))+ .foregroundStyle(LauncherPalette.cream.opacity(0.7))+ Text(signatureExpiry[game.id].map { AppSignature.describe($0, loc.t) } ?? loc.t("dev.expiryUnknown"))+ .font(.manrope(12.5))+ .foregroundStyle(signatureExpiry[game.id].map { AppSignature.isUrgent($0) } == true+ ? LauncherPalette.building : .secondary)+ Button { resign(game) } label: {+ Text(loc.t("dev.resign")).font(.manrope(12, .semibold))+ .foregroundStyle(LauncherPalette.cream)+ .padding(.horizontal, 10).padding(.vertical, 4)+ .overlay(Capsule().strokeBorder(LauncherPalette.cream.opacity(0.35)))+ .contentShape(Capsule())+ }+ .buttonStyle(.plain).disabled(m.running)+ .help(loc.t("dev.resignHelp"))+ .padTarget("hero.resign", scope: "main", radius: 12) { if !m.running { resign(game) } }+ }+ }+ if let resignNote {+ Text(resignNote).font(.manrope(12)).foregroundStyle(.secondary)+ .fixedSize(horizontal: false, vertical: true)+ }+ }+ .padding(.horizontal, 34).padding(.bottom, 34)+ }+ .frame(width: width, height: height).clipped()+ }++ func collection(width: CGFloat) -> some View {+ let cardWidth = min(300, max(190, (width - 124) / 5))+ let step = cardWidth + 14+ let games = filteredGames+ let heroID = heroGame?.id+ return VStack(alignment: .leading, spacing: 18) {+ HStack(spacing: 16) {+ Text(loc.t("library.collection")).font(.manrope(28, .bold)).tracking(-0.6)+ Spacer()+ LauncherSegmented(options: LibraryFilter.allCases.map { ($0.rawValue, loc.t($0.labelKey)) },+ selection: libraryFilter.rawValue) { setLibraryFilter(LibraryFilter(rawValue: $0) ?? .owned) }+ .frame(width: LauncherControl.width)+ .padTarget("library.filter", scope: "main", radius: 17,+ activate: { setLibraryFilter(libraryFilter == .owned ? .built : .owned) },+ adjust: { setLibraryFilter($0 > 0 ? .built : .owned) })+ Text(String(format: loc.t("library.gameCount"), libraryFilter == .owned ? library.games.count : library.games.filter(libraryFilter.includes).count))+ .font(.manrope(12)).foregroundStyle(.secondary)+ }+ if games.isEmpty {+ Text(loc.t("library.noResults")).foregroundStyle(.secondary).padding(.vertical, 28)+ } else {+ ScrollViewReader { proxy in+ ScrollView(.horizontal, showsIndicators: false) {+ HStack(alignment: .top, spacing: 14) {+ ForEach(games) { game in+ let _ = LauncherWork.count(.card)+ Button { library.selectedID = game.id } label: {+ VStack(alignment: .leading, spacing: 8) {+ ZStack {+ if let image = artwork[game.id] {+ Image(nsImage: image).resizable().scaledToFill()+ } else {+ LauncherPalette.surface+ Image(systemName: "gamecontroller").font(.system(size: 30, weight: .light)).foregroundStyle(.secondary)+ }+ }+ .frame(width: cardWidth, height: cardWidth / 1.8).clipped()+ .clipShape(RoundedRectangle(cornerRadius: 5))+ .overlay(RoundedRectangle(cornerRadius: 5).strokeBorder(+ game.id == heroID ? LauncherPalette.cream : .clear, lineWidth: 2))+ Text(game.name).font(.manrope(16, .semibold)).lineLimit(1)+ status(game)+ Capsule().fill(game.id == heroID ? LauncherPalette.cream : .clear)+ .frame(height: 3).padding(.top, 4)+ }+ .frame(width: cardWidth, alignment: .leading).contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .accessibilityAddTraits(game.id == heroID ? .isSelected : [])+ .padTarget("card." + game.id.uuidString, scope: "main", radius: 7) { if !launching { primaryAction(game) } }+ }+ }+ // Room for the controller's focus ring, which sits 4 pt outside a card: the row clips at its edges, so it+ // gets the room inside and gives it back outside (the cards stay where they were)+ .padding(.horizontal, Self.ringRoom).padding(.top, Self.ringRoom).padding(.bottom, 5 + Self.ringRoom)+ .background(EnclosingScrollView(row: row))+ }+ .padding(.horizontal, -Self.ringRoom).padding(.vertical, -Self.ringRoom)+ .onChange(of: padFocus.focused) { id in // the focused card scrolls into the row's view+ guard let id, id.hasPrefix("card.") else { return }+ withAnimation(.easeInOut(duration: 0.25)) { proxy.scrollTo(id, anchor: .center) }+ }+ }+ .overlay(alignment: .topLeading) {+ if row.canBack {+ pager("chevron.left", height: cardWidth / 1.8) { row.page(-1, step: step) }.offset(x: -22)+ }+ }+ .overlay(alignment: .topTrailing) {+ if row.canForward {+ pager("chevron.right", height: cardWidth / 1.8) { row.page(1, step: step) }.offset(x: 22)+ }+ }+ }+ }+ .padding(.horizontal, 34).padding(.top, 8).padding(.bottom, 22)+ }++ /// A round button floating over the row's edge, centred on the artwork, shown while the row scrolls that way.+ func pager(_ symbol: String, height: CGFloat, action: @escaping () -> Void) -> some View {+ Button(action: action) {+ Image(systemName: symbol).font(.system(size: 16, weight: .semibold)).foregroundStyle(.white)+ .frame(width: 44, height: 44)+ .background(Color.black.opacity(0.72), in: Circle())+ .overlay(Circle().strokeBorder(Color.white.opacity(0.16)))+ .shadow(color: .black.opacity(0.4), radius: 10)+ .contentShape(Circle())+ }+ .buttonStyle(.plain)+ .frame(height: height)+ .accessibilityLabel(loc.t(symbol == "chevron.left" ? "library.scrollBack" : "library.scrollForward"))+ .transition(.opacity)+ }++ func status(_ game: LibraryGame, prominent: Bool = false) -> some View {+ let building = m.running && activeBuildID == game.id+ let color = building ? LauncherPalette.building : ((game.isReady || game.hasIOSBuild) ? LauncherPalette.ready : LauncherPalette.unbuilt)+ let key = building ? "library.building" : (game.isReady ? "library.ready" : (game.hasIOSBuild ? (game.isOlderIOSBuild ? "library.olderIOS" : "library.readyIOS") : "library.notBuilt"))+ return HStack(spacing: 7) {+ Circle().fill(color).frame(width: prominent ? 9 : 7, height: prominent ? 9 : 7)+ Text(prominent ? loc.t(key).uppercased() : loc.t(key))+ .font(prominent ? .manrope(12, .bold) : .manrope(13, .medium))+ .tracking(prominent ? 1.3 : 0) // the eyebrow: the same face, in tracked capitals+ .foregroundStyle(color)+ if !building && toolsAge.older.contains(game.id) { // a quiet note beside the status, not a warning+ Text("· " + loc.t(prominent ? "library.olderTools" : "library.olderToolsShort"))+ .font(.manrope(prominent ? 13 : 12)).foregroundStyle(.secondary).lineLimit(1)+ .help(loc.t("library.olderToolsHelp"))+ }+ }+ .accessibilityElement(children: .combine)+ }+}diff --git a/frontend/Sources/NX2Apple/LauncherView.swift b/frontend/Sources/NX2Apple/LauncherView.swiftindex 9928a7dc..8c6b54db 100644--- a/frontend/Sources/NX2Apple/LauncherView.swift+++ b/frontend/Sources/NX2Apple/LauncherView.swift@@ -4,51 +4,15 @@ import NXCoreimport NXModelimport NXLauncher-enum LauncherPage: String, CaseIterable {- case library, builds, settings- var symbol: String {- switch self {- case .library: return "gamecontroller"- case .builds: return "shippingbox"- case .settings: return "slider.horizontal.3"- }- }-}--/// The library's filter: every game in the games folder, or only those with a build. Remembered between launches.-enum LibraryFilter: String, CaseIterable, Identifiable {- case owned, built- var id: String { rawValue }- var labelKey: String { "filter." + rawValue }-- /// Owned shows every game without reading its build, so the default filter costs nothing per card.- func includes(_ game: LibraryGame) -> Bool { self == .owned || game.isReady || game.hasIOSBuild }-- static func load(_ defaults: UserDefaults = .standard) -> LibraryFilter {- LibraryFilter(rawValue: defaults.string(forKey: "libraryFilter") ?? "") ?? .owned- }- func save(_ defaults: UserDefaults = .standard) { defaults.set(rawValue, forKey: "libraryFilter") }-- /// The selection and the controller's focus after a switch to this filter. A selected game the filter hides gives way to the- /// first one it shows, and a focus on a hidden card is dropped, so neither the hero nor the A button reaches a game that is not- /// on screen.- func reconcile(games: [LibraryGame], selectedID: UUID?, focused: String?) -> (selectedID: UUID?, focused: String?) {- let shown = games.filter(includes)- let selection = shown.contains { $0.id == selectedID } ? selectedID : shown.first?.id- guard let focused, focused.hasPrefix("card.") else { return (selection, focused) }- return (selection, shown.contains { "card." + $0.id.uuidString == focused } ? focused : nil)- }-}-struct LauncherView: View {private let stores: LauncherStores // the wiring: the stores below are its, the views take what they show- @StateObject private var m: BuildStore // the build: the stages, the failure, the inputs- @ObservedObject private var devices: DeviceStore // the copy card and the activity line while the data goes over- @ObservedObject private var loc: Localizer // the strings: handed on to every view below through the environment+ @StateObject var m: BuildStore // the build: the stages, the failure, the inputs+ @ObservedObject var devices: DeviceStore // the copy card and the activity line while the data goes over+ @ObservedObject var loc: Localizer // the strings: handed on to every view below through the environment@ObservedObject private var updates: AppUpdateStore // the app's self-update: the update icon, the sheet, the uninstall dialog@ObservedObject private var repo: RepoStore // the repository: the activity line, and the checks that follow a change of it@ObservedObject private var engine: EngineSyncStore // the engine: the sync banner, and the checks that follow a sync- @StateObject private var library: GameLibrary+ @StateObject var library: GameLibrary@State private var page: LauncherPage = .library@State private var search = ""@State private var searching = false@@ -58,25 +22,25 @@ struct LauncherView: View {@StateObject private var consoleDriver: AnyConsoleDriver@State private var controllerSheet = false@FocusState private var searchFocused: Bool- @State private var artwork: [UUID: NSImage] = [:]- @State private var activeBuildID: UUID?- @State private var launching = false+ @State var artwork: [UUID: NSImage] = [:]+ @State var activeBuildID: UUID?+ @State var launching = false@State private var launchError: String?@State private var removing: LibraryGame?- @State private var optionsFor: UUID?+ @State var optionsFor: UUID?@State private var freeSpaceFor: UUID? // the game whose Free space sheet is open@State private var controlsOpen = false@State private var savesFor: UUID? // the game whose Saves sheet is open (SaveTransfer.swift)@State private var cheatsFor: UUID? // the game whose Cheats sheet is open (CheatsView.swift)- @State private var manageOpenFor: UUID? // the game whose Manage menu is open (ManageMenu.swift)+ @State var manageOpenFor: UUID? // the game whose Manage menu is open (ManageMenu.swift)@StateObject private var controls: ControlLayout@StateObject private var gamepad: LauncherGamepad- @StateObject private var padFocus = PadFocus()- @StateObject private var row = RowScroller()- @StateObject private var toolsAge: ToolsAge+ @StateObject var padFocus = PadFocus()+ @StateObject var row = RowScroller()+ @StateObject var toolsAge: ToolsAge@State private var buildCommit = "" // the engine's commit when the running build started (ToolsAge)- @State private var signatureExpiry: [UUID: Date] = [:] // installed apps' provisioning-profile expiry, per game- @State private var resignNote: String? // the last re-sign's outcome, shown under the hero's expiry line+ @State var signatureExpiry: [UUID: Date] = [:] // installed apps' provisioning-profile expiry, per game+ @State var resignNote: String? // the last re-sign's outcome, shown under the hero's expiry lineprivate var performStartupChecks: Boolprivate let onRunSetup: (() -> Void)? // Settings' "Run setup again"; the root view supplies itprivate let qaManage: (open: Bool, ring: Bool) // visual QA: the Manage menu open at launch, with the controller's focus ring or without@@ -113,9 +77,9 @@ struct LauncherView: View {if injectedDriver { consoleDriver.setPadMerge(on) }}- @State private var libraryFilter: LibraryFilter = LibraryFilter.load()+ @State var libraryFilter: LibraryFilter = LibraryFilter.load()- private func setLibraryFilter(_ filter: LibraryFilter) {+ func setLibraryFilter(_ filter: LibraryFilter) {guard filter != libraryFilter else { return }withAnimation(.easeInOut(duration: 0.2)) { libraryFilter = filter }filter.save()@@ -124,12 +88,12 @@ struct LauncherView: View {if after.focused != padFocus.focused { padFocus.focused = after.focused }}- private var filteredGames: [LibraryGame] {+ var filteredGames: [LibraryGame] {library.games.filter { (search.isEmpty || $0.name.localizedCaseInsensitiveContains(search)) && libraryFilter.includes($0) }}/// The hero's game: the selection, unless the filter hides it, then the first game the filter shows.- private var heroGame: LibraryGame? {+ var heroGame: LibraryGame? {guard libraryFilter != .owned else { return library.selected }if let selected = library.selected, libraryFilter.includes(selected) { return selected }return library.games.first(where: libraryFilter.includes)@@ -426,258 +390,7 @@ struct LauncherView: View {}/// 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 in- if library.games.isEmpty {- emptyLibrary- } else {- ScrollView {- VStack(alignment: .leading, spacing: 0) {- if let game = heroGame {- 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 bottom- collection(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 } }- }- }- }-- private var emptyLibrary: some View {- VStack(alignment: .leading, spacing: 22) {- Spacer()- Image(systemName: "gamecontroller").font(.system(size: 44, weight: .light))- .foregroundStyle(LauncherPalette.cream)- Text(loc.t("library.welcome")).font(.manrope(54, .bold)).tracking(-1.8)- Text(loc.t("library.welcomeNote")).font(.manrope(17)).foregroundStyle(.secondary)- .frame(maxWidth: 490, alignment: .leading).fixedSize(horizontal: false, vertical: true)- Button { newBuild() } label: {- Label(loc.t("library.firstBuild"), systemImage: "plus")- .font(.manrope(16, .semibold))- .padding(.horizontal, 24).padding(.vertical, 15)- .foregroundStyle(.black).background(LauncherPalette.cream, in: Capsule())- }- .buttonStyle(.plain).padding(.top, 8)- Button(action: chooseLibraryFolder) {- Label(loc.t("library.chooseFolder"), systemImage: "folder")- .font(.manrope(14)).foregroundStyle(.secondary)- }.buttonStyle(.plain)- Spacer()- Text(loc.t("library.localNote")).font(.manrope(12)).foregroundStyle(.secondary)- }- .padding(48).frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)- }-- private func hero(_ game: LibraryGame, width: CGFloat, height: CGFloat) -> some View {- ZStack(alignment: .bottomLeading) {- if let image = artwork[game.id] {- Image(nsImage: image).resizable().scaledToFill()- .frame(width: width, height: height).clipped()- } else {- LauncherPalette.surface- Image(systemName: "gamecontroller").font(.system(size: 160, weight: .ultraLight))- .foregroundStyle(Color.white.opacity(0.05))- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing).padding(60)- }- LinearGradient(stops: [.init(color: .clear, location: 0.25),- .init(color: .black.opacity(0.25), location: 0.45),- .init(color: LauncherPalette.background, location: 1)],- startPoint: .top, endPoint: .bottom)- LinearGradient(colors: [.black.opacity(0.24), .clear], startPoint: .leading, endPoint: .trailing)- VStack(alignment: .leading, spacing: 14) {- HStack(spacing: 14) {- status(game, prominent: true)- if toolsAge.older.contains(game.id) && !(m.running && activeBuildID == game.id) {- Button { configureBuild(game) } label: {- Label(loc.t("library.rebuildShort"), systemImage: "arrow.clockwise")- .font(.manrope(12, .semibold)).foregroundStyle(LauncherPalette.cream)- .padding(.horizontal, 10).padding(.vertical, 4)- .overlay(Capsule().strokeBorder(LauncherPalette.cream.opacity(0.35)))- .contentShape(Capsule())- }- .buttonStyle(.plain).disabled(m.running || game.inputs["base", default: []].isEmpty)- .help(loc.t("library.olderToolsHelp"))- .padTarget("hero.rebuild", scope: "main", radius: 12) { if !m.running { configureBuild(game) } }- }- }- Text(game.name).font(.manrope(min(68, width * 0.052), .heavy))- .tracking(-1.6).lineLimit(2).shadow(color: .black.opacity(0.25), radius: 12)- HStack(spacing: 18) {- Button { primaryAction(game) } label: {- LauncherHeroActionLabel(- title: game.primary == .play ? loc.t("library.play")- : (game.primary == .openOnDevice ? String(format: loc.t("dev.open"), devices.deviceName(game.installedDevice))- : loc.t("library.newBuild")),- symbol: game.primary == .play ? "play.fill" : (game.primary == .openOnDevice ? "iphone" : "hammer.fill"))- }- .buttonStyle(.plain).disabled(launching || (m.running && !game.isReady))- .keyboardShortcut(.return, modifiers: [])- .padTarget("hero.play", scope: "main", radius: 30) { if !launching { primaryAction(game) } }- if game.isReady {- Button { optionsFor = game.id } label: {- Image(systemName: "slider.horizontal.3").font(.system(size: 17))- .frame(width: 48, height: 48)- .background(Color.white.opacity(0.10), in: Circle())- .overlay(Circle().strokeBorder(Color.white.opacity(0.14)))- }- .buttonStyle(.plain).help(loc.t("launch.title")).accessibilityLabel(loc.t("launch.title"))- .padTarget("hero.options", scope: "main", radius: 24) { optionsFor = game.id }- }- Button { manageOpenFor = manageOpenFor == nil ? game.id : nil } label: { ManageButtonLabel(title: loc.t("library.manage")) }- .buttonStyle(.plain).accessibilityLabel(loc.t("library.manage"))- .anchorPreference(key: ManageAnchorKey.self, value: .bounds) { $0 }- .padTarget("hero.manage", scope: "main", radius: 12) { manageOpenFor = game.id }- }- // A free Apple ID's provisioning profile lasts 7 days. Say when this app's runs out, and offer the- // re-sign at any time: renewing early (before a trip, say) is as valid as renewing just in time.- if game.onDevice && !game.isOlderIOSBuild {- HStack(spacing: 10) {- Image(systemName: "checkmark.seal").font(.system(size: 12))- .foregroundStyle(LauncherPalette.cream.opacity(0.7))- Text(signatureExpiry[game.id].map { AppSignature.describe($0, loc.t) } ?? loc.t("dev.expiryUnknown"))- .font(.manrope(12.5))- .foregroundStyle(signatureExpiry[game.id].map { AppSignature.isUrgent($0) } == true- ? LauncherPalette.building : .secondary)- Button { resign(game) } label: {- Text(loc.t("dev.resign")).font(.manrope(12, .semibold))- .foregroundStyle(LauncherPalette.cream)- .padding(.horizontal, 10).padding(.vertical, 4)- .overlay(Capsule().strokeBorder(LauncherPalette.cream.opacity(0.35)))- .contentShape(Capsule())- }- .buttonStyle(.plain).disabled(m.running)- .help(loc.t("dev.resignHelp"))- .padTarget("hero.resign", scope: "main", radius: 12) { if !m.running { resign(game) } }- }- }- if let resignNote {- Text(resignNote).font(.manrope(12)).foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- }- }- .padding(.horizontal, 34).padding(.bottom, 34)- }- .frame(width: width, height: height).clipped()- }-- private func collection(width: CGFloat) -> some View {- let cardWidth = min(300, max(190, (width - 124) / 5))- let step = cardWidth + 14- let games = filteredGames- let heroID = heroGame?.id- return VStack(alignment: .leading, spacing: 18) {- HStack(spacing: 16) {- Text(loc.t("library.collection")).font(.manrope(28, .bold)).tracking(-0.6)- Spacer()- LauncherSegmented(options: LibraryFilter.allCases.map { ($0.rawValue, loc.t($0.labelKey)) },- selection: libraryFilter.rawValue) { setLibraryFilter(LibraryFilter(rawValue: $0) ?? .owned) }- .frame(width: LauncherControl.width)- .padTarget("library.filter", scope: "main", radius: 17,- activate: { setLibraryFilter(libraryFilter == .owned ? .built : .owned) },- adjust: { setLibraryFilter($0 > 0 ? .built : .owned) })- Text(String(format: loc.t("library.gameCount"), libraryFilter == .owned ? library.games.count : library.games.filter(libraryFilter.includes).count))- .font(.manrope(12)).foregroundStyle(.secondary)- }- if games.isEmpty {- Text(loc.t("library.noResults")).foregroundStyle(.secondary).padding(.vertical, 28)- } else {- ScrollViewReader { proxy in- ScrollView(.horizontal, showsIndicators: false) {- HStack(alignment: .top, spacing: 14) {- ForEach(games) { game in- let _ = LauncherWork.count(.card)- Button { library.selectedID = game.id } label: {- VStack(alignment: .leading, spacing: 8) {- ZStack {- if let image = artwork[game.id] {- Image(nsImage: image).resizable().scaledToFill()- } else {- LauncherPalette.surface- Image(systemName: "gamecontroller").font(.system(size: 30, weight: .light)).foregroundStyle(.secondary)- }- }- .frame(width: cardWidth, height: cardWidth / 1.8).clipped()- .clipShape(RoundedRectangle(cornerRadius: 5))- .overlay(RoundedRectangle(cornerRadius: 5).strokeBorder(- game.id == heroID ? LauncherPalette.cream : .clear, lineWidth: 2))- Text(game.name).font(.manrope(16, .semibold)).lineLimit(1)- status(game)- Capsule().fill(game.id == heroID ? LauncherPalette.cream : .clear)- .frame(height: 3).padding(.top, 4)- }- .frame(width: cardWidth, alignment: .leading).contentShape(Rectangle())- }- .buttonStyle(.plain)- .accessibilityAddTraits(game.id == heroID ? .isSelected : [])- .padTarget("card." + game.id.uuidString, scope: "main", radius: 7) { if !launching { primaryAction(game) } }- }- }- // Room for the controller's focus ring, which sits 4 pt outside a card: the row clips at its edges, so it- // gets the room inside and gives it back outside (the cards stay where they were)- .padding(.horizontal, Self.ringRoom).padding(.top, Self.ringRoom).padding(.bottom, 5 + Self.ringRoom)- .background(EnclosingScrollView(row: row))- }- .padding(.horizontal, -Self.ringRoom).padding(.vertical, -Self.ringRoom)- .onChange(of: padFocus.focused) { id in // the focused card scrolls into the row's view- guard let id, id.hasPrefix("card.") else { return }- withAnimation(.easeInOut(duration: 0.25)) { proxy.scrollTo(id, anchor: .center) }- }- }- .overlay(alignment: .topLeading) {- if row.canBack {- pager("chevron.left", height: cardWidth / 1.8) { row.page(-1, step: step) }.offset(x: -22)- }- }- .overlay(alignment: .topTrailing) {- if row.canForward {- pager("chevron.right", height: cardWidth / 1.8) { row.page(1, step: step) }.offset(x: 22)- }- }- }- }- .padding(.horizontal, 34).padding(.top, 8).padding(.bottom, 22)- }-- /// A round button floating over the row's edge, centred on the artwork, shown while the row scrolls that way.- private func pager(_ symbol: String, height: CGFloat, action: @escaping () -> Void) -> some View {- Button(action: action) {- Image(systemName: symbol).font(.system(size: 16, weight: .semibold)).foregroundStyle(.white)- .frame(width: 44, height: 44)- .background(Color.black.opacity(0.72), in: Circle())- .overlay(Circle().strokeBorder(Color.white.opacity(0.16)))- .shadow(color: .black.opacity(0.4), radius: 10)- .contentShape(Circle())- }- .buttonStyle(.plain)- .frame(height: height)- .accessibilityLabel(loc.t(symbol == "chevron.left" ? "library.scrollBack" : "library.scrollForward"))- .transition(.opacity)- }-- private func status(_ game: LibraryGame, prominent: Bool = false) -> some View {- let building = m.running && activeBuildID == game.id- let color = building ? LauncherPalette.building : ((game.isReady || game.hasIOSBuild) ? LauncherPalette.ready : LauncherPalette.unbuilt)- let key = building ? "library.building" : (game.isReady ? "library.ready" : (game.hasIOSBuild ? (game.isOlderIOSBuild ? "library.olderIOS" : "library.readyIOS") : "library.notBuilt"))- return HStack(spacing: 7) {- Circle().fill(color).frame(width: prominent ? 9 : 7, height: prominent ? 9 : 7)- Text(prominent ? loc.t(key).uppercased() : loc.t(key))- .font(prominent ? .manrope(12, .bold) : .manrope(13, .medium))- .tracking(prominent ? 1.3 : 0) // the eyebrow: the same face, in tracked capitals- .foregroundStyle(color)- if !building && toolsAge.older.contains(game.id) { // a quiet note beside the status, not a warning- Text("· " + loc.t(prominent ? "library.olderTools" : "library.olderToolsShort"))- .font(.manrope(prominent ? 13 : 12)).foregroundStyle(.secondary).lineLimit(1)- .help(loc.t("library.olderToolsHelp"))- }- }- .accessibilityElement(children: .combine)- }+ @State var collectionHeight: CGFloat = 274private var activityBar: some View {VStack(spacing: 0) {@@ -753,7 +466,7 @@ struct LauncherView: View {return percent / 100}- private func newBuild() {+ func newBuild() {guard !m.running else { page = .builds; return }for index in m.slots.indices { m.slots[index].paths = []; m.slots[index].problem = "" }m.gameDir = ""; m.done = false; m.doneNote = ""; m.macAppPath = ""; m.stages = []@@ -761,7 +474,7 @@ struct LauncherView: View {page = .builds}- private func configureBuild(_ game: LibraryGame) {+ func configureBuild(_ game: LibraryGame) {guard !m.running else { page = .builds; return }for index in m.slots.indices {m.slots[index].paths = game.inputs[m.slots[index].id] ?? []@@ -865,7 +578,7 @@ struct LauncherView: View {/// The space the collection row keeps around its cards for the focus ring (PadFocus draws it 4 pt outside a target).static let ringRoom: CGFloat = 6- private func primaryAction(_ game: LibraryGame) {+ func primaryAction(_ game: LibraryGame) {if !game.isReady && game.onDevice { // installed on a device: start it therelaunching = truem.openOnDevice(udid: game.installedDevice, app: game.iosAppPath) { error in@@ -911,7 +624,7 @@ struct LauncherView: View {/// Sign the installed app again for another 7 days (a free Apple ID's profile), then install it: the game's code/// is not rebuilt, and its Documents stay.- private func resign(_ game: LibraryGame) {+ func resign(_ game: LibraryGame) {resignNote = nilm.resignOnDevice(app: game.iosAppPath, device: game.installedDevice) {resignNote = m.doneNote@@ -953,7 +666,7 @@ struct LauncherView: View {}}- private func chooseLibraryFolder() {+ func chooseLibraryFolder() {let panel = NSOpenPanel()panel.canChooseDirectories = truepanel.canChooseFiles = falsediff --git a/frontend/Tests/NX2AppleTests/SourceSizeTests.swift b/frontend/Tests/NX2AppleTests/SourceSizeTests.swiftindex e80aa76d..e1159643 100644--- a/frontend/Tests/NX2AppleTests/SourceSizeTests.swift+++ b/frontend/Tests/NX2AppleTests/SourceSizeTests.swift@@ -6,9 +6,7 @@ final class SourceSizeTests: XCTestCase {private static let limit = 800/// Path under frontend/Sources → its line count when the limit came in. Lower the number when the file shrinks.- private static let aboveTheLimit: [String: Int] = [- "NX2Apple/LauncherView.swift": 967,- ]+ private static let aboveTheLimit: [String: Int] = [:]private func sources() -> URL {var url = URL(fileURLWithPath: #filePath)