Mercurial > public > lazybear
changeset 224:7a159f0d5cf0
Delete SearchBar
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 28 Feb 2021 18:10:00 +0000 |
parents | 05d1acc290ad |
children | 1c541670fee7 |
files | LazyBear/UI/SearchBar.swift |
diffstat | 1 files changed, 0 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear/UI/SearchBar.swift Sun Feb 28 18:09:40 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -// -// SearchBar.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 19/2/21. -// - -import SwiftUI - -struct SearchBar: View { - @Binding var searchedText: String - @State private var isEditing = false - - var body: some View { - HStack { - TextField("Search ...", text: $searchedText) - .padding(.horizontal, 45) - .padding(.vertical, 10) - .background(Color(.systemGray6).cornerRadius(10)) - .overlay(overlay, alignment: .leading) - - - if isEditing { - cancel - .transition(.move(edge: .trailing)) - } - } - .padding(.horizontal) - .onTapGesture { - withAnimation { - self.isEditing = true - } - } - } - - var overlay: some View { - Image(systemName: "magnifyingglass") - .opacity(0.2) - .padding(.leading) - } - - var cancel: some View { - Button(action: { - withAnimation { - self.searchedText = "" - self.isEditing = false - // Force hide keyboard - UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) - } - }) { - Text("Cancel") - } - } -} - -struct SearchBar_Previews: PreviewProvider { - static var previews: some View { - VStack { - SearchBar(searchedText: .constant("")) - Spacer() - } - } -}