[ADD] Search bar for BrowseView on iOS 15

This commit is contained in:
Fabian Thies
2022-12-12 19:18:57 +01:00
committed by Joe Mattiello
parent 0c034b61d9
commit 0e7083539d
5 changed files with 73 additions and 33 deletions

View File

@@ -0,0 +1,23 @@
//
// Filterable.swift
// SideStore
//
// Created by Fabian Thies on 01.12.22.
// Copyright © 2022 SideStore. All rights reserved.
//
import Foundation
protocol Filterable {
func matches(_ searchText: String) -> Bool
}
extension Collection where Element: Filterable {
func matches(_ searchText: String) -> Bool {
self.contains(where: { $0.matches(searchText) })
}
func items(matching searchText: String) -> [Element] {
self.filter { $0.matches(searchText) }
}
}