| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // LoopFollow
- // SearchBar.swift
- import SwiftUI
- import UIKit
- struct SearchBar: UIViewRepresentable {
- @Binding var text: String
- class Coordinator: NSObject, UISearchBarDelegate {
- @Binding var text: String
- init(text: Binding<String>) {
- _text = text
- }
- func searchBar(_: UISearchBar, textDidChange searchText: String) {
- text = searchText
- }
- func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
- searchBar.resignFirstResponder()
- }
- }
- func makeCoordinator() -> Coordinator {
- return Coordinator(text: $text)
- }
- func makeUIView(context: UIViewRepresentableContext<SearchBar>) -> UISearchBar {
- let searchBar = UISearchBar(frame: .zero)
- searchBar.placeholder = String(localized: "Search Log")
- searchBar.delegate = context.coordinator
- searchBar.autocapitalizationType = .none
- searchBar.searchBarStyle = .minimal
- return searchBar
- }
- func updateUIView(_ uiView: UISearchBar, context _: UIViewRepresentableContext<SearchBar>) {
- uiView.text = text
- }
- }
|