mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
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:
@@ -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 }
|
||||
}
|
||||
|
||||
if let sessionID {
|
||||
Task { @MainActor in
|
||||
|
||||
@@ -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 {
|
||||
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,14 +56,23 @@ 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
|
||||
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)
|
||||
}
|
||||
withAnimation(.spring) { historyCount += increment }
|
||||
.buttonStyle(.plain)
|
||||
.disabled(historyLimit == 0)
|
||||
.padding(.trailing, 10)
|
||||
|
||||
Button() {
|
||||
withAnimation(.spring) { historyLimit += 2 }
|
||||
} label: {
|
||||
Image(systemName: "chevron.down")
|
||||
.resizable().scaledToFit()
|
||||
@@ -61,32 +80,38 @@ struct RecentsView: View {
|
||||
.foregroundStyle(hostsManager.tint)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.disabled(historyCount == hostsManager.history.count)
|
||||
.disabled(historyLimit >= hostsManager.history.count)
|
||||
|
||||
Spacer()
|
||||
Text(
|
||||
historyCount == 0 ?
|
||||
"\(hostsManager.history.count) item\(plural(hostsManager.history.count))" :
|
||||
"\(historyCount)/\(hostsManager.history.count)"
|
||||
)
|
||||
Text(historyLimitDisplay)
|
||||
.foregroundStyle(.gray)
|
||||
.font(.caption)
|
||||
.contentTransition(.numericText())
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
withAnimation(.spring) { historyCount = 0 }
|
||||
withAnimation(.spring) { historyLimit = Int.max }
|
||||
} label: {
|
||||
Image(systemName: "chevron.up.2")
|
||||
Image(systemName: "rectangle.expand.vertical")
|
||||
.resizable().scaledToFit()
|
||||
.frame(width: 20)
|
||||
.foregroundStyle(hostsManager.tint)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.disabled(historyCount == 0)
|
||||
}
|
||||
// }
|
||||
.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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user