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 the user to set a custom table_view header view. #556

Merged
merged 1 commit into from
Dec 5, 2014
Merged
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
4 changes: 4 additions & 0 deletions app/test_screens/test_table_screen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ def scroll_to_bottom
end
end

def table_header_view
UIImageView.alloc.initWithImage(UIImage.imageNamed('test'))
end

end
12 changes: 12 additions & 0 deletions lib/ProMotion/table/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def table_view

def screen_setup
check_table_data
set_up_header_view
set_up_searchable
set_up_refreshable
set_up_longpressable
Expand All @@ -28,6 +29,17 @@ def promotion_table_data
@promotion_table_data ||= TableData.new(table_data, table_view)
end

def set_up_header_view
if self.respond_to?(:table_header_view)
header_view = self.table_header_view
if header_view.is_a? UIView
self.tableView.tableHeaderView = header_view
else
PM.logger.warn "Table header views must be a UIView."
end
end
end

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)
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/tables/table_module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def default_header_height
cell.backgroundColor.should == UIColor.blueColor
end

it "should have a header view" do
@subject.tableView.tableHeaderView.class.should == UIImageView
end

describe("section with custom title_view") do

it "should use the correct class for section view" do
Expand Down