From 89ec46cee4b8557c057d2c72683ff7e633f44b19 Mon Sep 17 00:00:00 2001 From: Ankit Goyal Date: Sat, 13 Nov 2021 00:49:35 +0530 Subject: [PATCH] Fixed Number Range Component Length issue (#404) Fixed Reset search API not called issue --- .../SearchNumberRangeComponentViewController.swift | 8 +++++--- .../SearchNumberRangeComponentViewModel.swift | 1 + .../List/Screens/ResultViewController.swift | 7 ++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewController.swift b/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewController.swift index 69085f409..e9f15e065 100644 --- a/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewController.swift +++ b/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewController.swift @@ -175,12 +175,14 @@ extension SearchNumberRangeComponentViewController: UITextFieldDelegate { guard CharacterSet(charactersIn: "0123456789").isSuperset(of: CharacterSet(charactersIn: string)) else { return false } - + let text = textField.updatedText(for: range, replacementString: string) ?? "" + if text.count > numberRangeViewModel.maxCharacters { + return false + } + if textField == minRangeTextField { - let text = textField.updatedText(for: range, replacementString: string) checkForError(for: text, and: maxRangeTextField.text) } else { - let text = textField.updatedText(for: range, replacementString: string) checkForError(for: minRangeTextField.text, and: text) } return true diff --git a/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewModel.swift b/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewModel.swift index 8337f0f9e..f3ef77ade 100644 --- a/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewModel.swift +++ b/ContentApp/Modules/Advance Search/Number Range/SearchNumberRangeComponentViewModel.swift @@ -23,6 +23,7 @@ class SearchNumberRangeComponentViewModel: NSObject { var selectedCategory: SearchCategories? let stringConcatenator = "-" var queryBuilder: String? + let maxCharacters = 9 var title: String { return selectedCategory?.name ?? "" diff --git a/ContentApp/PresentationLayer/List/Screens/ResultViewController.swift b/ContentApp/PresentationLayer/List/Screens/ResultViewController.swift index c10fe010c..c30f4c3d8 100644 --- a/ContentApp/PresentationLayer/List/Screens/ResultViewController.swift +++ b/ContentApp/PresentationLayer/List/Screens/ResultViewController.swift @@ -240,7 +240,6 @@ extension ResultViewController { dropDown.selectionAction = { (index: Int, item: String) in self.resultsViewModel?.searchModel.selectedSearchFilter = self.resultsViewModel?.searchFilters[index] self.updateCategory() - self.pageController?.refreshList() // refresh list by calling search api } } } @@ -252,6 +251,7 @@ extension ResultViewController { categoryNameLabel.text = resultsViewModel?.selectedFilterName(for: selectedConfig) resultsViewModel?.resetAdvanceSearch() // reset categories for selected value resetChipCollectionView() + pageController?.refreshList() // refresh list by calling search api showResetFilterButton() } } @@ -487,6 +487,7 @@ extension ResultViewController { if let selectedCategory = resultsViewModel?.getSelectedCategory() { let viewController = SearchTextComponentViewController.instantiateViewController() let bottomSheet = MDCBottomSheetController(contentViewController: viewController) + bottomSheet.dismissOnDraggingDownSheet = false bottomSheet.delegate = self viewController.coordinatorServices = coordinatorServices viewController.textViewModel.selectedCategory = selectedCategory @@ -507,6 +508,7 @@ extension ResultViewController { if let selectedCategory = resultsViewModel?.getSelectedCategory() { let viewController = SearchListComponentViewController.instantiateViewController() let bottomSheet = MDCBottomSheetController(contentViewController: viewController) + bottomSheet.dismissOnDraggingDownSheet = false bottomSheet.delegate = self viewController.coordinatorServices = coordinatorServices viewController.listViewModel.isRadioList = isRadio @@ -528,6 +530,7 @@ extension ResultViewController { if let selectedCategory = resultsViewModel?.getSelectedCategory() { let viewController = SearchNumberRangeComponentViewController.instantiateViewController() let bottomSheet = MDCBottomSheetController(contentViewController: viewController) + bottomSheet.dismissOnDraggingDownSheet = false bottomSheet.delegate = self viewController.coordinatorServices = coordinatorServices viewController.numberRangeViewModel.selectedCategory = selectedCategory @@ -548,6 +551,7 @@ extension ResultViewController { if let selectedCategory = resultsViewModel?.getSelectedCategory() { let viewController = SearchSliderRangeComponentViewController.instantiateViewController() let bottomSheet = MDCBottomSheetController(contentViewController: viewController) + bottomSheet.dismissOnDraggingDownSheet = false bottomSheet.delegate = self viewController.coordinatorServices = coordinatorServices viewController.sliderViewModel.selectedCategory = selectedCategory @@ -568,6 +572,7 @@ extension ResultViewController { if let selectedCategory = resultsViewModel?.getSelectedCategory() { let viewController = SearchCalendarComponentViewController.instantiateViewController() let bottomSheet = MDCBottomSheetController(contentViewController: viewController) + bottomSheet.dismissOnDraggingDownSheet = false bottomSheet.delegate = self viewController.coordinatorServices = coordinatorServices viewController.calendarViewModel.selectedCategory = selectedCategory