From 100ffb03499bac3209f20f4ca511f9a313e6b1a0 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Fri, 8 Aug 2025 08:46:28 +0100 Subject: [PATCH] snippets can only be added if both name and content arent empty hosts only get added if they have been modified updated the popover to have concentric corner radiuses for the selection thingy added navigation title shhshell --- ShhShell/Host/Host.swift | 1 + ShhShell/Host/HostsManager.swift | 12 ++++-------- ShhShell/Views/ContentView.swift | 1 + ShhShell/Views/Hosts/HostSymbolPicker.swift | 15 +++++++++++++-- ShhShell/Views/Snippets/AddSnippetView.swift | 1 + ShhShell/Views/Terminal/ShellTabView.swift | 1 - 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ShhShell/Host/Host.swift b/ShhShell/Host/Host.swift index e33bbfa..c31e2ba 100644 --- a/ShhShell/Host/Host.swift +++ b/ShhShell/Host/Host.swift @@ -72,6 +72,7 @@ extension Host { static var blank: Host { Host(address: "") } + static var debug: Host { Host( name: "name for localhost", diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index bafecb0..028af07 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -15,7 +15,7 @@ class HostsManager: ObservableObject, @unchecked Sendable { @Published var hosts: [Host] = [] @Published var themes: [Theme] = [] - @Published var selectedTheme: Theme = Theme.defaultTheme + @Published var selectedTheme: Theme = Theme.decodeLocalTheme(fileName: "xcodeDarkHC") ?? Theme.defaultTheme @Published var selectedAnsi: Int = 1 @Published var fonts: [UIFont] = [] @@ -223,16 +223,12 @@ class HostsManager: ObservableObject, @unchecked Sendable { } func updateHost(_ updatedHost: Host) { -// let oldID = updatedHost.id + var blankHost = Host.blank + blankHost.id = updatedHost.id + guard updatedHost != blankHost else { return } if let index = hosts.firstIndex(where: { $0.id == updatedHost.id }) { withAnimation { hosts[index] = updatedHost } -// var updateHostWithNewID = updatedHost -// updateHostWithNewID.id = UUID() -// withAnimation { hosts[index] = updateHostWithNewID } -// -// updateHostWithNewID.id = oldID -// withAnimation { hosts[index] = updateHostWithNewID } saveHosts() } else { withAnimation { hosts.append(updatedHost) } diff --git a/ShhShell/Views/ContentView.swift b/ShhShell/Views/ContentView.swift index deb0cb1..85889c8 100644 --- a/ShhShell/Views/ContentView.swift +++ b/ShhShell/Views/ContentView.swift @@ -73,6 +73,7 @@ struct ContentView: View { } .scrollContentBackground(.hidden) } + .navigationTitle("ShhShell") .toolbar { ToolbarItem(placement: .confirmationAction) { NavigationLink { diff --git a/ShhShell/Views/Hosts/HostSymbolPicker.swift b/ShhShell/Views/Hosts/HostSymbolPicker.swift index 42ba91b..ebce288 100644 --- a/ShhShell/Views/Hosts/HostSymbolPicker.swift +++ b/ShhShell/Views/Hosts/HostSymbolPicker.swift @@ -12,11 +12,19 @@ struct HostSymbolPicker: View { @Environment(\.colorScheme) var cScheme + var innerR: CGFloat { + if #available(iOS 19, *) { + return 16 + } else { + return 3 + } + } + var body: some View { ZStack { Rectangle() .foregroundStyle(cScheme == .dark ? .black : .gray) - VStack(alignment: .center, spacing: 10) { + VStack(alignment: .center, spacing: 0) { ScrollView(.horizontal) { HStack { ForEach(HostSymbol.allCases, id: \.self) { symbol in @@ -24,7 +32,7 @@ struct HostSymbolPicker: View { if host.symbol == symbol { Rectangle() .fill(.gray.opacity(0.5)) - .clipShape(RoundedRectangle(cornerRadius: 5)) + .clipShape(RoundedRectangle(cornerRadius: innerR)) } HostSymbolPreview(symbol: symbol, label: host.label) .padding(10) @@ -37,10 +45,13 @@ struct HostSymbolPicker: View { } } } + .frame(height: 50) } .scrollIndicators(.visible) + Spacer() Divider() + Spacer() TextBox(label: host.label.isEmpty ? "" : "Icon Label", text: $host.label, prompt: "Icon label") } diff --git a/ShhShell/Views/Snippets/AddSnippetView.swift b/ShhShell/Views/Snippets/AddSnippetView.swift index 06a4c25..52e35c3 100644 --- a/ShhShell/Views/Snippets/AddSnippetView.swift +++ b/ShhShell/Views/Snippets/AddSnippetView.swift @@ -54,6 +54,7 @@ struct AddSnippetView: View { } label: { Label("Add", systemImage: "plus") } + .disabled(name.isEmpty || content.isEmpty) } } } diff --git a/ShhShell/Views/Terminal/ShellTabView.swift b/ShhShell/Views/Terminal/ShellTabView.swift index 11537b4..ddf31e3 100644 --- a/ShhShell/Views/Terminal/ShellTabView.swift +++ b/ShhShell/Views/Terminal/ShellTabView.swift @@ -89,7 +89,6 @@ struct ShellTabView: View { SnippetPicker(hostsManager: hostsManager) { container.sessions[selectedID ?? UUID()]?.handler.writeToChannel($0.content) } - .frame(minWidth: 300, minHeight: 400) .modifier(presentationCompactPopover()) } }