mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-01-12 17:52:17 +08:00
Adds styling for cell detail text label
This commit is contained in:
@@ -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
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user