@@ -32,7 +32,7 @@ struct CartView: View {
3232 POSPageHeaderView ( title: Localization . cartTitle,
3333 backButtonConfiguration: backButtonConfiguration,
3434 trailingContent: {
35- DynamicHStack ( horizontalAlignment : . trailing , verticalAlignment : . center , spacing: Constants . cartHeaderElementSpacing) {
35+ HStack ( spacing: Constants . cartHeaderElementSpacing) {
3636 if let itemsInCartLabel = viewHelper. itemsInCartLabel ( for: posModel. cart. purchasableItems. count) {
3737 Text ( itemsInCartLabel)
3838 . font ( Constants . itemsFont)
@@ -42,13 +42,9 @@ struct CartView: View {
4242 . foregroundColor ( Color . posOnSurfaceVariantLowest)
4343 }
4444
45- Button {
45+ CartClearMenuButton ( removeAllItemsFromCart : {
4646 posModel. removeAllItemsFromCart ( )
47- ServiceLocator . analytics. track ( . pointOfSaleClearCartTapped)
48- } label: {
49- Text ( Localization . clearButtonTitle)
50- }
51- . buttonStyle ( POSOutlinedButtonStyle ( size: . extraSmall) )
47+ } )
5248 . renderedIf ( shouldShowClearCartButton)
5349 }
5450 } )
@@ -137,10 +133,6 @@ private extension CartView {
137133 " pos.cartView.cartTitle " ,
138134 value: " Cart " ,
139135 comment: " Title at the header for the Cart view. " )
140- static let clearButtonTitle = NSLocalizedString (
141- " pos.cartView.clearButtonTitle " ,
142- value: " Clear " ,
143- comment: " Title for the 'Clear' button to remove all products from the Cart. " )
144136 static let addItemsToCartHint = NSLocalizedString (
145137 " pos.cartView.addItemsToCartHint " ,
146138 value: " Tap on a product to \n add it to the cart " ,
@@ -221,6 +213,37 @@ private extension CartView {
221213
222214}
223215
216+ @available ( iOS 17 . 0 , * )
217+ private struct CartClearMenuButton : View {
218+ let removeAllItemsFromCart : ( ) -> Void
219+
220+ var body : some View {
221+ Menu {
222+ Button ( role: . destructive,
223+ action: {
224+ removeAllItemsFromCart ( )
225+ ServiceLocator . analytics. track ( . pointOfSaleClearCartTapped)
226+ } ) {
227+ Text ( Localization . clearButtonTitle)
228+ }
229+
230+ } label: {
231+ Image ( systemName: " trash " )
232+ . font ( . posButtonSymbolMedium)
233+ . foregroundStyle ( Color . posOnSurface)
234+ . dynamicTypeSize ( ... POSHeaderLayoutConstants . maximumDynamicTypeSize)
235+ . accessibilityLabel ( Localization . clearButtonTitle)
236+ }
237+ }
238+
239+ enum Localization {
240+ static let clearButtonTitle = NSLocalizedString (
241+ " pos.cartView.clearButtonTitle.1 " ,
242+ value: " Clear cart " ,
243+ comment: " Title for the 'Clear cart' confirmation button to remove all products from the Cart. " )
244+ }
245+ }
246+
224247@available ( iOS 17 . 0 , * )
225248private struct CartScrollViewContent : View {
226249 @Environment ( PointOfSaleAggregateModel . self) private var posModel
0 commit comments