damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit d6ef1c40197c7bfe716942a9062dcd5864fd1343
parent b5f13636ae3145a0ab5e3c4ea0aca428bd29a5be
Author: James Carucci <jim.carucci@northstarbis.com>
Date:   Tue,  9 Aug 2022 10:02:44 -0700

Add cancel button to search box

Changelog-Added: Cancel button on search box
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Views/SearchHomeView.swift | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/damus/Views/SearchHomeView.swift b/damus/Views/SearchHomeView.swift @@ -15,16 +15,25 @@ struct SearchHomeView: View { var SearchInput: some View { ZStack(alignment: .leading) { - TextField("", text: $search) - .padding(5) - .padding(.leading, 35) - .textInputAutocapitalization(.never) + HStack{ + TextField("", text: $search) + .padding(5) + .padding(.leading, 35) + .textInputAutocapitalization(.never) + Label("", systemImage: "xmark.square") + .padding(EdgeInsets(top: 0.0, leading: 0.0, bottom: 0.0, trailing: 10.0)) + .opacity((search == "") ? 0.0 : 1.0) + .onTapGesture { + self.search = "" + } + } + Label("", systemImage: "magnifyingglass") .padding(.leading, 10) } .background { RoundedRectangle(cornerRadius: 20) - .foregroundColor(.gray.opacity(0.2)) + .foregroundColor(.gray.opacity(0.2)) } .padding() }