43 lines
1.0 KiB
Swift
43 lines
1.0 KiB
Swift
/* SwiftFin is subject to the terms of the Mozilla Public
|
|
* License, v2.0. If a copy of the MPL was not distributed with this
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*
|
|
* Copyright 2021 Aiden Vigue & Jellyfin Contributors
|
|
*
|
|
* Code sourced from AppCoda.com
|
|
*/
|
|
|
|
import SwiftUI
|
|
|
|
struct SearchBar: View {
|
|
@Binding var text: String
|
|
|
|
@State private var isEditing = false
|
|
|
|
var body: some View {
|
|
HStack {
|
|
|
|
TextField("Search ...", text: $text)
|
|
.padding(7)
|
|
.padding(.horizontal, 25)
|
|
.background(Color(.systemGray6))
|
|
.cornerRadius(8)
|
|
.padding(.horizontal, 10)
|
|
.onTapGesture {
|
|
self.isEditing = true
|
|
}
|
|
|
|
if isEditing {
|
|
Button(action: {
|
|
self.isEditing = false
|
|
self.text = ""
|
|
|
|
}) {
|
|
Text("Cancel")
|
|
}
|
|
.padding(.trailing, 10)
|
|
}
|
|
}
|
|
}
|
|
}
|