Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
chore: mark package as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
thislooksfun committed Jun 8, 2021
1 parent 9ae7010 commit a718441
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# THIS PROJECT IS DEPRECATED

iOS 15 introduced [`.searchable()`](<https://developer.apple.com/documentation/swiftui/form/searchable(text:placement:)>), 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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftlySearch/SwiftlySearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, placeholder: String? = nil, hidesNavigationBarDuringPresentation: Bool = true, hidesSearchBarWhenScrolling: Bool = true, cancelClicked: @escaping () -> Void = {}, searchClicked: @escaping () -> Void = {}) -> some View {
return overlay(SearchBar<AnyView>(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<ResultContent: View>(_ searchText: Binding<String>, 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))
}
Expand Down

0 comments on commit a718441

Please sign in to comment.