lib/ProMotion/table/extensions/searchable.rb in ProMotion-2.4.2 vs lib/ProMotion/table/extensions/searchable.rb in ProMotion-2.5.0.beta1

- old
+ new

@@ -9,10 +9,12 @@ if params[:search_bar] && params[:search_bar][:placeholder] search_bar.placeholder = params[:search_bar][:placeholder] end + @no_results_text = params[:search_bar][:no_results] if params[:search_bar][:no_results] + @table_search_display_controller = UISearchDisplayController.alloc.initWithSearchBar(search_bar, contentsController: params[:content_controller]) @table_search_display_controller.delegate = params[:delegate] @table_search_display_controller.searchResultsDataSource = params[:data_source] @table_search_display_controller.searchResultsDelegate = params[:search_results_delegate] @@ -37,13 +39,22 @@ search_bar = UISearchBar.alloc.initWithFrame(params[:frame]) search_bar.autoresizingMask = UIViewAutoresizingFlexibleWidth search_bar end + def set_no_results_text(controller) + Dispatch::Queue.main.async do + controller.searchResultsTableView.subviews.each do |v| + v.text = @no_results_text if v.is_a?(UILabel) + end + end if @no_results_text + end + ######### iOS methods, headless camel case ####### def searchDisplayController(controller, shouldReloadTableForSearchString:search_string) self.promotion_table_data.search(search_string) + set_no_results_text(controller) if @no_results_text true end def searchDisplayControllerWillEndSearch(controller) self.promotion_table_data.stop_searching