Sources/OrgstarMobile/FlashcardScreen.swift
29 lines · 992 bytes
1 symbol in this file
1#if os(iOS)
2import OrgApp
3import SwiftUI
4
5/// The flashcard review on iPhone and iPad, full screen. `done` closes it, with a card's file
6/// and heading to open when Open in Editor was chosen.
7struct FlashcardScreen: View {
8 let done: (String?, Int) -> Void
9 @State private var review: FlashcardReview
10
11 init(workspace: WorkspaceModel, session: DocumentSession, done: @escaping (String?, Int) -> Void) {
12 self.done = done
13 _review = State(initialValue: FlashcardReview(workspace: workspace, session: session))
14 }
15
16 var body: some View {
17 NavigationStack {
18 FlashcardReviewView(review: review) { path, offset in done(path, offset) }
19 .navigationTitle("Review")
20 .navigationBarTitleDisplayMode(.inline)
21 .toolbar {
22 ToolbarItem(placement: .cancellationAction) {
23 Button("Done") { done(nil, 0) }
24 }
25 }
26 }
27 }
28}
29#endif