diff --git a/ShhShell/Views/ContentView.swift b/ShhShell/Views/ContentView.swift index 1466ed5..e6f498f 100644 --- a/ShhShell/Views/ContentView.swift +++ b/ShhShell/Views/ContentView.swift @@ -12,102 +12,90 @@ struct ContentView: View { @ObservedObject var hostsManager: HostsManager @ObservedObject var keyManager: KeyManager - @State private var spawnTime: Date = .now - var body: some View { - TimelineView(.animation) { tl in - let time = tl.date.distance(to: spawnTime) - NavigationStack { - ZStack { - hostsManager.selectedTheme.background.suiColor.opacity(0.7) - .ignoresSafeArea(.all) - List { - SessionsListView( - handler: handler, - hostsManager: hostsManager, - keyManager: keyManager - ) - - RecentsView( - hostsManager: hostsManager, - keyManager: keyManager - ) - - HostsView( - handler: handler, - hostsManager: hostsManager, - keyManager: keyManager - ) - - Section() { - NavigationLink { - ThemeManagerView(hostsManager: hostsManager) - } label: { - Label("Themes", systemImage: "swatchpalette") - } - NavigationLink { - FontManagerView(hostsManager: hostsManager) - } label: { - Label("Fonts", systemImage: "textformat") - } - } - - Section { - NavigationLink { - SnippetManagerView(hostsManager: hostsManager) - } label: { - Label("Snippets", systemImage: "paperclip") - } - - NavigationLink { - KeyManagerView(hostsManager: hostsManager, keyManager: keyManager) - } label: { - Label("Keys", systemImage: "key.fill") - } - - NavigationLink { - HostkeysView(hostsManager: hostsManager) - } label: { - Label("Hostkey Fingerprints", systemImage: "lock.display") - } - } - - Section { - NavigationLink { - SettingsView(hostsManager: hostsManager, keyManager: keyManager) - } label: { - Label("Settings", systemImage: "gear") - } - NavigationLink { - AboutView(hostsManager: hostsManager) - } label: { - Label("About", systemImage: "info.square") - } - } - } - .scrollContentBackground(.hidden) - } - .navigationTitle("ShhShell") - .toolbar { - ToolbarItem(placement: .confirmationAction) { + NavigationStack { + ZStack { + hostsManager.selectedTheme.background.suiColor.opacity(0.7) + .ignoresSafeArea(.all) + List { + SessionsListView( + handler: handler, + hostsManager: hostsManager, + keyManager: keyManager + ) + + RecentsView( + hostsManager: hostsManager, + keyManager: keyManager + ) + + HostsView( + handler: handler, + hostsManager: hostsManager, + keyManager: keyManager + ) + + Section() { NavigationLink { - ConnectionView( - handler: SSHHandler(host: Host.blank, keyManager: keyManager), - hostsManager: hostsManager, - keyManager: keyManager - ) + ThemeManagerView(hostsManager: hostsManager) } label: { - Label("Add", systemImage: "plus") + Label("Themes", systemImage: "swatchpalette") + } + NavigationLink { + FontManagerView(hostsManager: hostsManager) + } label: { + Label("Fonts", systemImage: "textformat") + } + } + + Section { + NavigationLink { + SnippetManagerView(hostsManager: hostsManager) + } label: { + Label("Snippets", systemImage: "paperclip") + } + + NavigationLink { + KeyManagerView(hostsManager: hostsManager, keyManager: keyManager) + } label: { + Label("Keys", systemImage: "key.fill") + } + + NavigationLink { + HostkeysView(hostsManager: hostsManager) + } label: { + Label("Hostkey Fingerprints", systemImage: "lock.display") + } + } + + Section { + NavigationLink { + SettingsView(hostsManager: hostsManager, keyManager: keyManager) + } label: { + Label("Settings", systemImage: "gear") + } + NavigationLink { + AboutView(hostsManager: hostsManager) + } label: { + Label("About", systemImage: "info.square") } } } + .scrollContentBackground(.hidden) } - .visualEffect { content, proxy in - content - .colorEffect(ShaderLibrary.crt( - .float2(proxy.size), - .float(time) - )) + .navigationTitle("ShhShell") + .toolbar { + ToolbarItem(placement: .confirmationAction) { + NavigationLink { + ConnectionView( + handler: SSHHandler(host: Host.blank, keyManager: keyManager), + hostsManager: hostsManager, + keyManager: keyManager + ) + } label: { + Label("Add", systemImage: "plus") + } + } } } } @@ -115,7 +103,7 @@ struct ContentView: View { #Preview { let keymanager = KeyManager() - ContentView( + ContentView( handler: SSHHandler(host: Host.debug, keyManager: keymanager), hostsManager: HostsManager(), keyManager: keymanager diff --git a/ShhShell/Views/Terminal/ShellView.swift b/ShhShell/Views/Terminal/ShellView.swift index 5304f62..af84876 100644 --- a/ShhShell/Views/Terminal/ShellView.swift +++ b/ShhShell/Views/Terminal/ShellView.swift @@ -16,32 +16,48 @@ struct ShellView: View { @Environment(\.dismiss) var dismiss + @State var startTime: Date = .now + var body: some View { NavigationStack { ZStack { - hostsManager.selectedTheme.background.suiColor - .ignoresSafeArea(.all) - TerminalController(handler: handler, hostsManager: hostsManager) - - Group { - Color.gray.opacity(0.2) - .transition(.opacity) - Image(systemName: "bell.fill") - .foregroundStyle( - hostsManager.selectedTheme.background.luminance > 0.5 ? - .black : .white - ) - .font(.largeTitle) - .shadow(color: .black, radius: 5) - } - .opacity(handler.bell ? 1 : 0) - .onChange(of: handler.bell) { _ in - guard handler.bell else { return } - if hostsManager.settings.bellHaptic { - Haptic.warning.trigger() + TimelineView(.animation) { tl in + let time = tl.date.distance(to: startTime) + let shaderEnabled = hostsManager.settings.filter == .crt + hostsManager.selectedTheme.background.suiColor + .ignoresSafeArea(.all) + TerminalController(handler: handler, hostsManager: hostsManager) + + Group { + Color.gray.opacity(0.2) + .transition(.opacity) + Image(systemName: "bell.fill") + .foregroundStyle( + hostsManager.selectedTheme.background.luminance > 0.5 ? + .black : .white + ) + .font(.largeTitle) + .shadow(color: .black, radius: 5) } - if hostsManager.settings.bellSound { - AudioServicesPlaySystemSound(1103) + .opacity(handler.bell ? 1 : 0) + .onChange(of: handler.bell) { _ in + guard handler.bell else { return } + if hostsManager.settings.bellHaptic { + Haptic.warning.trigger() + } + if hostsManager.settings.bellSound { + AudioServicesPlaySystemSound(1103) + } + } + .visualEffect { content, proxy in + content + .colorEffect( + ShaderLibrary.crt( + .float2(proxy.size), + .float(time) + ), + isEnabled: shaderEnabled + ) } } }