eleven / messenger Public

Clone
git clone https://amadan.net/eleven/messenger

Plain git — no account needed to clone.

Download

Download this file

1import SwiftUI
2import LChatCore
3
4// 🤖 The native surface for a schema-described app thread (To-do, Reminders):
5// the Interface view is SchemaAppView — native components assembled from the
6// app's schema — with the companion Chat view (the same DM-with-the-app the
7// web offers) switched from the ⋮ menu (AppViewPicker rows — dropdown items,
8// never a segmented control in the bar) and rendered by the native feed. The
9// webview is out of the loop entirely for these apps; apps without a schema
10// get the same shape from AppThreadScreen, with a webview only as the
11// Interface.
12struct SchemaAppScreen: View {
13 let instance: SavedInstance
14 let thread: ChatThread
15 @ObservedObject var store: ThreadStore
16 let schemaStore: SchemaAppStore
17
18 // The Interface IS the app (the web's takeover default); Chat is the
19 // companion conversation, a menu pick away.
20 @State private var mode = "interface" // "chat" | "interface"
21 // Passed through to the companion chat: its profile cards hop threads.
22 @Binding private var path: [Route]
23 @Environment(\.dismiss) private var dismiss
24
25 init?(instance: SavedInstance, thread: ChatThread, store: ThreadStore,
26 path: Binding<[Route]>) {
27 guard let schemaStore = SchemaAppStoreCache.shared.store(for: instance, thread: thread,
28 myUserId: store.myUserId) else { return nil }
29 self.instance = instance
30 self.thread = thread
31 self.store = store
32 self.schemaStore = schemaStore
33 self._path = path
34 }
35
36 var body: some View {
37 if mode == "chat" {
38 NativeChatScreen(instance: instance, thread: thread, store: store,
39 path: $path, appView: $mode)
40 } else {
41 SchemaAppView(store: schemaStore)
42 .navigationTitle(thread.title)
43 .navigationBarTitleDisplayMode(.inline)
44 .toolbar {
45 ToolbarItem(placement: .primaryAction) {
46 AppInterfaceKebab(store: store, thread: thread,
47 appView: $mode,
48 onClose: { dismiss() })
49 }
50 }
51 }
52 }
53}
54