Skip to content

Commit c07807f

Browse files
committed
Set appropriate search field placeholder
1 parent b129e7c commit c07807f

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

WooCommerce/Classes/POS/Presentation/Item Search/POSProductSearchable.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import protocol Yosemite.POSSearchHistoryProviding
44
import enum Yosemite.POSItem
55

66
final class POSProductSearchable: POSSearchable {
7-
let itemListType: ItemListType
7+
private let itemListType: ItemListType
88
private let itemsController: PointOfSaleSearchingItemsControllerProtocol
99
private let searchHistoryProvider: POSSearchHistoryProviding
1010

@@ -20,6 +20,10 @@ final class POSProductSearchable: POSSearchable {
2020
searchHistoryProvider.searchHistory(for: itemListType.itemType)
2121
}
2222

23+
var searchFieldPlaceholder: String {
24+
itemListType.itemType.searchFieldLabel
25+
}
26+
2327
func performSearch(term: String) async {
2428
await itemsController.searchItems(searchTerm: term, baseItem: .root)
2529
}

WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import enum Yosemite.POSItem
44

55
/// Protocol defining search capabilities for POS items
66
protocol POSSearchable {
7-
/// The type of item lists being searched
8-
var itemListType: ItemListType { get }
9-
7+
var searchFieldPlaceholder: String { get }
108
/// Recent search history for the current item type
119
var searchHistory: [String] { get }
1210

@@ -47,7 +45,7 @@ struct POSSearchField: View {
4745
}))
4846

4947
TextField(text: $searchTerm) {
50-
Text(searchable.itemListType.itemType.searchFieldLabel)
48+
Text(searchable.searchFieldPlaceholder)
5149
}
5250
.textFieldStyle(POSSearchTextFieldStyle(focused: isSearchFieldFocused,
5351
searchTerm: $searchTerm))
@@ -107,13 +105,16 @@ struct POSSearchContentView<Content: View>: View {
107105
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
108106

109107
private let searchable: any POSSearchable
108+
private let itemListType: ItemListType
110109
@Binding private var searchTerm: String
111110
private let content: (Bool) -> Content
112111

113112
init(searchable: any POSSearchable,
113+
itemListType: ItemListType,
114114
searchTerm: Binding<String>,
115115
@ViewBuilder content: @escaping (Bool) -> Content) {
116116
self.searchable = searchable
117+
self.itemListType = itemListType
117118
self._searchTerm = searchTerm
118119
self.content = content
119120
}
@@ -134,15 +135,15 @@ struct POSSearchContentView<Content: View>: View {
134135
onSearchSelected: { selectedSearchTerm in
135136
searchTerm = selectedSearchTerm
136137
ServiceLocator.analytics.track(
137-
event: .PointOfSale.preSearchRecentTermTapped(itemListType: searchable.itemListType))
138+
event: .PointOfSale.preSearchRecentTermTapped(itemListType: itemListType))
138139
},
139-
itemListType: searchable.itemListType
140+
itemListType: itemListType
140141
)
141142
}
142143
}
143144

144145
// MARK: - Localization
145-
private extension POSItemType {
146+
extension POSItemType {
146147
var searchFieldLabel: String {
147148
switch self {
148149
case .product:

WooCommerce/Classes/POS/Presentation/ItemListView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct ItemListView: View {
128128
searchable: POSProductSearchable(itemListType: selectedItemListType,
129129
itemsController: searchItemsController,
130130
searchHistoryProvider: posModel.searchHistoryService),
131+
itemListType: selectedItemListType,
131132
searchTerm: $searchTerm
132133
) { _ in
133134
itemListContent(selectedItemListType)

WooCommerce/Classes/POS/Presentation/Orders/PointOfSaleOrderListView.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,14 @@ private extension PointOfSaleOrderListView {
333333
final class POSOrderSearchable: POSSearchable {
334334
private let ordersController: PointOfSaleSearchingOrderListControllerProtocol
335335

336-
var itemListType: ItemListType {
337-
.products(search: false)
338-
}
339-
340336
init(ordersController: PointOfSaleSearchingOrderListControllerProtocol) {
341337
self.ordersController = ordersController
342338
}
343339

340+
var searchFieldPlaceholder: String {
341+
Localization.searchFieldPlaceholder
342+
}
343+
344344
var searchHistory: [String] {
345345
[]
346346
}
@@ -368,6 +368,12 @@ private enum Localization {
368368
"pos.orderListView.ordersTitle",
369369
value: "Orders",
370370
comment: "Title at the header for the Orders view.")
371+
372+
static let searchFieldPlaceholder = NSLocalizedString(
373+
"pos.orderListView.searchFieldPlaceholder",
374+
value: "Search orders",
375+
comment: "Placeholder for a search field in the Orders view."
376+
)
371377
}
372378

373379
#if DEBUG

0 commit comments

Comments
 (0)