SPB Git

Repository Public

CaptureHook.swift 1.4 KB 30 lines swift

1// SP Notes iOS2// File: Features/Root/CaptureHook.swift3// Description: CAPTURE HOOK — the single place where a capture request is honoured (centre tab button, ⌥⌘N, the command4//              palette, `spnotes://capture[?kind=…]`, `AppRoute.capture`). The Quick Capture wave replaces the body of5//              `present` with its sheet; until then a capture opens the 1.0 new-note flow (a task-list note for `kind=tasks`).6//7// Author: Simon-Pierre Boucher8// Contact: contact@spboucher.ai9import SwiftUI1011@MainActor12enum CaptureHook {13    /// Called by `MainInterface` for each `ShellState.requestCapture(kind:)`.14    /// QUICK CAPTURE: present the capture sheet here (`request.kind` is a `DeepLink.CaptureKind` raw value or nil).15    static func present(_ request: ShellCaptureRequest, app: AppModel, shell: ShellState) {16        if request.kind == DeepLink.CaptureKind.tasks.rawValue {17            // `kind=tasks` starts a task list, as `spnotes://new?kind=tasks` does18            Task {19                await app.attempt {20                    let id = try await app.quickCreate(title: nil, text: "", kind: .tasks)21                    shell.open(note: id, isNew: true)22                }23            }24        } else {25            // the Quick Capture sheet (Features/Capture), in the mode asked for (text by default)26            shell.quickCapture = CaptureRequest(mode: CaptureMode(route: request.kind) ?? .text)27        }28    }29}30
Files main
Menu

Theme