mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Add clear history button (fix #205)
This commit is contained in:
parent
4ea44a5267
commit
e139d98bd7
@ -255,6 +255,11 @@ final class NavigationModel: ObservableObject {
|
||||
presentingAlert = true
|
||||
}
|
||||
|
||||
func presentAlert(_ alert: Alert) {
|
||||
self.alert = alert
|
||||
presentingAlert = true
|
||||
}
|
||||
|
||||
func presentShareSheet(_ url: URL) {
|
||||
shareURL = url
|
||||
presentingShareSheet = true
|
||||
|
@ -221,9 +221,6 @@ struct SearchView: View {
|
||||
VStack {
|
||||
if showRecentQueries {
|
||||
recentQueries
|
||||
#if os(iOS)
|
||||
.padding(.bottom, 90)
|
||||
#endif
|
||||
} else {
|
||||
#if os(tvOS)
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
@ -299,8 +296,11 @@ struct SearchView: View {
|
||||
}
|
||||
}
|
||||
.redrawOn(change: recentsChanged)
|
||||
|
||||
Section(footer: Color.clear.frame(minHeight: 80)) {
|
||||
clearHistoryButton
|
||||
}
|
||||
}
|
||||
.id(UUID())
|
||||
}
|
||||
#if os(iOS)
|
||||
.listStyle(.insetGrouped)
|
||||
@ -351,7 +351,7 @@ struct SearchView: View {
|
||||
}
|
||||
.contextMenu {
|
||||
removeButton(item)
|
||||
removeAllButton
|
||||
|
||||
#if os(tvOS)
|
||||
Button("Cancel", role: .cancel) {}
|
||||
#endif
|
||||
@ -367,13 +367,24 @@ struct SearchView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var removeAllButton: some View {
|
||||
private var clearHistoryButton: some View {
|
||||
Button {
|
||||
navigation.presentAlert(
|
||||
Alert(
|
||||
title: Text("Are you sure you want to clear search history?"),
|
||||
message: Text("This cannot be reverted"),
|
||||
primaryButton: .destructive(Text("Clear")) {
|
||||
recents.clear()
|
||||
recentsChanged.toggle()
|
||||
},
|
||||
secondaryButton: .cancel()
|
||||
)
|
||||
)
|
||||
} label: {
|
||||
Label("Remove All", systemImage: "trash.fill")
|
||||
Label("Clear Search History...", systemImage: "trash.fill")
|
||||
}
|
||||
.labelStyle(.titleOnly)
|
||||
.foregroundColor(Color("AppRedColor"))
|
||||
}
|
||||
|
||||
private var searchFiltersActive: Bool {
|
||||
|
Loading…
Reference in New Issue
Block a user