added mac-like traffic lights to the top of tabshellview

This commit is contained in:
neon443
2025-07-04 09:29:21 +01:00
parent 89669b4596
commit a9df89eae2
2 changed files with 74 additions and 45 deletions

View File

@@ -185,8 +185,8 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
func setTitle(_ newTitle: String) {
DispatchQueue.main.async {
self.title = newTitle
Task { @MainActor in
withAnimation { self.title = newTitle }
}
}

View File

@@ -19,7 +19,40 @@ struct ShellTabView: View {
var body: some View {
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
)
}
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
@@ -31,15 +64,6 @@ struct ShellTabView: View {
Rectangle()
.fill(selected ? ansi7 : background)
HStack {
if selected {
Button() {
container.sessions[id]?.handler.disconnect()
} label: {
Image(systemName: "xmark.app.fill")
.resizable().scaledToFit()
}
.padding()
}
Spacer()
VStack {
Text(container.sessions[id]!.handler.title)
@@ -60,12 +84,17 @@ struct ShellTabView: View {
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 {