Skip to content

Commit 954659f

Browse files
committed
Adjust the search text view slightly
1 parent 441c95f commit 954659f

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Release Notes.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* `FormActionButton` now uses `true` as default value for the `dimmed` modifier.
1919
* `FormActionButtonStyle` now lets you style more parts of the form action button.
2020
* `FormText` no longers forces lowercase to its title.
21+
* `SearchBar` no longer adds a divider below the text field.
2122
* `TextFieldClearButton` now animates in the clear button.
2223

2324
### 🐛 Bug fixes

Sources/SwiftUIKit/Views/SearchBar.swift

+17-9
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,12 @@ public struct SearchBar: View {
4141
private let searchFieldPadding: CGFloat
4242
private let searchFieldMargin: CGFloat
4343

44-
public var hasText: Bool {
45-
!text.wrappedValue.isEmpty
46-
}
47-
4844
public var body: some View {
4945
VStack(spacing: 0) {
5046
HStack {
5147
searchField
5248
cancelButton
5349
}.padding(searchFieldMargin)
54-
Divider()
5550
}
5651
}
5752
}
@@ -61,6 +56,10 @@ public struct SearchBar: View {
6156

6257
private extension SearchBar {
6358

59+
var hasText: Bool {
60+
!text.wrappedValue.isEmpty
61+
}
62+
6463
@ViewBuilder
6564
var cancelButton: some View {
6665
if hasText {
@@ -75,7 +74,8 @@ private extension SearchBar {
7574
var searchField: some View {
7675
HStack {
7776
Image(systemName: "magnifyingglass")
78-
TextField(title, text: text).withClearButton(for: text)
77+
TextField(title, text: text)
78+
.withClearButton(for: text)
7979
}
8080
.padding(searchFieldPadding)
8181
.background(searchFieldBackground)
@@ -95,11 +95,19 @@ private extension SearchBar {
9595
}
9696

9797
struct SearchBar_Previews: PreviewProvider {
98-
99-
@State static var text = ""
98+
99+
struct Preview: View {
100+
101+
@State
102+
var text = ""
103+
104+
var body: some View {
105+
SearchBar(title: "Search", text: $text, cancelText: "Cancel")
106+
}
107+
}
100108

101109
static var previews: some View {
102-
SearchBar(title: "Search", text: $text, cancelText: "Cancel")
110+
Preview()
103111
}
104112
}
105113
#endif

0 commit comments

Comments
 (0)