oficina / memoria Public

Clone
git clone https://amadan.net/oficina/memoria

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS) && canImport(RastrilloMacUpdates)
2import RastrilloMacUpdates
3#endif
4import MemoriaKit
5import RastrilloApple
6import SwiftUI
7
8@main struct MemoriaApp: App {
9 #if os(macOS) && canImport(RastrilloMacUpdates)
10 // Quiet, as Calls and Calendar: a scheduled check never opens a window;
11 // an update downloads in the background and installs on quit. Needs
12 // "install": "automatic" in mac-updates.json too (rastrillo/native
13 // docs/mac-updates.md).
14 @State private var updater = NativeUpdater(policy: .quiet)
15 #endif
16 @StateObject private var connection = NativeConnection(defaultServer: "https://memoria.oficina.works")
17 var body: some Scene {
18 WindowGroup {
19 Group {
20 if let client = connection.client { MemoriaWorkspace(client: client, accounts: connection.showAccounts, signOut: connection.signOut) }
21 else { NativeAccountsView("Memoria", systemImage: "books.vertical", connection: connection) }
22 }.id(connection.activeAccountID).onOpenURL(perform: connection.handleOpenURL).tint(Color(red: 0.48, green: 0.32, blue: 0.68))
23 #if os(macOS)
24 .frame(minWidth: 800, minHeight: 580)
25 #endif
26 #if os(macOS) && canImport(RastrilloMacUpdates)
27 // The quiet updater's one line, only while an update is pending: where
28 // an update that needs the person (automatic downloads off) shows up.
29 .safeAreaInset(edge: .bottom) {
30 if updater.canInstallPendingUpdate { NativeUpdateNotice(updater: updater).padding(.bottom, 12) }
31 }
32 #endif
33 }
34 #if os(macOS)
35 .defaultSize(width: 1120, height: 780)
36 .commands {
37 // First, so About, Hide, Quit and Help say "Memoria", not the display
38 // name "Oficina Memoria", and Check for Updates (after .appInfo) stays.
39 PlainAppNameCommands()
40 // The Help group it replaces carried SwiftUI's hidden ⌥⌘S sidebar
41 // alias; View ▸ Show Sidebar (⌃⌘S) keeps the split view's sidebar.
42 SidebarCommands()
43 #if canImport(RastrilloMacUpdates)
44 NativeUpdateCommands(updater: updater)
45 #endif
46 }
47 #endif
48 }
49}
50