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

Fix for #653, editing_style: :none not working properly with VoiceOver #678

Merged
merged 3 commits into from
Apr 27, 2015
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
16 changes: 16 additions & 0 deletions lib/ProMotion/table/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def screen_setup
set_up_refreshable
set_up_longpressable
set_up_row_height
set_up_accessibility
end

def check_table_data
Expand Down Expand Up @@ -89,6 +90,19 @@ def set_up_row_height
end
end

def editable?
self.promotion_table_data.sections.each do |section|
section[:cells].each do |cell|
return true if [:insert,:delete].include?(cell[:editing_style])
end
end
false
end

def set_up_accessibility
self.extend(Editable) if editable?
end

def searching?
self.promotion_table_data.filtered
end
Expand Down Expand Up @@ -235,11 +249,13 @@ def tableView(_, editingStyleForRowAtIndexPath: index_path)
map_cell_editing_style(data_cell[:editing_style])
end

module Editable
def tableView(_, commitEditingStyle: editing_style, forRowAtIndexPath: index_path)
if editing_style == UITableViewCellEditingStyleDelete
delete_row(index_path)
end
end
end

def tableView(_, canMoveRowAtIndexPath:index_path)
data_cell = self.promotion_table_data.cell(index_path: index_path, unfiltered: true)
Expand Down
18 changes: 18 additions & 0 deletions spec/unit/tables/table_screen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
screen.view.estimatedRowHeight.should == 77
end

it "sets up proper accessibility methods" do
class NoneditableTableScreen < PM::TableScreen
def on_load
end
def table_data
[{title: "test",
cells: [{title: "Non-editable test"}]}]
end
end
noneditable=NoneditableTableScreen.new
noneditable.on_load
noneditable.editable?.should==false
index_path=NSIndexPath.indexPathForRow(0, inSection: 0)
lambda {noneditable.tableView(noneditable, commitEditingStyle: UITableViewCellEditingStyleDelete, forRowAtIndexPath: index_path)}.should.raise NoMethodError
@screen.editable?.should==true
@screen.should.respond_to(:"tableView:commitEditingStyle:forRowAtIndexPath")
end

end

describe "search functionality" do
Expand Down