LiTranslate-iOS/LiTranslate/Presentation/Component/SearchBarView.swift

36 lines
914 B
Swift
Raw Permalink Normal View History

2022-09-10 19:46:05 +02:00
//
// SearchBarView.swift
// LiTranslate
//
// Created by Viktor Kalyniuk on 02.09.2022.
//
import SwiftUI
struct SearchBarView: View {
@Binding var inputText: String
private let searchIcon: Image = Image(systemName: SystemNames.magnifyingglass)
private let searchText: String = "Search"
var body: some View {
HStack {
TextField("\(searchIcon) \(searchText)", text: $inputText)
Button {
inputText = ""
} label: {
Image(systemName: SystemNames.closeCircleFill)
.foregroundColor(Colors.Foreground.tertiaryLabel)
}
.buttonStyle(.plain)
.opacity(Double(inputText.isEmpty ? Numbers.zero : Numbers.one))
}
}
}
struct SearchBarView_Previews: PreviewProvider {
static var previews: some View {
SearchBarView(inputText: .constant(""))
}
}