added full expand and full close buttons, with new symbols that support ios 13+

added historylimitdisplay computed property
made disconnect synchronous
This commit is contained in:
neon443
2025-09-01 17:46:43 +01:00
parent efb6072af8
commit 7c28cc79da
2 changed files with 72 additions and 49 deletions

View File

@@ -140,11 +140,9 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
func disconnect() {
Task { @MainActor in
self.hostkeyChanged = false
withAnimation { self.state = .idle }
withAnimation { self.testSuceeded = nil }
}
self.hostkeyChanged = false
withAnimation { self.state = .idle }
withAnimation { self.testSuceeded = nil }
if let sessionID {
Task { @MainActor in

View File

@@ -11,12 +11,22 @@ struct RecentsView: View {
@ObservedObject var hostsManager: HostsManager
@ObservedObject var keyManager: KeyManager
@State var historyCount: Int = 1
@State var historyLimit: Int = 1
var historyLimitDisplay: String {
let count = hostsManager.history.count
if historyLimit == 0 {
return "\(count) item\(plural(count))"
} else if historyLimit > count {
return "\(count)/\(count)"
} else {
return "\(historyLimit)/\(count)"
}
}
var body: some View {
var body: some View {
if !hostsManager.history.isEmpty {
Section("Recents") {
ForEach(hostsManager.history.reversed().prefix(historyCount)) { history in
ForEach(hostsManager.history.reversed().prefix(historyLimit)) { history in
NavigationLink() {
ConnectionView(
handler: SSHHandler(
@@ -46,51 +56,66 @@ struct RecentsView: View {
.tint(.red)
}
}
// if historyCount <= hostsManager.history.count {
HStack(alignment: .center) {
Button() {
var increment = 2
if historyCount+2 > hostsManager.history.count {
increment = 1
}
withAnimation(.spring) { historyCount += increment }
} label: {
Image(systemName: "chevron.down")
.resizable().scaledToFit()
.frame(width: 20)
.foregroundStyle(hostsManager.tint)
}
.buttonStyle(.plain)
.disabled(historyCount == hostsManager.history.count)
Spacer()
Text(
historyCount == 0 ?
"\(hostsManager.history.count) item\(plural(hostsManager.history.count))" :
"\(historyCount)/\(hostsManager.history.count)"
)
.foregroundStyle(.gray)
.font(.caption)
.contentTransition(.numericText())
Spacer()
Button {
withAnimation(.spring) { historyCount = 0 }
} label: {
Image(systemName: "chevron.up.2")
.resizable().scaledToFit()
.frame(width: 20)
.foregroundStyle(hostsManager.tint)
}
.buttonStyle(.plain)
.disabled(historyCount == 0)
HStack(alignment: .center) {
Button() {
var decrement: Int = 2
if historyLimit < 2 { decrement = 1 }
withAnimation(.spring) { historyLimit -= decrement }
} label: {
Image(systemName: "chevron.up")
.resizable().scaledToFit()
.frame(width: 20)
.foregroundStyle(hostsManager.tint)
}
// }
.buttonStyle(.plain)
.disabled(historyLimit == 0)
.padding(.trailing, 10)
Button() {
withAnimation(.spring) { historyLimit += 2 }
} label: {
Image(systemName: "chevron.down")
.resizable().scaledToFit()
.frame(width: 20)
.foregroundStyle(hostsManager.tint)
}
.buttonStyle(.plain)
.disabled(historyLimit >= hostsManager.history.count)
Spacer()
Text(historyLimitDisplay)
.foregroundStyle(.gray)
.font(.caption)
.contentTransition(.numericText())
Spacer()
Button {
withAnimation(.spring) { historyLimit = Int.max }
} label: {
Image(systemName: "rectangle.expand.vertical")
.resizable().scaledToFit()
.frame(width: 20)
.foregroundStyle(hostsManager.tint)
}
.buttonStyle(.plain)
.disabled(historyLimit != 0)
.padding(.trailing, 10)
Button {
withAnimation(.spring) { historyLimit = 0 }
} label: {
Image(systemName: "rectangle.compress.vertical")
.resizable().scaledToFit()
.frame(width: 20)
.foregroundStyle(hostsManager.tint)
}
.buttonStyle(.plain)
.disabled(historyLimit == 0)
}
}
.transition(.opacity)
}
}
}
}
#Preview {