mirror of
https://github.com/neon443/ShhShell.git
synced 2026-11-30 12:44:51 +00:00
added traffliclights to make the traffic lights perfect, red yellow done
green wip clean up on the terminal view: add background and reorg the fiel and add traffic lights add bg to all the terminal related stuff
This commit is contained in:
5 files changed
+197
-100
No files matched your search
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// TrafficLights.swift
|
||||
// ShhShell
|
||||
//
|
||||
// Created by neon443 on 04/07/2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct TrafficLightRed: View {
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Image(systemName: "circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.foregroundStyle(.red)
|
||||
Image(systemName: "xmark")
|
||||
.resizable().scaledToFit()
|
||||
.bold()
|
||||
.scaleEffect(0.6)
|
||||
.foregroundStyle(
|
||||
ColorCodable(
|
||||
red: 0.5490196078,
|
||||
green: 0.1019607843,
|
||||
blue: 0.0588235294
|
||||
).stColor.suiColor
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TrafficLightYellow: View {
|
||||
var body: some View {
|
||||
ZStack(alignment: .center) {
|
||||
Image(systemName: "circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.foregroundStyle(.yellow)
|
||||
Image(systemName: "minus")
|
||||
.resizable().scaledToFit()
|
||||
.bold()
|
||||
.scaleEffect(0.6)
|
||||
.foregroundStyle(
|
||||
ColorCodable(
|
||||
red: 0.5803921569,
|
||||
green: 0.3411764706,
|
||||
blue: 0.0980392157
|
||||
).stColor.suiColor
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TrafficLightGreen: View {
|
||||
var body: some View {
|
||||
ZStack(alignment: .center) {
|
||||
Image(systemName: "circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.symbolRenderingMode(.palette)
|
||||
.foregroundStyle(.green)
|
||||
Rectangle()
|
||||
.foregroundStyle(
|
||||
ColorCodable(
|
||||
red: 0.1529411765,
|
||||
green: 0.3843137255,
|
||||
blue: 0.1176470588
|
||||
).stColor.suiColor
|
||||
)
|
||||
.scaleEffect(0.6)
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
Group {
|
||||
HStack {
|
||||
TrafficLightRed()
|
||||
TrafficLightYellow()
|
||||
TrafficLightGreen()
|
||||
}
|
||||
}
|
||||
.frame(width: 150, height: 50)
|
||||
.scaleEffect(4.9)
|
||||
}
|
||||
@@ -19,8 +19,8 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
|
||||
self.handler = handler
|
||||
self.hostsManager = hostsManager
|
||||
|
||||
print(getTerminal().backgroundColor)
|
||||
print(getTerminal().foregroundColor)
|
||||
print(getTerminal().backgroundColor.colorCodable)
|
||||
print(getTerminal().foregroundColor.colorCodable)
|
||||
|
||||
applySelectedTheme()
|
||||
|
||||
|
||||
@@ -16,119 +16,127 @@ struct ShellTabView: View {
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var foreground: Color { hostsManager.selectedTheme.foreground.suiColor }
|
||||
var ansi7: Color { hostsManager.selectedTheme.ansi[6].suiColor.opacity(0.7) }
|
||||
var background: Color { hostsManager.selectedTheme.background.suiColor }
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
VStack {
|
||||
HStack(alignment: .center, spacing: 10) {
|
||||
Button() {
|
||||
for session in container.sessions.values {
|
||||
session.handler.disconnect()
|
||||
ZStack {
|
||||
background
|
||||
.ignoresSafeArea(.all)
|
||||
GeometryReader { geo in
|
||||
VStack {
|
||||
let oneTabWidth = max(60, (geo.size.width)/CGFloat(container.sessionIDs.count))
|
||||
|
||||
HStack(alignment: .center, spacing: 10) {
|
||||
Button() {
|
||||
for session in container.sessions.values {
|
||||
session.handler.disconnect()
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.symbolRenderingMode(.palette)
|
||||
.foregroundStyle(
|
||||
ColorCodable(red: 0.5411764706, green: 0, blue: 0).stColor.suiColor,
|
||||
.red
|
||||
)
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.symbolRenderingMode(.palette)
|
||||
.foregroundStyle(
|
||||
ColorCodable(red: 0.5411764706, green: 0, blue: 0).stColor.suiColor,
|
||||
.red
|
||||
)
|
||||
Button() {
|
||||
dismiss()
|
||||
} label: {
|
||||
Image(systemName: "minus.circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.symbolRenderingMode(.palette)
|
||||
.foregroundStyle(
|
||||
ColorCodable(red: 0.5764705882, green: 0.5333333333, blue: 0.2784313725).stColor.suiColor,
|
||||
.yellow
|
||||
)
|
||||
}
|
||||
Button() {
|
||||
print("get out of fullscreen idk??")
|
||||
} label: {
|
||||
Image(systemName: "minus.circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.symbolRenderingMode(.palette)
|
||||
.foregroundStyle(
|
||||
ColorCodable(red: 0.5764705882, green: 0.5333333333, blue: 0.2784313725).stColor.suiColor,
|
||||
.yellow
|
||||
)
|
||||
}
|
||||
Spacer()
|
||||
Text(container.sessions[selectedID ?? UUID()]?.handler.title ?? "title")
|
||||
Spacer()
|
||||
}
|
||||
Button() {
|
||||
dismiss()
|
||||
} label: {
|
||||
Image(systemName: "minus.circle.fill")
|
||||
.resizable().scaledToFit()
|
||||
.symbolRenderingMode(.palette)
|
||||
.foregroundStyle(
|
||||
ColorCodable(red: 0.5764705882, green: 0.5333333333, blue: 0.2784313725).stColor.suiColor,
|
||||
.yellow
|
||||
)
|
||||
}
|
||||
Spacer()
|
||||
Text(container.sessions[selectedID ?? UUID()]?.handler.title ?? "title")
|
||||
Spacer()
|
||||
}
|
||||
.frame(height: 30)
|
||||
.padding(10)
|
||||
|
||||
let oneTabWidth = max(60, (geo.size.width-35)/CGFloat(container.sessionIDs.count))
|
||||
HStack(alignment: .center, spacing: 0) {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 0) {
|
||||
ForEach(container.sessionIDs, id: \.self) { id in
|
||||
let selected = selectedID == id
|
||||
let foreground = hostsManager.selectedTheme.foreground.suiColor
|
||||
let ansi7 = hostsManager.selectedTheme.ansi[6].suiColor.opacity(0.7)
|
||||
let background = hostsManager.selectedTheme.background.suiColor
|
||||
ZStack {
|
||||
Rectangle()
|
||||
.fill(selected ? ansi7 : background)
|
||||
HStack {
|
||||
Spacer()
|
||||
VStack {
|
||||
Text(container.sessions[id]!.handler.title)
|
||||
.monospaced()
|
||||
.foregroundStyle(foreground)
|
||||
.bold(selected)
|
||||
Text(container.sessions[id]!.handler.host.description)
|
||||
.foregroundStyle(foreground.opacity(0.7))
|
||||
.monospaced()
|
||||
.font(.caption)
|
||||
.frame(height: 30)
|
||||
.padding(.horizontal)
|
||||
|
||||
HStack(alignment: .center, spacing: 0) {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 0) {
|
||||
ForEach(container.sessionIDs, id: \.self) { id in
|
||||
let selected: Bool = selectedID == id
|
||||
ZStack {
|
||||
Rectangle()
|
||||
.fill(selected ? ansi7 : background)
|
||||
HStack {
|
||||
Spacer()
|
||||
VStack {
|
||||
Text(container.sessions[id]!.handler.title)
|
||||
.monospaced()
|
||||
.foregroundStyle(foreground)
|
||||
.bold(selected)
|
||||
Text(container.sessions[id]!.handler.host.description)
|
||||
.foregroundStyle(foreground.opacity(0.7))
|
||||
.monospaced()
|
||||
.font(.caption)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.frame(width: oneTabWidth)
|
||||
.ignoresSafeArea(.all)
|
||||
.onTapGesture {
|
||||
withAnimation { selectedID = id }
|
||||
.frame(width: oneTabWidth)
|
||||
.onTapGesture {
|
||||
withAnimation { selectedID = id }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Button() {
|
||||
dismiss()
|
||||
} label: {
|
||||
Image(systemName: "arrow.down.right.and.arrow.up.left")
|
||||
.resizable().scaledToFit()
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.frame(width: 30)
|
||||
.padding(.horizontal, 2.5)
|
||||
}
|
||||
.frame(height: 30)
|
||||
.onAppear {
|
||||
if selectedID == nil {
|
||||
if let handler {
|
||||
selectedID = handler.sessionID
|
||||
} else {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let selectedID,
|
||||
let session = container.sessions[selectedID] {
|
||||
ShellView(
|
||||
handler: session.handler,
|
||||
hostsManager: hostsManager
|
||||
)
|
||||
.onDisappear {
|
||||
if !checkShell(session.handler.state) {
|
||||
if let lastSession = container.sessionIDs.last {
|
||||
withAnimation { self.selectedID = lastSession }
|
||||
.frame(height: 30)
|
||||
.onAppear {
|
||||
if selectedID == nil {
|
||||
if let handler {
|
||||
selectedID = handler.sessionID
|
||||
} else {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
.id(selectedID)
|
||||
.transition(.opacity)
|
||||
} else {
|
||||
if let handler {
|
||||
ShellView(handler: handler, hostsManager: hostsManager)
|
||||
|
||||
//the acc terminal lol
|
||||
if let selectedID,
|
||||
let session = container.sessions[selectedID] {
|
||||
ShellView(
|
||||
handler: session.handler,
|
||||
hostsManager: hostsManager
|
||||
)
|
||||
.onDisappear {
|
||||
if !checkShell(session.handler.state) {
|
||||
if let lastSession = container.sessionIDs.last {
|
||||
withAnimation { self.selectedID = lastSession }
|
||||
} else {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
.id(selectedID)
|
||||
.transition(.opacity)
|
||||
} else {
|
||||
Text("No SSH Handler")
|
||||
if let handler {
|
||||
ShellView(handler: handler, hostsManager: hostsManager)
|
||||
} else {
|
||||
Text("No SSH Handler")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ struct ShellView: View {
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ZStack {
|
||||
hostsManager.selectedTheme.background.suiColor
|
||||
.ignoresSafeArea(.all)
|
||||
TerminalController(handler: handler, hostsManager: hostsManager)
|
||||
.onAppear {
|
||||
if let sessionID = handler.sessionID {
|
||||
|
||||