From 3dc37cf75e09fbf20cc7248ad7a60b306d85d9b0 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Wed, 16 Jul 2025 18:36:04 +0100 Subject: [PATCH] remove hosts section if no hosts, delete invert.metal --- ShhShell.xcodeproj/project.pbxproj | 4 -- ShhShell/Views/Hosts/HostsView.swift | 62 ++++++++++++++-------------- ShhShell/Views/Misc/invert.metal | 13 ------ 3 files changed, 32 insertions(+), 47 deletions(-) delete mode 100644 ShhShell/Views/Misc/invert.metal diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index 9dc6241..8267ebd 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -64,7 +64,6 @@ A96C90A12E12B87A00724253 /* TextBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C90A02E12B87900724253 /* TextBox.swift */; }; A96C90A32E12D53B00724253 /* KeyType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C90A22E12D53900724253 /* KeyType.swift */; }; A9835C3C2E17CCA500969508 /* TrafficLights.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9835C3B2E17CCA500969508 /* TrafficLights.swift */; }; - A9835C3E2E17E9C100969508 /* invert.metal in Sources */ = {isa = PBXBuildFile; fileRef = A9835C3D2E17E9C100969508 /* invert.metal */; }; A98554552E05535F009051BD /* KeyManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554542E05535F009051BD /* KeyManagerView.swift */; }; A98554592E0553AA009051BD /* KeyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554582E0553AA009051BD /* KeyManager.swift */; }; A985545D2E055D4D009051BD /* ConnectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A985545C2E055D4D009051BD /* ConnectionView.swift */; }; @@ -189,7 +188,6 @@ A96C90A02E12B87900724253 /* TextBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextBox.swift; sourceTree = ""; }; A96C90A22E12D53900724253 /* KeyType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyType.swift; sourceTree = ""; }; A9835C3B2E17CCA500969508 /* TrafficLights.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrafficLights.swift; sourceTree = ""; }; - A9835C3D2E17E9C100969508 /* invert.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = invert.metal; sourceTree = ""; }; A98554542E05535F009051BD /* KeyManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyManagerView.swift; sourceTree = ""; }; A98554582E0553AA009051BD /* KeyManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyManager.swift; sourceTree = ""; }; A985545C2E055D4D009051BD /* ConnectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionView.swift; sourceTree = ""; }; @@ -467,7 +465,6 @@ A96C90A02E12B87900724253 /* TextBox.swift */, A9DA97722E0D40C100142DDC /* HostSymbolPreview.swift */, A9835C3B2E17CCA500969508 /* TrafficLights.swift */, - A9835C3D2E17E9C100969508 /* invert.metal */, ); path = Misc; sourceTree = ""; @@ -758,7 +755,6 @@ A985545D2E055D4D009051BD /* ConnectionView.swift in Sources */, A9FD37592E143D74005319A8 /* GenericPasswordConvertible.swift in Sources */, A9485C762E1AF59F00209824 /* FontManagerView.swift in Sources */, - A9835C3E2E17E9C100969508 /* invert.metal in Sources */, A98554592E0553AA009051BD /* KeyManager.swift in Sources */, A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */, A9D819312E102D8700442D38 /* HostkeysView.swift in Sources */, diff --git a/ShhShell/Views/Hosts/HostsView.swift b/ShhShell/Views/Hosts/HostsView.swift index 6c2c49a..97d6f17 100644 --- a/ShhShell/Views/Hosts/HostsView.swift +++ b/ShhShell/Views/Hosts/HostsView.swift @@ -17,42 +17,44 @@ struct HostsView: View { Text("Add your first Host!") } - Section("Hosts") { - ForEach(hostsManager.hosts) { host in - NavigationLink() { - ConnectionView( - handler: SSHHandler(host: host, keyManager: keyManager), - hostsManager: hostsManager, - keyManager: keyManager - ) - } label: { - HostSymbolPreview(symbol: host.symbol, label: host.label) - .frame(width: 40, height: 40) - Text(host.description) - } - .id(host) - .animation(.default, value: host) - .swipeActions(edge: .trailing) { - Button(role: .destructive) { - hostsManager.removeHost(host) + if !hostsManager.hosts.isEmpty { + Section("Hosts") { + ForEach(hostsManager.hosts) { host in + NavigationLink() { + ConnectionView( + handler: SSHHandler(host: host, keyManager: keyManager), + hostsManager: hostsManager, + keyManager: keyManager + ) } label: { - Label("Delete", systemImage: "trash") + HostSymbolPreview(symbol: host.symbol, label: host.label) + .frame(width: 40, height: 40) + Text(host.description) } - .tint(.red) - Button() { - hostsManager.duplicateHost(host) - } label: { - Label("Duplicate", systemImage: "square.filled.on.square") + .id(host) + .animation(.default, value: host) + .swipeActions(edge: .trailing) { + Button(role: .destructive) { + hostsManager.removeHost(host) + } label: { + Label("Delete", systemImage: "trash") + } + .tint(.red) + Button() { + hostsManager.duplicateHost(host) + } label: { + Label("Duplicate", systemImage: "square.filled.on.square") + } + .tint(.blue) } - .tint(.blue) } + .onMove(perform: { + hostsManager.moveHost(from: $0, to: $1) + }) } - .onMove(perform: { - hostsManager.moveHost(from: $0, to: $1) - }) + .transition(.opacity) + .navigationTitle("ShhShell") } - .transition(.opacity) - .navigationTitle("ShhShell") } } diff --git a/ShhShell/Views/Misc/invert.metal b/ShhShell/Views/Misc/invert.metal deleted file mode 100644 index d457d7a..0000000 --- a/ShhShell/Views/Misc/invert.metal +++ /dev/null @@ -1,13 +0,0 @@ -// -// invert.metal -// ShhShell -// -// Created by neon443 on 04/07/2025. -// - -#include -using namespace metal; - -[[ stitchable ]] half4 invert(float2 pos, half4 color) { - return half4(0, 1 - color.g, 1 - color.b, 1 - color.a); -}