LiTranslate-iOS/LiTranslate/Presentation/Component/SearchBarView.swift
Viktor Kalyniuk 823b3abe77 release v1.0
2022-09-10 20:46:05 +03:00

35 lines
914 B
Swift

//
// 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(""))
}
}