dc42db0c59
Replace the single hand-saved rig file with a managed library of named rigs persisted in app storage and synced across devices and both builder apps via a shared iCloud container (iCloud.net.realizedsound.ShoeGazeData), falling back to local storage when iCloud is unavailable. Core (LyrebirdShoeGaze/Presets): - RigEntry: named, timestamped ShoeGazeState (a whole multi-board rig). - RigArchive: portable multi-rig JSON bundle for backup/transfer; legacy single-rig files import as a one-rig archive. - RigLibraryStore (@MainActor @Observable): one JSON file per rig, with NSFileCoordinator writes and NSMetadataQuery live remote-change watching. - RigLibraryLocation: iCloud-or-local directory resolver (skips the slow ubiquity lookup when no iCloud account is signed in). - ShoeGaze.loadRig(from: ShoeGazeState) + captureEntry; shared filename sanitizer factored out of BoardVersionStore. UI (LyrebirdShoeGazeUI): - RigLibrarySidebarView: persistent left listing with new/save/save-as/ duplicate/rename/delete/erase-all and archive import/export. - RigNamePrompt; RigLibraryBootstrap one-call shell setup. - ShoeGazeBuilderView: sidebar wired in; selecting a rig replaces the session; File menu / sidebar do whole-library archive import/export. Shells/entitlements: both builder targets own+start the store and carry the iCloud Documents entitlement; NSUbiquitousContainers exposes the rigs in the Files app. (macOS pbxproj also carries a pre-existing 1.0->1.1.1 version bump.) Tests: RigEntry/RigArchive round-trip + RigLibraryStore CRUD/import/export (15 new; full suite 206 passing). Provisioning (manual, not done here): enable the iCloud container on both App IDs and select it in Signing & Capabilities for both targets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
72 lines
2.2 KiB
Swift
72 lines
2.2 KiB
Swift
// RigNamePrompt.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import SwiftUI
|
|
|
|
/// A request to prompt the user for a rig name (New, Save As, Rename, Duplicate).
|
|
///
|
|
/// Presented via the ``SwiftUI/View/rigNamePrompt(_:)`` modifier. Setting a non-`nil` value shows a
|
|
/// text-entry alert seeded with `initialText`; committing a non-empty, trimmed name invokes
|
|
/// `onCommit`. Cancelling dismisses without calling `onCommit`.
|
|
struct RigNamePrompt: Identifiable {
|
|
|
|
let id: UUID = UUID()
|
|
|
|
/// Alert title, e.g. `"Save Rig As"`.
|
|
let title: String
|
|
|
|
/// Text the field is pre-filled with (e.g. the existing name for a rename).
|
|
let initialText: String
|
|
|
|
/// Confirm-button label, e.g. `"Save"` or `"Rename"`.
|
|
let confirmLabel: String
|
|
|
|
/// Invoked with the trimmed, non-empty name when the user confirms.
|
|
let onCommit: (String) -> Void
|
|
}
|
|
|
|
private struct RigNamePromptModifier: ViewModifier {
|
|
|
|
@Binding var prompt: RigNamePrompt?
|
|
@State private var text: String = ""
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.onChange(of: prompt?.id) {
|
|
// Seed the field whenever a new prompt is presented.
|
|
text = prompt?.initialText ?? ""
|
|
}
|
|
.alert(
|
|
prompt?.title ?? "",
|
|
isPresented: isPresented,
|
|
presenting: prompt
|
|
) { active in
|
|
TextField("Name", text: $text)
|
|
Button(active.confirmLabel) {
|
|
let trimmed: String = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
if !trimmed.isEmpty { active.onCommit(trimmed) }
|
|
}
|
|
Button("Cancel", role: .cancel) { }
|
|
}
|
|
}
|
|
|
|
private var isPresented: Binding<Bool> {
|
|
Binding(
|
|
get: { prompt != nil },
|
|
set: { presented in if !presented { prompt = nil } }
|
|
)
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
|
|
/// Presents a rig-name entry alert driven by `prompt`. Set the binding to a ``RigNamePrompt``
|
|
/// to show it; it clears itself on dismiss.
|
|
func rigNamePrompt(_ prompt: Binding<RigNamePrompt?>) -> some View {
|
|
modifier(RigNamePromptModifier(prompt: prompt))
|
|
}
|
|
}
|