@@ -21,7 +21,7 @@ final class SearchView: BaseView {
2121
2222 private let searchBar = BKSearchTextField (
2323 placeholder: " 도서 검색 후 내 서재에 담아보세요. " ,
24- type: . brand
24+ type: . normal
2525 )
2626
2727 private let divider = BKDivider ( type: . medium)
@@ -78,6 +78,10 @@ final class SearchView: BaseView {
7878 searchBar. placeholder = placeholder
7979 }
8080
81+ func setSearchBarText( with text: String ) {
82+ searchBar. text = text
83+ }
84+
8185 func applySnapshot(
8286 with state: SearchViewModel . SearchState ,
8387 count: Int = 0
@@ -101,10 +105,12 @@ final class SearchView: BaseView {
101105 let headerHeight = header. bounds. height
102106 let offset = - ( headerHeight / 2.0 )
103107 collectionView. backgroundView = makeEmptyLabel ( state. placeholder, verticalOffset: offset)
108+ searchBar. setClearButtonMode ( . whileEditing)
104109 } else {
105110 collectionView. backgroundView = nil
106111 snapshot. appendSections ( [ . result] )
107112 snapshot. appendItems ( state. books. map { . result( $0) } , toSection: . result)
113+ searchBar. setClearButtonMode ( . always)
108114 }
109115 header. setTitle ( . result( count: count) )
110116 layoutMode = . afterSearch
@@ -158,6 +164,7 @@ private extension SearchView {
158164 }
159165 cell. onQueryLabelTapped = { [ weak self] in
160166 self ? . eventPublisher. send ( . search( keyword) )
167+ self ? . setSearchBarText ( with: keyword)
161168 }
162169
163170 return cell
0 commit comments