ok fix stupid things in recents:

- crash when expanding recents but theres only one more
 - ui improvements make the down arrow grayed out if its all the way down
 - up arrow disabled if fully collapsed
 - something else i forgot
This commit is contained in:
neon443
2025-08-16 22:24:50 +01:00
parent 587c85842f
commit 56c5634d9a

View File

@@ -47,10 +47,14 @@ struct RecentsView: View {
.tint(.red) .tint(.red)
} }
} }
if historyCount != hostsManager.history.count { if historyCount <= hostsManager.history.count {
HStack(alignment: .center) { HStack(alignment: .center) {
Button() { Button() {
withAnimation { historyCount += 2 } var increment = 2
if historyCount+2 > hostsManager.history.count {
increment = 1
}
withAnimation { historyCount += increment }
} label: { } label: {
Image(systemName: "chevron.down") Image(systemName: "chevron.down")
.resizable().scaledToFit() .resizable().scaledToFit()
@@ -58,14 +62,17 @@ struct RecentsView: View {
.foregroundStyle(hostsManager.tint) .foregroundStyle(hostsManager.tint)
} }
.buttonStyle(.plain) .buttonStyle(.plain)
.disabled(historyCount == hostsManager.history.count)
Spacer() Spacer()
Text("\(historyCount)/\(hostsManager.history.count)") Text("\(historyCount)/\(hostsManager.history.count)")
.foregroundStyle(.gray) .foregroundStyle(.gray)
.font(.caption) .font(.caption)
.contentTransition(.numericText()) .contentTransition(.numericText())
Spacer() Spacer()
Button { Button {
withAnimation { historyCount = 2 } withAnimation { historyCount = 0 }
} label: { } label: {
Image(systemName: "chevron.up.2") Image(systemName: "chevron.up.2")
.resizable().scaledToFit() .resizable().scaledToFit()
@@ -73,10 +80,12 @@ struct RecentsView: View {
.foregroundStyle(hostsManager.tint) .foregroundStyle(hostsManager.tint)
} }
.buttonStyle(.plain) .buttonStyle(.plain)
.disabled(historyCount == 0)
} }
} }
} }
.transition(.opacity)
} }
} }
} }