diff --git a/README.md b/README.md index d916758..d3e4ab5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ +# THIS PROJECT IS DEPRECATED + +iOS 15 introduced [`.searchable()`](), which is an official, native, +first-party search bar for SwiftUI. As such this project is no longer necessary. +I will continue to keep it around for projects that need to support older +versions, but it will no longer be actively developed and you should switch to +the new system once you have the choice. Thank you all for your support, and +happy coding! + # SwiftlySearch A small, lightweight UISearchController wrapper for SwiftUI @@ -53,10 +62,10 @@ struct MRE: View { } ``` - ## Known issues: ([#12](https://github.com/thislooksfun/SwiftlySearch/issues/12)) `NavigationLink`s inside the `resultContent` don't work. This is a limitation of the UIKit/SwiftUI interaction, and thus out of my hands. If you require a seperate view for displaying search results you can use a workaround like shown below: + ```swift struct ContentView: View { @State diff --git a/Sources/SwiftlySearch/SwiftlySearch.swift b/Sources/SwiftlySearch/SwiftlySearch.swift index 29ef32c..104c290 100644 --- a/Sources/SwiftlySearch/SwiftlySearch.swift +++ b/Sources/SwiftlySearch/SwiftlySearch.swift @@ -21,10 +21,14 @@ import SwiftUI import Combine public extension View { + @available(iOS, introduced: 13.0, deprecated: 15.0, message: "Use .searchable() and .onSubmit(of:) instead.") + @available(macCatalyst, introduced: 13.0, deprecated: 15.0, message: "Use .searchable() and .onSubmit(of:) instead.") func navigationBarSearch(_ searchText: Binding, placeholder: String? = nil, hidesNavigationBarDuringPresentation: Bool = true, hidesSearchBarWhenScrolling: Bool = true, cancelClicked: @escaping () -> Void = {}, searchClicked: @escaping () -> Void = {}) -> some View { return overlay(SearchBar(text: searchText, placeholder: placeholder, hidesNavigationBarDuringPresentation: hidesNavigationBarDuringPresentation, hidesSearchBarWhenScrolling: hidesSearchBarWhenScrolling, cancelClicked: cancelClicked, searchClicked: searchClicked).frame(width: 0, height: 0)) } + @available(iOS, introduced: 13.0, deprecated: 15.0, message: "Use .searchable() and .onSubmit(of:) instead.") + @available(macCatalyst, introduced: 13.0, deprecated: 15.0, message: "Use .searchable() and .onSubmit(of:) instead.") func navigationBarSearch(_ searchText: Binding, placeholder: String? = nil, hidesNavigationBarDuringPresentation: Bool = true, hidesSearchBarWhenScrolling: Bool = true, cancelClicked: @escaping () -> Void = {}, searchClicked: @escaping () -> Void = {}, @ViewBuilder resultContent: @escaping (String) -> ResultContent) -> some View { return overlay(SearchBar(text: searchText, placeholder: placeholder, hidesNavigationBarDuringPresentation: hidesNavigationBarDuringPresentation, hidesSearchBarWhenScrolling: hidesSearchBarWhenScrolling, cancelClicked: cancelClicked, searchClicked: searchClicked, resultContent: resultContent).frame(width: 0, height: 0)) }