Skip to content

Commit b9277d0

Browse files
committed
Improve search field animation: animate search button and search field separately
1 parent a44a95e commit b9277d0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Modules/Sources/PointOfSale/Presentation/Orders/POSOrderListView.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ struct POSOrderListView: View {
1313
@Environment(\.siteTimezone) private var siteTimezone
1414
@StateObject private var infiniteScrollTriggerDeterminer = ThresholdInfiniteScrollTriggerDeterminer()
1515

16-
@Namespace private var searchTransition
17-
1816
private var ordersViewState: POSOrderListState {
1917
orderListModel.ordersController.ordersViewState
2018
}
@@ -45,8 +43,11 @@ struct POSOrderListView: View {
4543
setSearch(true)
4644
}
4745
.accessibilityLabel(Localization.searchButtonAccessibilityLabel)
48-
.matchedGeometryEffect(id: Constants.searchControlID, in: searchTransition)
49-
.transition(.opacity.combined(with: .scale))
46+
.transition(.asymmetric(
47+
insertion: .scale.combined(with: .opacity)
48+
.animation(.easeInOut(duration: Constants.animationDuration).delay(Constants.animationDuration)),
49+
removal: .opacity.animation(.easeInOut(duration: Constants.animationDuration * 0.5))
50+
))
5051
}
5152

5253
if isSearching {
@@ -58,8 +59,12 @@ struct POSOrderListView: View {
5859
}
5960
)
6061
.posSearchTextFieldUnfocusedBorderColor(.posOutlineVariant)
61-
.matchedGeometryEffect(id: Constants.searchControlID, in: searchTransition)
62-
.transition(.opacity.combined(with: .move(edge: .leading)))
62+
.transition(.asymmetric(
63+
insertion: .opacity.combined(with: .move(edge: .trailing))
64+
.animation(.easeInOut(duration: Constants.animationDuration).delay(Constants.animationDuration * 0.5)),
65+
removal: .opacity.combined(with: .move(edge: .trailing))
66+
.animation(.easeInOut(duration: Constants.animationDuration))
67+
))
6368
.onChange(of: searchTerm) { _, newValue in
6469
if newValue.isEmpty {
6570
orderListModel.ordersController.clearSearchOrders()
@@ -381,7 +386,6 @@ private enum Constants {
381386
static let orderCardMinHeight: CGFloat = 112
382387
static let maximumOrderCardHeight: CGFloat = Constants.orderCardMinHeight * 2
383388
static let animationDuration: CGFloat = 0.2
384-
static let searchControlID = "searchControl"
385389
static let scrollTopID = "orderListViewTopID"
386390
}
387391

0 commit comments

Comments
 (0)