Open History to see the last commit
1import SwiftUI
2
3struct JOLSettingsView: View {
4 @ObservedObject var connection: JOLController
5 @State private var confirmHistory = false
6 @State private var confirmDetails = false
7 var body: some View {
8 VStack(alignment: .leading, spacing: 18) {
9 Text("Your explorer. On line.").font(.custom("Caveat", size: 27))
10 Text("Read Jerry’s journals and send directions from your browser. Choose a JOL server you trust—or keep everything on this Mac.")
11 .font(.system(size: 12)).foregroundStyle(Color(nsColor: NotebookTheme.faded))
12 if connection.connected {
13 GroupBox {
14 VStack(alignment: .leading, spacing: 10) {
15 Text(connection.manifest?.name ?? "Jerry On Line").font(.headline)
16 Text(connection.manifest?.origin ?? connection.address).font(.system(size: 12))
17 Text(connection.status).font(.system(size: 12)).accessibilityLabel("JOL status: " + connection.status)
18 if let synced = connection.lastSync { Text("Last synced \(synced, style: .relative) ago").font(.system(size: 11)).foregroundStyle(.secondary) }
19 HStack {
20 Button("Open JOL") { connection.openWebsite() }
21 Button("Disconnect") { connection.disconnect() }
22 }
23 }.frame(maxWidth: .infinity, alignment: .leading).padding(8)
24 }
25 GroupBox {
26 VStack(alignment: .leading, spacing: 10) {
27 Toggle("Allow remote missions", isOn: Binding(get: { connection.remoteArmed }, set: { connection.setRemoteArmed($0) }))
28 Text("Remote directions use this Mac and its AI connection. Taking manual control pauses remote missions. Enable them again here when you’re ready, then close Settings.")
29 .font(.system(size: 12)).foregroundStyle(.secondary)
30 }.padding(8)
31 }
32 GroupBox("Journal sharing") {
33 VStack(alignment: .leading, spacing: 10) {
34 Text("Sharing notes\(connection.sharePhotos ? ", photographs" : "")\(connection.shareDetails || connection.backfillDetails ? ", and technical details" : "").")
35 if connection.includeHistory {
36 Text("Older expeditions are included.").foregroundStyle(.secondary)
37 } else {
38 Button("Share Older Expeditions…") { confirmHistory = true }
39 }
40 if !connection.shareDetails && !connection.backfillDetails {
41 Button("Share Technical Details…") { confirmDetails = true }
42 .disabled(connection.working)
43 }
44 if let issue = connection.sharingIssue {
45 Text(issue).font(.system(size: 11)).foregroundStyle(.secondary)
46 }
47 }.frame(maxWidth: .infinity, alignment: .leading).padding(8)
48 }
49 } else {
50 VStack(alignment: .leading, spacing: 10) {
51 TextField("https://jol.example.com", text: $connection.address).textFieldStyle(.roundedBorder)
52 .disabled(connection.working).onSubmit { connection.checkServer() }.accessibilityLabel("JOL server address")
53 .onChange(of: connection.address) { _, _ in connection.serverAddressChanged() }
54 if connection.manifest == nil {
55 Button("Find Server") { connection.checkServer() }.disabled(connection.working || connection.address.isEmpty)
56 } else {
57 Text(connection.manifest?.name ?? "Jerry On Line").font(.headline)
58 Text(connection.manifest?.origin ?? "").font(.system(size: 12)).foregroundStyle(.secondary)
59 Toggle("Share journal photographs", isOn: $connection.sharePhotos)
60 Toggle("Share technical details", isOn: $connection.shareDetails)
61 Toggle("Also share existing expeditions", isOn: $connection.includeHistory)
62 Text("New expeditions are shared when connected. Photographs and details can contain screen content. Your server’s operator can read shared journals; enabling remote missions also trusts that server to send directions.")
63 .font(.system(size: 11)).foregroundStyle(.secondary)
64 HStack {
65 Button("Connect in Browser") { connection.connect() }.disabled(connection.working)
66 if connection.working { Button("Cancel") { connection.cancelSignIn() } }
67 else { Button("Change Server") { connection.checkServer() } }
68 }
69 }
70 Text(connection.status).font(.system(size: 12)).fixedSize(horizontal: false, vertical: true)
71 }.padding(14).background(Color(nsColor: NotebookTheme.leather).opacity(0.045), in: RoundedRectangle(cornerRadius: 7))
72 Text("AI credentials stay on this Mac. Disconnecting JOL never stops local journal saving or removes your AI connection.")
73 .font(.system(size: 11)).foregroundStyle(.secondary)
74 }
75 }
76 .frame(width: 532, alignment: .leading)
77 .foregroundStyle(Color(nsColor: NotebookTheme.ink))
78 .tint(Color(nsColor: NotebookTheme.ink))
79 .font(.system(size: 13))
80 .confirmationDialog("Share older expeditions?", isPresented: $confirmHistory) {
81 Button("Share Older Expeditions") { connection.shareOlderExpeditions() }
82 } message: {
83 Text("Upload expeditions saved on this Mac before you connected, using your current sharing choices.")
84 }
85 .confirmationDialog("Share technical details?", isPresented: $confirmDetails) {
86 Button("Share Technical Details") { connection.shareTechnicalDetails() }
87 } message: {
88 Text("Include technical details from past and future shared expeditions. Details may contain screen content.")
89 }
90 }
91}