Repository Public
1// SP Notes iOS2// File: Features/Home/NewNoteButton.swift3// Description: The "new note" button of the navigation bars. A tap creates a note at once (in the list shown) and opens it; a4// long press offers a new folder. (1.0 floated it above the iPhone lists; with the tab bar it lives in the bar.)5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import SwiftUI910struct NewNoteButton: View {11 var source: NoteSource?12 @Environment(AppModel.self) private var app13 @Environment(ShellState.self) private var shell14 @State private var isCreating = false1516 var body: some View {17 Menu {18 Button { create() } label: { Label("Nouvelle note", systemImage: "square.and.pencil") }19 Button { shell.sheet = NewFolderTarget.sheet(for: source) } label: { Label("Nouveau dossier", systemImage: "folder.badge.plus") }20 } label: {21 Label("Nouvelle note", systemImage: "square.and.pencil")22 } primaryAction: {23 create()24 }25 .accessibilityLabel("Nouvelle note")26 .accessibilityHint("Touche de façon prolongée pour créer un dossier")27 .accessibilityIdentifier("new-note")28 }2930 private func create() {31 guard !isCreating else { return }32 isCreating = true33 Task {34 await NoteCommands(app: app, shell: shell).newNote(in: source)35 isCreating = false36 }37 }38}39