@@ -678,6 +678,11 @@ private extension ProductsViewController {
678678 present ( filterProductListViewController, animated: true , completion: nil )
679679 }
680680
681+ func clearFilter( sourceBarButtonItem: UIBarButtonItem ? = nil , sourceView: UIView ? = nil ) {
682+ ServiceLocator . analytics. track ( . productListClearFiltersTapped)
683+ filters = FilterProductListViewModel . Filters ( )
684+ }
685+
681686 /// Presents products survey
682687 ///
683688 func presentProductsFeedback( ) {
@@ -728,21 +733,51 @@ private extension ProductsViewController {
728733 ///
729734 func displayNoResultsOverlay( ) {
730735 let emptyStateViewController = EmptyStateViewController ( style: . list)
736+ let config = createFilterConfig ( )
737+ displayEmptyStateViewController ( emptyStateViewController)
738+ emptyStateViewController. configure ( config)
739+ }
740+
741+ func createFilterConfig( ) -> EmptyStateViewController . Config {
742+ if filters. numberOfActiveFilters == 0 {
743+ return createNoProductsConfig ( )
744+ } else {
745+ return createNoProductsMatchFilterConfig ( )
746+ }
747+ }
748+
749+ /// Creates EmptyStateViewController.Config for no products empty view
750+ ///
751+ func createNoProductsConfig( ) -> EmptyStateViewController . Config {
731752 let message = NSLocalizedString ( " No products yet " ,
732753 comment: " The text on the placeholder overlay when there are no products on the Products tab " )
733754 let details = NSLocalizedString ( " Start selling today by adding your first product to the store. " ,
734755 comment: " The details on the placeholder overlay when there are no products on the Products tab " )
735756 let buttonTitle = NSLocalizedString ( " Add Product " ,
736757 comment: " Action to add product on the placeholder overlay when there are no products on the Products tab " )
737- let config = EmptyStateViewController . Config. withButton (
758+ return EmptyStateViewController . Config. withButton (
738759 message: . init( string: message) ,
739760 image: . emptyProductsTabImage,
740761 details: details,
741762 buttonTitle: buttonTitle) { [ weak self] button in
742763 self ? . addProduct ( sourceView: button)
743764 }
744- displayEmptyStateViewController ( emptyStateViewController)
745- emptyStateViewController. configure ( config)
765+ }
766+
767+ /// Creates EmptyStateViewController.Config for no products match the filter empty view
768+ ///
769+ func createNoProductsMatchFilterConfig( ) -> EmptyStateViewController . Config {
770+ let message = NSLocalizedString ( " No matching products found " ,
771+ comment: " The text on the placeholder overlay when no products match the filter on the Products tab " )
772+ let buttonTitle = NSLocalizedString ( " Clear Filters " ,
773+ comment: " Action to add product on the placeholder overlay when no products match the filter on the Products tab " )
774+ return EmptyStateViewController . Config. withButton (
775+ message: . init( string: message) ,
776+ image: . emptyProductsTabImage,
777+ details: " " ,
778+ buttonTitle: buttonTitle) { [ weak self] button in
779+ self ? . clearFilter ( sourceView: button)
780+ }
746781 }
747782
748783 /// Shows the EmptyStateViewController as a child view controller.
0 commit comments