Skip to content

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

The onboarding drops the app name and icon, and its cards keep one size across states

v0lumehidcf2798efbd8
diff --git a/frontend/Onboarding.md b/frontend/Onboarding.md
index 59c3f0cf..4794ec34 100644
--- a/frontend/Onboarding.md
+++ b/frontend/Onboarding.md
@@ -50,7 +50,7 @@ Persist the current step and selections before handling `skipForLater`; inject t
## Presentation choices
-The flow retains the launcher's dark appearance, palette, Manrope, cream capsule primary button, secondary button style and 1.8:1 cover crop. The app currently forces dark mode, so onboarding does too. The welcome icon is the app's own (`NSApp.applicationIconImage` inside the .app, a symbol under `swift run`); there is no SwiftPM resource, because the release workflow copies only the executable. Background preparation stays beside Xcode, while a fixed footer keeps the primary action visible at the launcher's 900 × 680 minimum window size. Long content scrolls.
+The flow retains the launcher's dark appearance, palette, Manrope, cream capsule primary button, secondary button style and 1.8:1 cover crop. The app currently forces dark mode, so onboarding does too. Background preparation stays beside Xcode, while a fixed footer keeps the primary action visible at the launcher's 900 × 680 minimum window size. Long content scrolls. The two Xcode cards share one fixed height across all of that step's states (content scrolls inside a card rather than resizing it), and the platform, keys and games cards keep their size between states.
Return activates the primary action, Escape and controller B go back. Every interactive element has an onboarding controller target. Step headings receive VoiceOver focus, and changing status is announced. Reduced Motion replaces slides with fades, shows completed checks immediately, stops indeterminate loops and disables progress interpolation.
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index c84f6a02..b9b7f45b 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -41,7 +41,6 @@ enum Lang: String {
enum L10n {
/// key: (Chinese, English)
static let table: [String: (zh: String, en: String)] = [
- "onboarding.brand": ("NX2Apple", "NX2Apple"),
"onboarding.welcome.title": ("\u{51c6}\u{5907}\u{5f00}\u{59cb}\u{6e38}\u{620f}\u{3002}", "Make yourself at home."),
"onboarding.welcome.note": ("\u{7ea6} 15 \u{5206}\u{949f}\u{ff0c}\u{5373}\u{53ef}\u{5728} Mac \u{4e0a}\u{539f}\u{751f}\u{8fd0}\u{884c}\u{4f60}\u{7684} Switch \u{6e38}\u{620f}\u{3002}", "Play your Switch games natively on your Mac, in about 15 minutes."),
"onboarding.platform.title": ("\u{4f60}\u{60f3}\u{5728}\u{54ea}\u{91cc}\u{73a9}\u{ff1f}", "Where do you want to play?"),
diff --git a/frontend/Sources/NSPortBuilder/OnboardingView.swift b/frontend/Sources/NSPortBuilder/OnboardingView.swift
index 9cb58473..a3d71061 100644
--- a/frontend/Sources/NSPortBuilder/OnboardingView.swift
+++ b/frontend/Sources/NSPortBuilder/OnboardingView.swift
@@ -12,7 +12,6 @@ import UniformTypeIdentifiers
@State private var detailsOpen = false
@State private var pickerError: String?
@State private var backwards = false
- @State private var entered = false
@AccessibilityFocusState private var headingFocused: Bool
init(driver: Driver, lang: Lang = .initial(), gamepad: LauncherGamepad? = nil) {
@@ -75,7 +74,6 @@ import UniformTypeIdentifiers
.onAppear {
padFocus.scope = "onboarding"
gamepad.perform = padAction
- withAnimation(.easeOut(duration: 0.35)) { entered = true }
headingFocused = true
}
.onDisappear { gamepad.perform = { _ in } }
@@ -128,15 +126,6 @@ import UniformTypeIdentifiers
private var heading: some View {
VStack(alignment: .leading, spacing: 14) {
- if state.step == .welcome {
- HStack(spacing: 14) {
- OnboardingAppIcon().frame(width: 62, height: 62).accessibilityHidden(true)
- Text(t("onboarding.brand")).font(.manrope(27, .bold)).tracking(-0.8)
- }
- .padding(.bottom, 14)
- .opacity(entered ? 1 : 0)
- .offset(y: reduceMotion || entered ? 0 : 8)
- }
if state.step == .done {
OnboardingCheck(lang: lang).frame(width: 64, height: 64).padding(.bottom, 12)
}
@@ -207,14 +196,14 @@ import UniformTypeIdentifiers
Spacer()
Image(systemName: selected ? "checkmark.circle.fill" : "circle")
.foregroundStyle(selected ? LauncherPalette.cream : Color.white.opacity(0.2))
- }.accessibilityHidden(true)
+ }.frame(height: 40, alignment: .top).accessibilityHidden(true) // symbols differ in height: the titles stay on one line
Text(t("onboarding.platform.\(platform.rawValue)")).font(.manrope(22, .bold))
Text(t(platform.includesIOS ? "onboarding.platform.iosSize" : "onboarding.platform.macNote"))
.font(.manrope(13)).foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
Spacer(minLength: 0)
}
- .padding(24).frame(maxWidth: .infinity, minHeight: 200, alignment: .topLeading)
+ .padding(24).frame(maxWidth: .infinity, minHeight: 216, maxHeight: 216, alignment: .topLeading)
.background(selected ? LauncherPalette.cream.opacity(0.07) : LauncherPalette.surface, in: RoundedRectangle(cornerRadius: 14))
.overlay(RoundedRectangle(cornerRadius: 14).strokeBorder(selected ? LauncherPalette.cream : Color.white.opacity(0.10), lineWidth: selected ? 2 : 1))
.contentShape(RoundedRectangle(cornerRadius: 14))
@@ -226,9 +215,21 @@ import UniformTypeIdentifiers
}
}
+ /// Both Xcode cards have this content height in every state (the tallest is setting up with the iOS sub-step), so nothing
+ /// jumps when the state changes; content sits at the top and scrolls inside the card when it is longer.
+
+ private func fixedCard<Content: View>(@ViewBuilder _ content: () -> Content) -> some View {
+ ScrollView {
+ content().frame(maxWidth: .infinity, alignment: .topLeading)
+ }
+ .frame(height: onboardingXcodeCardHeight, alignment: .top)
+ .modifier(OnboardingCard())
+ }
+
private var xcode: some View {
HStack(alignment: .top, spacing: 22) {
- VStack(alignment: .leading, spacing: 20) {
+ fixedCard {
+ VStack(alignment: .leading, spacing: 20) {
HStack(spacing: 12) {
xcodeIcon
Text(t(state.xcode.statusKey)).font(.manrope(18, .semibold))
@@ -247,17 +248,19 @@ import UniformTypeIdentifiers
}
case let .failed(failure): failureView(failure)
}
+ }
}
- .frame(maxWidth: .infinity, alignment: .leading).modifier(OnboardingCard())
- VStack(alignment: .leading, spacing: 20) {
+ fixedCard {
+ VStack(alignment: .leading, spacing: 20) {
Text(t("onboarding.background.title")).font(.manrope(14, .semibold))
ForEach(OnboardingBackgroundTask.allCases, id: \.self) { task in
taskRow(task.titleKey, status: state.background[task] ?? .queued)
}
Text(t("onboarding.background.note")).font(.manrope(12)).foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
}
- .frame(width: 230, alignment: .leading).modifier(OnboardingCard())
}
}
@@ -329,6 +332,8 @@ import UniformTypeIdentifiers
}
}
+ /// Content height of the keys card and the least of the games card, so their states do not resize them.
+
private var keys: some View {
VStack(alignment: .leading, spacing: 18) {
HStack(spacing: 12) {
@@ -349,7 +354,9 @@ import UniformTypeIdentifiers
dropZone(keys: true, enabled: state.keys != .validating)
}
Text(t("onboarding.keys.privacy")).font(.manrope(12)).foregroundStyle(.secondary)
- }.modifier(OnboardingCard())
+ }
+ .frame(minHeight: onboardingDropCardHeight, alignment: .topLeading) // the same size whether it asks, checks or is done
+ .modifier(OnboardingCard())
}
private var games: some View {
@@ -389,6 +396,7 @@ import UniformTypeIdentifiers
}
dropZone(keys: false, enabled: state.games != .scanning)
}
+ .frame(minHeight: onboardingDropCardHeight, alignment: .topLeading)
}
private func dropZone(keys: Bool, enabled: Bool) -> some View {
@@ -458,6 +466,9 @@ import UniformTypeIdentifiers
}
}
+private let onboardingXcodeCardHeight: CGFloat = 270
+private let onboardingDropCardHeight: CGFloat = 250
+
private struct OnboardingCard: ViewModifier {
func body(content: Content) -> some View {
content.padding(24).frame(maxWidth: .infinity, alignment: .leading)
@@ -576,16 +587,3 @@ private struct OnboardingCheck: View {
.background(LauncherWindowChrome()).preferredColorScheme(.dark)
}
}
-
-/// The app's own icon. A bare `swift run` executable has no icon (macOS shows a generic one), so
-/// there a symbol stands in. No SwiftPM resource: the release workflow copies only the executable.
-struct OnboardingAppIcon: View {
- var body: some View {
- if Bundle.main.bundlePath.hasSuffix(".app") {
- Image(nsImage: NSApp.applicationIconImage).resizable().scaledToFit()
- } else {
- Image(systemName: "gamecontroller.fill").resizable().scaledToFit().padding(10)
- .foregroundStyle(.secondary)
- }
- }
-}
diff --git a/frontend/Tests/NSPortBuilderTests/OnboardingTests.swift b/frontend/Tests/NSPortBuilderTests/OnboardingTests.swift
index 93927059..affed05e 100644
--- a/frontend/Tests/NSPortBuilderTests/OnboardingTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/OnboardingTests.swift
@@ -193,5 +193,28 @@ final class OnboardingTests: XCTestCase {
window.orderOut(nil)
}
}
+ // The Xcode step keeps one card size across its states: capture each to compare.
+ let failure = OnboardingFailure(message: "The Metal Toolchain could not be downloaded.", details: "HTTP 503")
+ let states: [(String, OnboardingState.Xcode)] = [("checking", .checking), ("missing", .missing), ("downloading", .downloading),
+ ("needsSetup", .needsSetup), ("settingUp", .settingUp), ("ready", .ready), ("failed", .failed(failure))]
+ for (name, xcode) in states {
+ var s = OnboardingState()
+ s.step = .xcode; s.platform = .selected(.both); s.xcode = xcode
+ s.setup = [.selected: .done, .license: .done, .firstLaunch: .done, .metal: .running(0.65), .ios: .running(0.2)]
+ s.background = [.python: .done, .dotnet: .running(0.5), .tools: .queued]
+ let driver = MockOnboardingDriver(state: s, lang: .en, animated: false)
+ let host = NSHostingView(rootView: OnboardingView(driver: driver, lang: .en))
+ let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 900, height: 680),
+ styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false)
+ window.contentView = host
+ window.orderFront(nil)
+ RunLoop.main.run(until: Date().addingTimeInterval(0.4))
+ host.layoutSubtreeIfNeeded()
+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))
+ host.cacheDisplay(in: host.bounds, to: rep)
+ try XCTUnwrap(rep.representation(using: .png, properties: [:]))
+ .write(to: output.appendingPathComponent("xcode-\(name)-en.png"))
+ window.orderOut(nil)
+ }
}
}