Skip to content

Commit c6e9043

Browse files
committed
Add clear option for bookings date filter
1 parent 0ca913c commit c6e9043

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

WooCommerce/Classes/Bookings/BookingFilters/BookingDateTimeFilterView.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ struct BookingDateTimeFilterView: View {
5555
.listStyle(.plain)
5656
.navigationTitle(Localization.title)
5757
.navigationBarTitleDisplayMode(.inline)
58+
.toolbar {
59+
ToolbarItem(placement: .navigationBarTrailing) {
60+
Button(Localization.clear) {
61+
clearDateRange()
62+
}
63+
.disabled(selectedFromDate == nil && selectedToDate == nil)
64+
}
65+
}
5866
.background(Color(.listBackground))
5967
.environment(\.timeZone, TimeZone(identifier: "UTC")!) // API treats dates as no timezone so use UTC to display and select dates
6068
.onChange(of: fromDate) { _, newValue in
@@ -157,6 +165,12 @@ private extension BookingDateTimeFilterView {
157165
return fromDate...Date.distantFuture
158166
}
159167
}
168+
169+
func clearDateRange() {
170+
selectedFromDate = nil
171+
selectedToDate = nil
172+
expandedPicker = nil
173+
}
160174
}
161175

162176
private extension BookingDateTimeFilterView {
@@ -186,6 +200,11 @@ private extension BookingDateTimeFilterView {
186200
value: "Time",
187201
comment: "Title of the Time row in the date time picker for booking filter"
188202
)
203+
static let clear = NSLocalizedString(
204+
"bookingDateTimeFilterView.clear",
205+
value: "Clear",
206+
comment: "Title of the Clear button in the date time picker for booking filter"
207+
)
189208
}
190209
}
191210

0 commit comments

Comments
 (0)