Sources/Orgstar/FlashcardWindow.swift

c98c5d987c74e64b70f0263e5f8c44b1ae29c815
orgstar/Sources/Orgstar/FlashcardWindow.swift

27 lines · 1014 bytes

 1import OrgApp
 2import SwiftUI
 3
 4/// Window ▸ Review Flashcards: the cards due across the workspace, reviewed one at a time.
 5/// Opening a card shows its heading in the main window.
 6struct FlashcardWindow: View {
 7    let commands: AppCommands
 8    @State private var review: FlashcardReview
 9    @Environment(\.openWindow) private var openWindow
10
11    init(workspace: WorkspaceModel, session: DocumentSession, commands: AppCommands) {
12        self.commands = commands
13        _review = State(initialValue: FlashcardReview(workspace: workspace, session: session))
14    }
15
16    var body: some View {
17        FlashcardReviewView(review: review) { path, offset in
18            if !commands.mainWindowOpen { openWindow(id: "main") }
19            commands.jump(path: path, offset: offset)
20        }
21        .frame(minWidth: 420, minHeight: 360)
22        .navigationTitle("Review Flashcards")
23        .toolbar {
24            Button("Start Again", systemImage: "arrow.clockwise") { Task { await review.start() } }
25        }
26    }
27}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form