Sources/OrgstarMobile/RoamGraphScreen.swift

63ae15b64d76b8b7c4d413cf6a6c5434c50d402d
orgstar/Sources/OrgstarMobile/RoamGraphScreen.swift

33 lines · 1084 bytes

 1#if os(iOS)
 2import OrgApp
 3import OrgCore
 4import OrgIndex
 5import SwiftUI
 6
 7/// The workspace's nodes and links, as the Mac's Graph window draws them; a tap on a node
 8/// opens it.
 9struct RoamGraphScreen: View {
10    let workspace: WorkspaceModel
11    let session: DocumentSession
12    let path: String
13    let caret: Int
14    let open: (HeadingLocation) -> Void
15    @Environment(\.dismiss) private var dismiss
16
17    private var current: String? {
18        session.document(of: path).flatMap { RoamGraph.current(tree: $0.tree, at: caret, path: path, denote: OrgPreferences.usesDenote()) }
19    }
20
21    var body: some View {
22        NavigationStack {
23            RoamGraphView(load: { workspace.roamGraph(overlay: workspace.overlay(session.openDocuments)) }, current: current, version: 0) { location in
24                dismiss()
25                open(location)
26            }
27            .navigationTitle("Node Graph")
28            .navigationBarTitleDisplayMode(.inline)
29            .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { dismiss() } } }
30        }
31    }
32}
33#endif
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