Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions berkeley-mobile/Home/Search/SearchBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SwiftUI
struct SearchBarView: View {
@EnvironmentObject var viewModel: SearchViewModel
@FocusState private var isFocused: Bool
@State private var isPresentingFeedbackForm = false

private var onSearchBarTap: ((Bool) -> Void)?

Expand All @@ -26,8 +27,26 @@ struct SearchBarView: View {
viewModel.searchLocations(viewModel.searchText)
}

if !viewModel.searchText.isEmpty {
clearTextIcon
if viewModel.searchText.isEmpty {
Button(action: {
isPresentingFeedbackForm = true
}) {
Image(systemName: "bubble.left.and.bubble.right")
.foregroundStyle(Color(BMColor.searchBarIconColor))
.fontWeight(.semibold)
.frame(width: 30, alignment: .center)
}
.accessibilityLabel("Send Feedback")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor into its own private var

} else {
Button(action: {
viewModel.clearSearchText()
}) {
Image(systemName: "xmark")
.foregroundStyle(Color(BMColor.searchBarIconColor))
.fontWeight(.semibold)
.frame(width: 30, alignment: .center)
}
.accessibilityLabel("Clear search text")
}
}
.padding()
Expand Down Expand Up @@ -63,6 +82,7 @@ struct SearchBarView: View {
isFocused = newValue
onSearchBarTap?(newValue)
}
.sheet(isPresented: $isPresentingFeedbackForm) { FeedbackFormView() }
}

private var searchOrBackIcon: some View {
Expand All @@ -79,17 +99,6 @@ struct SearchBarView: View {
}
}

private var clearTextIcon: some View {
Button(action: {
viewModel.clearSearchText()
}) {
Image(systemName: "xmark")
.foregroundStyle(Color(BMColor.searchBarIconColor))
.fontWeight(.semibold)
.frame(width: 30, alignment: .center)
}
}

init(onSearchBarTap: ((Bool) -> Void)? = nil) {
self.onSearchBarTap = onSearchBarTap
}
Expand Down
1 change: 1 addition & 0 deletions berkeley-mobile/Home/Search/SearchResultsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,4 @@ struct SearchResultsView: View {
SearchResultsView()
.environmentObject(SearchViewModel(chooseMapMarker: { _ in }) { _ in })
}