Skip to content
Open
Changes from all commits
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
24 changes: 15 additions & 9 deletions Sources/InstantSearchSwiftUI/View/SearchBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ public struct SearchBar: View {

/// Whether the search bar is in the editing state
@Binding public var isEditing: Bool

/// Customizable background color for the main text field
@State public var searchBarBackgroundColor =
Color(.sRGB, red: 239/255, green: 239/255, blue: 240/255, opacity: 1)

@State public var searchBarForegroundColor = Color(.gray)

private let placeholder: String
private var onSubmit: () -> Void

Expand All @@ -47,7 +53,7 @@ public struct SearchBar: View {
.overlay(
HStack {
Image(systemName: "magnifyingglass")
.foregroundColor(.gray)
.foregroundColor(searchBarForegroundColor)
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
.padding(.leading, 8)
.disabled(true)
Expand All @@ -57,7 +63,7 @@ public struct SearchBar: View {
},
label: {
Image(systemName: "multiply.circle.fill")
.foregroundColor(.gray)
.foregroundColor(searchBarForegroundColor)
.padding(.trailing, 8)
})
}
Expand All @@ -66,15 +72,15 @@ public struct SearchBar: View {
.onTapGesture {
isEditing = true
}
.background(Color(.sRGB, red: 239/255, green: 239/255, blue: 240/255, opacity: 1))
.background(searchBarBackgroundColor)
.cornerRadius(10)
if isEditing {
Button(action: {
isEditing = false
},
label: {
Text("Cancel")
})
Button<Text> {
isEditing = false
} label: {
Text("Cancel")
}
.padding(.trailing, 10)
.transition(.move(edge: .trailing))
.animation(.default)
Expand Down