Skip to content

Open source CapCut alternative.

TypeScript

feat(app): unify sign-in and the walkthrough into one onboarding card

David Lea4d32624cb8c
diff --git a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
index 5fdfacc2..944133cd 100644
--- a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
+++ b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
@@ -6,12 +6,12 @@ import DonkeyAI
import DonkeyContracts
import DonkeyRuntime
import Foundation
+import SwiftUI
@MainActor
final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
private var authCoordinator: DonkeyAuthCoordinator?
private var onboardingWindowController: OnboardingWindowController?
- private var loginWindowController: DonkeyLoginWindowController?
private var permissionSetupController: MacPermissionSetupWindowController?
private var manualPermissionSetupController: MacPermissionSetupWindowController?
private var overlayController: UserQueryOverlayController?
@@ -50,18 +50,22 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
// optimistic default. The phase observer keeps it current from here on.
BackendSessionGate.shared.update(isAuthenticated: authCoordinator.isAuthenticated)
authCoordinator.authenticationCompleted = { [weak self] _ in
+ // Sign-in may have happened on the onboarding card's sign-in slide; close it before bringing
+ // up the authenticated surfaces. `close()` clears the retain via onDismiss, and this is a
+ // no-op when the card isn't showing (e.g. notch re-auth).
+ self?.onboardingWindowController?.close()
self?.startAuthenticatedAppSurfaces()
}
registerAuthCallbackHandler()
installMainMenu()
- // First install (never signed in) runs the onboarding walkthrough, which finishes into the
- // sign-in window. A returning user whose session has expired skips both: the notch comes up
- // in login mode (driven by the auth phase observer) and carries them back through sign-in inline.
+ // First install (never signed in) opens the onboarding card on its sign-in landing. A returning
+ // user whose session has expired skips it: the notch comes up in login mode (driven by the auth
+ // phase observer) and carries them back through sign-in inline.
if authCoordinator.isAuthenticated || authCoordinator.hasEverSignedIn {
startAuthenticatedAppSurfaces()
} else {
- showOnboarding()
+ presentOnboardingCard(entry: .signIn)
}
}
@@ -76,7 +80,7 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
hasVisibleWindows flag: Bool
) -> Bool {
if authCoordinator?.isAuthenticated != true {
- showLoginWindow()
+ presentOnboardingCard(entry: .signIn)
} else if let permissionSetupController {
permissionSetupController.showSetup()
} else if overlayController == nil {
@@ -98,47 +102,58 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
uiUnderstandingCoordinator?.stop()
}
- /// First-run onboarding: a borderless, draggable card window that walks through what Donkey does.
- /// Whether the user steps through to the final slide or dismisses early, it finishes into sign-in.
- private func showOnboarding() {
+ /// Where to open the onboarding card.
+ private enum OnboardingEntry {
+ /// Land on the sign-in slide: signed-out app-open, reopen, or post-sign-out.
+ case signIn
+ /// Open on the feature tour: the "Show Onboarding" menu replay.
+ case tour
+ }
+
+ /// Presents the onboarding card — the single surface for both the walkthrough and login. When signed
+ /// out, slide 0 is the Google sign-in landing with an Explore link into the feature tour, and the card
+ /// stays up until sign-in completes (the `authenticationCompleted` handler closes it). When signed in,
+ /// it's the feature tour ending in Done. `entry` chooses the opening slide.
+ private func presentOnboardingCard(entry: OnboardingEntry) {
+ guard let authCoordinator else { return }
NSApp.setActivationPolicy(.regular)
+
let controller = OnboardingWindowController()
onboardingWindowController = controller
+
+ let isSignedIn = authCoordinator.isAuthenticated
+ let pages = OnboardingTour.pages(isSignedIn: isSignedIn)
+
+ // Signed-out pages are [sign-in, features...]. `.signIn` opens on the landing (0); `.tour` skips
+ // to the first feature (1). Signed-in pages are features only, always opened at 0.
+ let initialPageIndex: Int
+ if isSignedIn {
+ initialPageIndex = 0
+ } else {
+ switch entry {
+ case .signIn: initialPageIndex = 0
+ case .tour: initialPageIndex = min(1, pages.count - 1)
+ }
+ }
+
controller.present(
- pages: OnboardingTour.pages,
+ pages: pages,
+ initialPageIndex: initialPageIndex,
continueButtonTitle: "Continue",
- finishButtonTitle: "Get Started",
- onFinish: { [weak self] in
- self?.finishOnboarding()
- },
- onClose: { [weak self] in
- self?.finishOnboarding()
+ finishButtonTitle: "Done",
+ onDismiss: { [weak self] in self?.onboardingWindowController = nil },
+ signInFooter: isSignedIn ? nil : { [authCoordinator] in
+ AnyView(OnboardingGoogleSignInFooter(authCoordinator: authCoordinator))
}
)
}
- private func finishOnboarding() {
- onboardingWindowController = nil
- showLoginWindow()
- }
-
- private func showLoginWindow() {
- guard let authCoordinator else { return }
-
- NSApp.setActivationPolicy(.regular)
- if loginWindowController == nil {
- loginWindowController = DonkeyLoginWindowController(authCoordinator: authCoordinator)
- }
- loginWindowController?.showLogin()
- }
-
private func startAuthenticatedAppSurfaces() {
guard overlayController == nil,
permissionSetupController == nil
else { return }
- loginWindowController?.close()
- loginWindowController = nil
+ onboardingWindowController?.close()
NSApp.setActivationPolicy(.regular)
// The notch overlay renders immediately on launch, so it's always present. When permissions
@@ -374,21 +389,7 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
}
@objc private func showOnboardingMenuAction(_ sender: Any?) {
- showOnboardingWalkthrough()
- }
-
- /// Replays the onboarding walkthrough on demand from the menu. Unlike the first-run path, finishing or
- /// closing it just dismisses the card — it never routes into sign-in.
- private func showOnboardingWalkthrough() {
- NSApp.setActivationPolicy(.regular)
- let controller = OnboardingWindowController()
- onboardingWindowController = controller
- controller.present(
- pages: OnboardingTour.pages,
- finishButtonTitle: "Done",
- onFinish: { [weak self] in self?.onboardingWindowController = nil },
- onClose: { [weak self] in self?.onboardingWindowController = nil }
- )
+ presentOnboardingCard(entry: .tour)
}
// MARK: - Permissions setup
@@ -407,10 +408,10 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
private func signOut() {
// User-initiated: revoke every session for this user so the website (and any other device) signs
- // out too, then tear down local surfaces and surface login.
+ // out too, then tear down local surfaces and surface the onboarding card on its sign-in landing.
authCoordinator?.signOut(revokingRemoteSessions: true)
teardownAuthenticatedSurfaces()
- showLoginWindow()
+ presentOnboardingCard(entry: .signIn)
}
/// Tears down the live overlay/runtime surfaces so a later sign-in can rebuild them cleanly.
@@ -451,6 +452,14 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
showOnboardingItem.target = self
appMenu.addItem(showOnboardingItem)
+ let permissionsSetupItem = NSMenuItem(
+ title: "Permissions Setup",
+ action: #selector(permissionsSetupMenuAction(_:)),
+ keyEquivalent: ""
+ )
+ permissionsSetupItem.target = self
+ appMenu.addItem(permissionsSetupItem)
+
let signOutItem = NSMenuItem(
title: "Sign Out",
action: #selector(signOutMenuAction(_:)),
@@ -459,14 +468,6 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
signOutItem.target = self
appMenu.addItem(signOutItem)
- let permissionsSetupItem = NSMenuItem(
- title: "Permissions Setup…",
- action: #selector(permissionsSetupMenuAction(_:)),
- keyEquivalent: ""
- )
- permissionsSetupItem.target = self
- appMenu.addItem(permissionsSetupItem)
-
appMenu.addItem(.separator())
appMenu.addItem(
withTitle: "Quit \(Self.appDisplayName)",
diff --git a/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift b/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift
index 62144291..131119ab 100644
--- a/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift
+++ b/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift
@@ -130,7 +130,64 @@ private struct DonkeyGoogleSignInScreen<StatusText: View>: View {
}
}
-private struct GoogleContinueAsset: View {
+/// The sign-in slide's call-to-action inside the onboarding card: the same Google button the login window
+/// uses, plus a compact status line that tracks the in-flight sign-in. Tapping it starts the real Google
+/// flow; the app delegate closes the onboarding card once `authenticationCompleted` fires.
+struct OnboardingGoogleSignInFooter: View {
+ @ObservedObject var authCoordinator: DonkeyAuthCoordinator
+
+ var body: some View {
+ VStack(spacing: 8) {
+ Button {
+ authCoordinator.beginGoogleSignIn()
+ } label: {
+ GoogleContinueAsset()
+ .opacity(buttonIsDisabled ? 0.58 : 1)
+ }
+ .buttonStyle(.plain)
+ .disabled(buttonIsDisabled)
+ .accessibilityLabel("Continue with Google")
+
+ statusText
+ .font(.system(size: 12, weight: .medium))
+ .foregroundStyle(statusColor)
+ .frame(height: 14)
+ }
+ }
+
+ private var buttonIsDisabled: Bool {
+ switch authCoordinator.phase {
+ case .openingBrowser, .waitingForCallback, .exchangingSession:
+ return true
+ default:
+ return false
+ }
+ }
+
+ @ViewBuilder
+ private var statusText: some View {
+ switch authCoordinator.phase {
+ case .waitingForCallback:
+ Text("Finish sign-in in your browser to continue.")
+ case .exchangingSession:
+ Text("Creating a secure Mac session...")
+ case .failed(let message):
+ Text(message)
+ default:
+ Text(" ")
+ }
+ }
+
+ private var statusColor: Color {
+ if case .failed = authCoordinator.phase {
+ return Color(red: 1.0, green: 0.47, blue: 0.36)
+ }
+
+ return .white.opacity(0.54)
+ }
+}
+
+struct GoogleContinueAsset: View {
var body: some View {
Group {
if let image = Self.image {
diff --git a/apps/Donkey/Sources/Donkey/Onboarding.swift b/apps/Donkey/Sources/Donkey/Onboarding.swift
index bf5c1ac7..390c2eef 100644
--- a/apps/Donkey/Sources/Donkey/Onboarding.swift
+++ b/apps/Donkey/Sources/Donkey/Onboarding.swift
@@ -27,6 +27,9 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
/// When `nil`, falls back to `imageBundle`, which is typically the caller's
/// module bundle.
let stringsBundle: Bundle?
+ /// Per-slide gradient backdrop rendered behind the artwork. When `nil`, the
+ /// slide falls back to the card's flat dark fill.
+ let background: OnboardingSlideBackground?
init(
id: UUID = UUID(),
@@ -35,7 +38,8 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
title: LocalizedStringKey,
description: LocalizedStringKey,
tableName: String? = nil,
- stringsBundle: Bundle? = nil
+ stringsBundle: Bundle? = nil,
+ background: OnboardingSlideBackground? = nil
) {
self.id = id
self.imageName = imageName
@@ -44,6 +48,7 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
self.description = description
self.tableName = tableName
self.stringsBundle = stringsBundle
+ self.background = background
}
/// Bundle used for localized string lookup. Prefers `stringsBundle`, then
@@ -61,6 +66,61 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
}
}
+/// A per-slide gradient backdrop. Every slide shares the same blue wash; only
+/// the spotlight distinguishes them — its position moves and its intensity
+/// visibly brightens and dims as the walkthrough advances.
+struct OnboardingSlideBackground: Sendable {
+ /// Where the spotlight bloom sits over the shared blue wash.
+ var bloomCenter: UnitPoint
+ /// Bloom strength, 0...1. Spread widely across slides so the brightness
+ /// shift reads clearly from one slide to the next.
+ var bloomIntensity: Double
+
+ /// The colour the wash resolves to at the bottom edge — matched to the card
+ /// fill so the gradient seams invisibly into the text panel below.
+ static let baseFill = Color(white: 0.10)
+}
+
+struct OnboardingSlideBackgroundView: View {
+ let background: OnboardingSlideBackground
+
+ /// The shared blue wash. Every slide uses these exact colours; only the
+ /// spotlight (position + intensity) changes between slides.
+ private static let washTop = Color(red: 0.16, green: 0.38, blue: 0.96)
+ private static let washMiddle = Color(red: 0.07, green: 0.17, blue: 0.52)
+ /// Bright sky-blue spotlight — kept blue rather than white so a strong bloom
+ /// glows without washing the hue out.
+ private static let bloomColor = Color(red: 0.60, green: 0.82, blue: 1.0)
+
+ var body: some View {
+ ZStack {
+ LinearGradient(
+ stops: [
+ .init(color: Self.washTop, location: 0.0),
+ .init(color: Self.washMiddle, location: 0.55),
+ .init(color: OnboardingSlideBackground.baseFill, location: 1.0)
+ ],
+ startPoint: .top,
+ endPoint: .bottom
+ )
+
+ RadialGradient(
+ colors: [
+ Self.bloomColor.opacity(background.bloomIntensity),
+ .clear
+ ],
+ center: background.bloomCenter,
+ startRadius: 0,
+ endRadius: 420
+ )
+ .blendMode(.screen)
+ }
+ // Flatten the blend into its own layer so the bloom screens only over
+ // this slide's wash, never over the artwork or controls above it.
+ .drawingGroup()
+ }
+}
+
struct OnboardingSlideshowView: View {
let pages: [OnboardingPage]
/// Fixed content width of the slideshow card. The image region's height
@@ -72,7 +132,16 @@ struct OnboardingSlideshowView: View {
let buttonTableName: String?
let buttonBundle: Bundle?
let onFinish: (() -> Void)?
+ /// Dismisses the card without finishing the tour. Wired to the top-right
+ /// close button so the user always has a way out — including a signed-out
+ /// user who doesn't want to sign in right now.
let onClose: (() -> Void)?
+ /// When non-nil, the FIRST slide is the sign-in landing — it renders this
+ /// footer (Donkey's Google button) with an "Explore" link beneath — and the
+ /// final feature slide renders the same footer so it takes the user straight
+ /// into sign-in. When `nil`, the tour is a plain walkthrough ending in the
+ /// finish button.
+ let signInFooter: (() -> AnyView)?
@Environment(\.dismiss) private var dismiss
@State var currentIndex: Int
@@ -85,7 +154,8 @@ struct OnboardingSlideshowView: View {
buttonTableName: String? = nil,
buttonBundle: Bundle? = nil,
onFinish: (() -> Void)? = nil,
- onClose: (() -> Void)? = nil
+ onClose: (() -> Void)? = nil,
+ signInFooter: (() -> AnyView)? = nil
) {
self.pages = pages
self.width = width
@@ -95,6 +165,7 @@ struct OnboardingSlideshowView: View {
self.buttonBundle = buttonBundle
self.onFinish = onFinish
self.onClose = onClose
+ self.signInFooter = signInFooter
_currentIndex = State(initialValue: Self.clamped(initialPageIndex, pageCount: pages.count))
}
@@ -156,6 +227,13 @@ struct OnboardingSlideshowView: View {
// `.id + .transition(.opacity)` subtree and visibly fade out and
// back in at the transition's midpoint.
ZStack(alignment: .top) {
+ if let background = pages[currentIndex].background {
+ OnboardingSlideBackgroundView(background: background)
+ .frame(width: width, height: imageHeight)
+ .id(currentIndex)
+ .transition(.opacity)
+ }
+
image(for: pages[currentIndex])
.resizable()
.scaledToFit()
@@ -178,10 +256,14 @@ struct OnboardingSlideshowView: View {
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
.allowsHitTesting(false)
- OnboardingPageIndicator(totalPages: pages.count, currentIndex: currentIndex)
- .padding(.bottom, 14)
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
- .allowsHitTesting(false)
+ OnboardingPageIndicator(totalPages: pages.count, currentIndex: currentIndex) { index in
+ goToPage(index)
+ }
+ // Bottom padding is 6 rather than 14 because each dot now carries a
+ // 24pt-tall hit band centred on its 8pt visual; the extra 8pt below
+ // the dot offsets the smaller pad so the dots sit where they did.
+ .padding(.bottom, 6)
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
topControls
}
@@ -209,7 +291,8 @@ struct OnboardingSlideshowView: View {
Spacer(minLength: 24)
- primaryActionButton
+ primaryActionArea
+ .frame(height: Self.primaryRegionHeight, alignment: .bottom)
}
.padding(.horizontal, 32)
.padding(.top, 12)
@@ -229,10 +312,13 @@ struct OnboardingSlideshowView: View {
goBack()
}
.opacity(currentIndex > 0 ? 1 : 0)
+ .allowsHitTesting(currentIndex > 0)
Spacer()
- iconButton(systemName: "checkmark") {
+ // Always-available escape hatch: closes the card on any slide, so a
+ // signed-out user who isn't ready to sign in can still dismiss it.
+ iconButton(systemName: "xmark") {
if let onClose {
onClose()
} else {
@@ -246,13 +332,39 @@ struct OnboardingSlideshowView: View {
// MARK: - Primary CTA
- private var primaryActionButton: some View {
- Button(action: advance) {
- Text(
- isLastPage ? finishButtonTitle : continueButtonTitle,
- tableName: buttonTableName,
- bundle: buttonBundle
- )
+ /// Fixed height reserved for the primary action, sized to the tallest case
+ /// (the sign-in footer: Google button + status + Explore link). Every slide
+ /// reserves it and bottom-aligns its button, so the window locks to one card
+ /// height and every CTA sits on the same baseline.
+ static let primaryRegionHeight: CGFloat = 96
+
+ /// Whether the current slide is the sign-in landing — the first slide, only
+ /// when a sign-in footer was injected (signed-out flow).
+ private var isSignInSlide: Bool {
+ signInFooter != nil && currentIndex == 0
+ }
+
+ @ViewBuilder
+ private var primaryActionArea: some View {
+ if let signInFooter, isSignInSlide {
+ // Sign-in landing: the Google button, with an Explore link beneath
+ // that drops into the feature tour.
+ VStack(spacing: 12) {
+ signInFooter()
+ exploreLink
+ }
+ } else if let signInFooter, isLastPage {
+ // The signed-out tour ends on the Google button itself, so the final
+ // slide takes the user straight into sign-in.
+ signInFooter()
+ } else {
+ capsuleButton(isLastPage ? finishButtonTitle : continueButtonTitle, action: advance)
+ }
+ }
+
+ private func capsuleButton(_ title: LocalizedStringKey, action: @escaping () -> Void) -> some View {
+ Button(action: action) {
+ Text(title, tableName: buttonTableName, bundle: buttonBundle)
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(.white)
.frame(width: 220, height: 42)
@@ -276,6 +388,22 @@ struct OnboardingSlideshowView: View {
.keyboardShortcut(.defaultAction)
}
+ /// "Explore Donkey ›" link under the sign-in button; jumps into the feature
+ /// tour, which walks forward and ends back at this sign-in slide.
+ private var exploreLink: some View {
+ Button(action: exploreFeatures) {
+ HStack(spacing: 4) {
+ Text("Explore Donkey")
+ Image(systemName: "chevron.right")
+ .font(.system(size: 10, weight: .semibold))
+ }
+ .font(.system(size: 13, weight: .medium))
+ .foregroundStyle(.white.opacity(0.72))
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ }
+
// MARK: - Icon button (glass circle)
private func iconButton(systemName: String, action: @escaping () -> Void) -> some View {
@@ -313,8 +441,6 @@ struct OnboardingSlideshowView: View {
if isLastPage {
if let onFinish {
onFinish()
- } else if let onClose {
- onClose()
} else {
dismiss()
}
@@ -329,6 +455,21 @@ struct OnboardingSlideshowView: View {
currentIndex = newIndex
}
+ /// From the sign-in landing, drop into the feature tour (the first feature
+ /// slide sits right after the sign-in slide).
+ func exploreFeatures() {
+ let target = min(1, pages.count - 1)
+ guard target != currentIndex else { return }
+ currentIndex = target
+ }
+
+ /// Jump straight to a slide, used by the clickable page-indicator dots.
+ func goToPage(_ index: Int) {
+ let target = Self.clamped(index, pageCount: pages.count)
+ guard target != currentIndex else { return }
+ currentIndex = target
+ }
+
private func image(for page: OnboardingPage) -> Image {
if let bundle = page.imageBundle,
let image = platformImage(named: page.imageName, in: bundle) {
@@ -422,18 +563,22 @@ final class OnboardingWindowController {
/// Presents the onboarding window. If a window is already visible, it is brought to the front.
///
- /// The window automatically closes when the user taps the checkmark or finishes the walkthrough.
- /// `onClose` and `onFinish` are invoked *before* the window is dismissed.
+ /// When the final slide shows the standard finish button, tapping it runs `onFinish` and then
+ /// closes the window. When a `signInFooter` is injected (Donkey's Google sign-in), slide 0 is the
+ /// sign-in landing and the window stays up until the caller closes it — typically once sign-in
+ /// completes. `initialPageIndex` chooses the slide to open on (e.g. the sign-in landing vs. the tour).
@discardableResult
func present(
pages: [OnboardingPage],
width: CGFloat = 660,
+ initialPageIndex: Int = 0,
continueButtonTitle: LocalizedStringKey = "Continue",
finishButtonTitle: LocalizedStringKey = "Done",
buttonTableName: String? = nil,
buttonBundle: Bundle? = nil,
onFinish: (() -> Void)? = nil,
- onClose: (() -> Void)? = nil
+ onDismiss: (() -> Void)? = nil,
+ signInFooter: (() -> AnyView)? = nil
) -> NSWindow {
if let existing = window {
existing.makeKeyAndOrderFront(nil)
@@ -451,35 +596,25 @@ final class OnboardingWindowController {
// button pin to the top, centre, and bottom of the remaining space
// respectively. Shorter slides simply get more breathing room.
let imageHeight = width / OnboardingSlideshowView.imageAspectRatio
- let maxPanelHeight = Self.maxBottomPanelHeight(
- pages: pages,
- width: width,
- continueButtonTitle: continueButtonTitle,
- finishButtonTitle: finishButtonTitle,
- buttonTableName: buttonTableName,
- buttonBundle: buttonBundle
- )
+ let maxPanelHeight = Self.maxBottomPanelHeight(pages: pages, width: width)
let totalHeight = max(imageHeight + maxPanelHeight, 1)
let rootView = OnboardingSlideshowView(
pages: pages,
width: width,
+ initialPageIndex: initialPageIndex,
continueButtonTitle: continueButtonTitle,
finishButtonTitle: finishButtonTitle,
buttonTableName: buttonTableName,
buttonBundle: buttonBundle,
onFinish: {
- if let onFinish {
- onFinish()
- } else {
- onClose?()
- }
+ onFinish?()
dismiss()
},
onClose: {
- onClose?()
dismiss()
- }
+ },
+ signInFooter: signInFooter
)
let contentSize = CGSize(width: width, height: totalHeight)
@@ -505,6 +640,7 @@ final class OnboardingWindowController {
let delegate = WindowDelegate { [weak self] in
self?.window = nil
self?.windowDelegate = nil
+ onDismiss?()
}
window.delegate = delegate
self.windowDelegate = delegate
@@ -525,23 +661,13 @@ final class OnboardingWindowController {
/// panel respectively).
private static func maxBottomPanelHeight(
pages: [OnboardingPage],
- width: CGFloat,
- continueButtonTitle: LocalizedStringKey,
- finishButtonTitle: LocalizedStringKey,
- buttonTableName: String?,
- buttonBundle: Bundle?
+ width: CGFloat
) -> CGFloat {
guard !pages.isEmpty else { return 0 }
- return pages.enumerated().map { index, page in
- let isLast = (index == pages.count - 1)
- let sizingView = OnboardingBottomPanelSizingView(
- page: page,
- buttonTitle: isLast ? finishButtonTitle : continueButtonTitle,
- buttonTableName: buttonTableName,
- buttonBundle: buttonBundle
- )
- .frame(width: width)
+ return pages.map { page in
+ let sizingView = OnboardingBottomPanelSizingView(page: page)
+ .frame(width: width)
let hosting = NSHostingView(rootView: sizingView)
hosting.layoutSubtreeIfNeeded()
@@ -569,12 +695,9 @@ final class OnboardingWindowController {
/// slideshow will render at runtime.
private struct OnboardingBottomPanelSizingView: View {
let page: OnboardingPage
- let buttonTitle: LocalizedStringKey
- let buttonTableName: String?
- let buttonBundle: Bundle?
var body: some View {
- VStack(spacing: 6) {
+ VStack(spacing: 0) {
Text(page.title, tableName: page.tableName, bundle: page.resolvedStringsBundle)
.font(.system(size: 28, weight: .bold))
.multilineTextAlignment(.center)
@@ -586,15 +709,15 @@ private struct OnboardingBottomPanelSizingView: View {
.multilineTextAlignment(.center)
.foregroundStyle(Color.white.opacity(0.70))
.fixedSize(horizontal: false, vertical: true)
- .padding(.bottom, 6)
+ .padding(.top, 6)
- Text(buttonTitle, tableName: buttonTableName, bundle: buttonBundle)
- .font(.system(size: 15, weight: .semibold))
- .frame(width: 220, height: 42)
- .padding(.top, 18)
+ Spacer(minLength: 24)
+
+ Color.clear
+ .frame(height: OnboardingSlideshowView.primaryRegionHeight)
}
.padding(.horizontal, 32)
- .padding(.top, 6)
+ .padding(.top, 12)
.padding(.bottom, 24)
}
}
@@ -604,22 +727,42 @@ private struct OnboardingBottomPanelSizingView: View {
struct OnboardingPageIndicator: View {
let totalPages: Int
let currentIndex: Int
+ /// Invoked with the tapped slide index when a dot is clicked.
+ let onSelect: (Int) -> Void
- init(totalPages: Int, currentIndex: Int) {
+ /// Visual gap between dots. It is baked into each dot's hit target rather
+ /// than the HStack spacing, so the space between dots reads the same while
+ /// the area immediately around each dot stays clickable.
+ private static let gap: CGFloat = 7
+
+ init(totalPages: Int, currentIndex: Int, onSelect: @escaping (Int) -> Void) {
self.totalPages = totalPages
self.currentIndex = currentIndex
+ self.onSelect = onSelect
}
var body: some View {
- HStack(spacing: 7) {
+ HStack(spacing: 0) {
ForEach(0..<totalPages, id: \.self) { index in
- Capsule(style: .continuous)
- .fill(index == currentIndex ? Color.white.opacity(0.95) : Color.white.opacity(0.32))
- .frame(width: index == currentIndex ? 24 : 8, height: 8)
+ let isCurrent = index == currentIndex
+ let dotWidth: CGFloat = isCurrent ? 24 : 8
+ Button {
+ onSelect(index)
+ } label: {
+ Capsule(style: .continuous)
+ .fill(isCurrent ? Color.white.opacity(0.95) : Color.white.opacity(0.32))
+ .frame(width: dotWidth, height: 8)
+ // Grow the hit target around the small dot — the gap to
+ // its neighbour plus a comfortable vertical band — without
+ // changing how the dot itself looks.
+ .frame(width: dotWidth + Self.gap, height: 24)
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .accessibilityLabel("Go to page \(index + 1)")
+ .accessibilityAddTraits(isCurrent ? [.isSelected] : [])
}
}
- .accessibilityElement(children: .ignore)
- .accessibilityLabel("Page \(currentIndex + 1) of \(max(totalPages, 1))")
}
}
@@ -632,36 +775,68 @@ struct OnboardingPageIndicator: View {
/// them as `.copy(...)` resources in `Package.swift`, and name them to match
/// the `imageName` values below.
enum OnboardingTour {
- static let pages: [OnboardingPage] = [
+ /// The sign-in landing — the first slide when signed out. Its call-to-action
+ /// is the injected Google sign-in footer plus the Explore link; the feature
+ /// tour walks forward and returns here to sign in.
+ static let signInPage = OnboardingPage(
+ imageName: "onboarding-signin",
+ imageBundle: DonkeyResourceBundle.app,
+ title: "Sign in to Donkey",
+ description: "Continue with Google to put Donkey to work on your Mac.",
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.50, y: 0.16), bloomIntensity: 0.95)
+ )
+
+ /// The feature slides — the walkthrough reached by Explore (signed out) or
+ /// shown directly (signed-in replay).
+ static let featurePages: [OnboardingPage] = [
OnboardingPage(
imageName: "onboarding-welcome",
imageBundle: DonkeyResourceBundle.app,
title: "Welcome to Donkey",
- description: "Your AI assistant that gets things done right on your Mac."
+ description: "Your AI assistant that gets things done right on your Mac.",
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.26, y: 0.30), bloomIntensity: 0.30)
),
OnboardingPage(
imageName: "onboarding-ask",
imageBundle: DonkeyResourceBundle.app,
title: "Just ask, in plain language",
- description: "Type or speak a request and Donkey figures out the steps."
+ description: "Type or speak a request and Donkey figures out the steps.",
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.74, y: 0.18), bloomIntensity: 0.60)
),
OnboardingPage(
imageName: "onboarding-apps",
imageBundle: DonkeyResourceBundle.app,
title: "It works your apps for you",
- description: "Donkey clicks, types, and navigates across the apps you already use."
+ description: "Donkey clicks, types, and navigates across the apps you already use.",
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.50, y: 0.40), bloomIntensity: 0.50)
),
OnboardingPage(
imageName: "onboarding-follow",
imageBundle: DonkeyResourceBundle.app,
title: "Follow along every step",
- description: "Watch what Donkey is doing in the notch as it works."
- ),
- OnboardingPage(
- imageName: "onboarding-ready",
- imageBundle: DonkeyResourceBundle.app,
- title: "You're all set",
- description: "Sign in to start putting Donkey to work."
+ description: "Watch what Donkey is doing in the notch as it works.",
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.80, y: 0.22), bloomIntensity: 0.80)
)
]
+
+ /// Closing slide when the user is already signed in (menu replay): a plain
+ /// wrap-up whose Done button dismisses the card.
+ static let finishedPage = OnboardingPage(
+ imageName: "onboarding-ready",
+ imageBundle: DonkeyResourceBundle.app,
+ title: "You're all set",
+ description: "Donkey is ready whenever you are.",
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.46, y: 0.16), bloomIntensity: 1.00)
+ )
+
+ /// Signed out: the sign-in landing leads the feature tour. Signed in: the
+ /// feature tour ends on a plain wrap-up. The sign-in slide is always index 0
+ /// when present, which the slideshow relies on for the Explore / return flow.
+ static func pages(isSignedIn: Bool) -> [OnboardingPage] {
+ if isSignedIn {
+ return featurePages + [finishedPage]
+ } else {
+ return [signInPage] + featurePages
+ }
+ }
}