krz/hutch

an ios client for sourcehut

clone: git clone https://gitbay.org/krz/hutch.git

v3.1.5: Hutch/Views/Search/RecentSearchSuggestions.swift · raw

 1import SwiftUI
 2
 3struct RecentSearchSuggestions: View {
 4    let title: String
 5    let entries: [ScopedSearchHistoryEntry]
 6    let onSelect: (String) -> Void
 7    let onClear: () -> Void
 8
 9    var body: some View {
10        if !entries.isEmpty {
11            Section(title) {
12                ForEach(entries) { entry in
13                    Button {
14                        onSelect(entry.query)
15                    } label: {
16                        Label(entry.query, systemImage: "clock.arrow.circlepath")
17                    }
18                }
19
20                Button("Clear Recent Searches", role: .destructive) {
21                    onClear()
22                }
23            }
24        }
25    }
26}