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
This commit is contained in:
neon443
2025-08-08 08:46:28 +01:00
parent 5547a6fb34
commit 100ffb0349
6 changed files with 20 additions and 11 deletions

View File

@@ -72,6 +72,7 @@ extension Host {
static var blank: Host {
Host(address: "")
}
static var debug: Host {
Host(
name: "name for localhost",

View File

@@ -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) }

View File

@@ -73,6 +73,7 @@ struct ContentView: View {
}
.scrollContentBackground(.hidden)
}
.navigationTitle("ShhShell")
.toolbar {
ToolbarItem(placement: .confirmationAction) {
NavigationLink {

View File

@@ -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")
}

View File

@@ -54,6 +54,7 @@ struct AddSnippetView: View {
} label: {
Label("Add", systemImage: "plus")
}
.disabled(name.isEmpty || content.isEmpty)
}
}
}

View File

@@ -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())
}
}