Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow search bar to be hidden initially #618

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ProMotion/table/extensions/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def make_searchable(params={})
@table_search_display_controller.searchResultsDataSource = params[:data_source]
@table_search_display_controller.searchResultsDelegate = params[:search_results_delegate]

self.table_view.tableHeaderView = search_bar
self.tableView.tableHeaderView = search_bar
end
alias :makeSearchable :make_searchable

Expand Down
3 changes: 3 additions & 0 deletions lib/ProMotion/table/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def set_up_header_view
def set_up_searchable
if self.class.respond_to?(:get_searchable) && self.class.get_searchable
self.make_searchable(content_controller: self, search_bar: self.class.get_searchable_params)
if self.class.get_searchable_params[:hide_initially]
self.tableView.contentOffset = CGPointMake(0, self.searchDisplayController.searchBar.frame.size.height)
end
end
end

Expand Down
13 changes: 13 additions & 0 deletions spec/unit/tables/table_screen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@
@screen.tableView.tableHeaderView.should.be.kind_of UISearchBar
end

it "should not hide the search bar initally by default" do
@screen.tableView.contentOffset.should == CGPointMake(0,0)
end

it "should allow hiding the search bar initally" do
class HiddenSearchScreen < TableScreenSearchable
searchable hide_initially: true
end
screen = HiddenSearchScreen.new
screen.on_load
screen.tableView.contentOffset.should == CGPointMake(0,screen.searchDisplayController.searchBar.frame.size.height)
end

end

describe "refresh functionality" do
Expand Down