mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
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:
@@ -72,6 +72,7 @@ extension Host {
|
|||||||
static var blank: Host {
|
static var blank: Host {
|
||||||
Host(address: "")
|
Host(address: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
static var debug: Host {
|
static var debug: Host {
|
||||||
Host(
|
Host(
|
||||||
name: "name for localhost",
|
name: "name for localhost",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
@Published var hosts: [Host] = []
|
@Published var hosts: [Host] = []
|
||||||
|
|
||||||
@Published var themes: [Theme] = []
|
@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 selectedAnsi: Int = 1
|
||||||
|
|
||||||
@Published var fonts: [UIFont] = []
|
@Published var fonts: [UIFont] = []
|
||||||
@@ -223,16 +223,12 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateHost(_ updatedHost: Host) {
|
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 }) {
|
if let index = hosts.firstIndex(where: { $0.id == updatedHost.id }) {
|
||||||
withAnimation { hosts[index] = updatedHost }
|
withAnimation { hosts[index] = updatedHost }
|
||||||
// var updateHostWithNewID = updatedHost
|
|
||||||
// updateHostWithNewID.id = UUID()
|
|
||||||
// withAnimation { hosts[index] = updateHostWithNewID }
|
|
||||||
//
|
|
||||||
// updateHostWithNewID.id = oldID
|
|
||||||
// withAnimation { hosts[index] = updateHostWithNewID }
|
|
||||||
saveHosts()
|
saveHosts()
|
||||||
} else {
|
} else {
|
||||||
withAnimation { hosts.append(updatedHost) }
|
withAnimation { hosts.append(updatedHost) }
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
}
|
}
|
||||||
|
.navigationTitle("ShhShell")
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .confirmationAction) {
|
ToolbarItem(placement: .confirmationAction) {
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
|
|||||||
@@ -12,11 +12,19 @@ struct HostSymbolPicker: View {
|
|||||||
|
|
||||||
@Environment(\.colorScheme) var cScheme
|
@Environment(\.colorScheme) var cScheme
|
||||||
|
|
||||||
|
var innerR: CGFloat {
|
||||||
|
if #available(iOS 19, *) {
|
||||||
|
return 16
|
||||||
|
} else {
|
||||||
|
return 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.foregroundStyle(cScheme == .dark ? .black : .gray)
|
.foregroundStyle(cScheme == .dark ? .black : .gray)
|
||||||
VStack(alignment: .center, spacing: 10) {
|
VStack(alignment: .center, spacing: 0) {
|
||||||
ScrollView(.horizontal) {
|
ScrollView(.horizontal) {
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(HostSymbol.allCases, id: \.self) { symbol in
|
ForEach(HostSymbol.allCases, id: \.self) { symbol in
|
||||||
@@ -24,7 +32,7 @@ struct HostSymbolPicker: View {
|
|||||||
if host.symbol == symbol {
|
if host.symbol == symbol {
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.fill(.gray.opacity(0.5))
|
.fill(.gray.opacity(0.5))
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 5))
|
.clipShape(RoundedRectangle(cornerRadius: innerR))
|
||||||
}
|
}
|
||||||
HostSymbolPreview(symbol: symbol, label: host.label)
|
HostSymbolPreview(symbol: symbol, label: host.label)
|
||||||
.padding(10)
|
.padding(10)
|
||||||
@@ -37,10 +45,13 @@ struct HostSymbolPicker: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.frame(height: 50)
|
||||||
}
|
}
|
||||||
.scrollIndicators(.visible)
|
.scrollIndicators(.visible)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
Divider()
|
Divider()
|
||||||
|
Spacer()
|
||||||
|
|
||||||
TextBox(label: host.label.isEmpty ? "" : "Icon Label", text: $host.label, prompt: "Icon label")
|
TextBox(label: host.label.isEmpty ? "" : "Icon Label", text: $host.label, prompt: "Icon label")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ struct AddSnippetView: View {
|
|||||||
} label: {
|
} label: {
|
||||||
Label("Add", systemImage: "plus")
|
Label("Add", systemImage: "plus")
|
||||||
}
|
}
|
||||||
|
.disabled(name.isEmpty || content.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ struct ShellTabView: View {
|
|||||||
SnippetPicker(hostsManager: hostsManager) {
|
SnippetPicker(hostsManager: hostsManager) {
|
||||||
container.sessions[selectedID ?? UUID()]?.handler.writeToChannel($0.content)
|
container.sessions[selectedID ?? UUID()]?.handler.writeToChannel($0.content)
|
||||||
}
|
}
|
||||||
.frame(minWidth: 300, minHeight: 400)
|
|
||||||
.modifier(presentationCompactPopover())
|
.modifier(presentationCompactPopover())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user