diff --git a/motion/ruby_motion_query/stylers/ui_table_view_cell_styler.rb b/motion/ruby_motion_query/stylers/ui_table_view_cell_styler.rb index 006ea86..ae4eacc 100644 --- a/motion/ruby_motion_query/stylers/ui_table_view_cell_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_table_view_cell_styler.rb @@ -24,13 +24,37 @@ module RubyMotionQuery alias :color :text_color alias :color= :text_color= + def detail_text_color + if @view.detailTextLabel + @view.detailTextLabel.textColor + end + end + + def detail_text_color=(v) + if @view.detailTextLabel + @view.detailTextLabel.textColor = v + end + end + alias :detail_color :text_color + alias :detail_color= :text_color= + def font ; @view.textLabel.font ; end def font=(v) ; @view.textLabel.font = v ; end + def detail_font + @view.detailTextLabel.font if @view.detailTextLabel + end + + def detail_font=(v) + if @view.detailTextLabel + @view.detailTextLabel.font = v + end + end + def selection_style ; @view.selectionStyle ; end def selection_style=(v) ; @view.selectionStyle = v ; end end end -end \ No newline at end of file +end diff --git a/spec/stylers/ui_table_view_cell_styler_spec.rb b/spec/stylers/ui_table_view_cell_styler_spec.rb index baa7bd0..e62cd4e 100644 --- a/spec/stylers/ui_table_view_cell_styler_spec.rb +++ b/spec/stylers/ui_table_view_cell_styler_spec.rb @@ -2,8 +2,10 @@ class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet def ui_table_view_cell_kitchen_sink(st) st.text_color = rmq.color.red - st.font = rmq.font.system(11) + st.font = rmq.font.system(15) st.selection_style = UITableViewCellSelectionStyleBlue + st.detail_text_color = rmq.color.green + st.detail_font = rmq.font.system(11) end end @@ -17,11 +19,29 @@ describe 'stylers/ui_table_view_cell' do behaves_like "styler" it 'should apply a style with every UITableViewCell wrapper method' do - view = @vc.rmq.create!(@view_klass, :ui_table_view_cell_kitchen_sink) - view.tap do |v| - view.textLabel.textColor.should.equal(rmq.color.red) - view.textLabel.font.should.equal(rmq.font.system(11)) - view.selectionStyle.should.equal(UITableViewCellSelectionStyleBlue) + cell = UITableViewCell.alloc.initWithStyle(UITableViewCellStyleSubtitle, reuseIdentifier: "test-cell") + @vc.rmq(cell).apply_style(:ui_table_view_cell_kitchen_sink) + cell.tap do |c| + c.textLabel.textColor.should.equal(rmq.color.red) + c.textLabel.font.should.equal(rmq.font.system(15)) + c.selectionStyle.should.equal(UITableViewCellSelectionStyleBlue) + c.detailTextLabel.textColor.should.equal(rmq.color.green) + c.detailTextLabel.font.should.equal(rmq.font.system(11)) + end + + @vc.rmq(cell).style do |st| + st.text_color.should.equal(rmq.color.red) + st.detail_text_color.should.equal(rmq.color.green) + st.font.should.equal(rmq.font.system(15)) + st.detail_font.should.equal(rmq.font.system(11)) + end + end + + it 'should not raise if the cell does not have a detail label' do + cell = UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: "default-cell") + + should.not.raise(NoMethodError) do + @vc.rmq(cell).apply_style(:ui_table_view_cell_kitchen_sink) end end end