From 72a6f45defdfb0e271ff5a450fdc5c9b94c98dc1 Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Wed, 25 Feb 2015 17:09:31 -0600 Subject: [PATCH] Adds indicator_style for UIScrollView Tests failing for some reason. --- .../stylers/ui_scroll_view_styler.rb | 10 ++++++++++ spec/stylers/ui_scroll_view_styler.rb | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/motion/ruby_motion_query/stylers/ui_scroll_view_styler.rb b/motion/ruby_motion_query/stylers/ui_scroll_view_styler.rb index 5f6a34e..f5f2793 100644 --- a/motion/ruby_motion_query/stylers/ui_scroll_view_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_scroll_view_styler.rb @@ -1,6 +1,14 @@ module RubyMotionQuery module Stylers + INDICATOR_STYLES = { + default: UIScrollViewIndicatorStyleDefault, + black: UIScrollViewIndicatorStyleBlack, + dark: UIScrollViewIndicatorStyleBlack, + white: UIScrollViewIndicatorStyleWhite, + light: UIScrollViewIndicatorStyleWhite + } + class UIScrollViewStyler < UIViewStyler def paging=(value) ; @view.pagingEnabled = value ; end def paging ; @view.isPagingEnabled ; end @@ -32,6 +40,8 @@ module RubyMotionQuery def scroll_indicator_insets=(value); @view.scrollIndicatorInsets = value; end def scroll_indicator_insets; @view.scrollIndicatorInsets; end + def indicator_style=(value); @view.indicatorStyle = INDICATOR_STYLES[value] || value; end + def indicator_style; @view.indicatorStyle; end end diff --git a/spec/stylers/ui_scroll_view_styler.rb b/spec/stylers/ui_scroll_view_styler.rb index 6fdbbf8..5046545 100644 --- a/spec/stylers/ui_scroll_view_styler.rb +++ b/spec/stylers/ui_scroll_view_styler.rb @@ -12,6 +12,8 @@ class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet st.content_inset = st.content_inset st.content_inset = UIEdgeInsetsMake(1, 2, 3, 4) + + st.indicator_style = UIScrollViewIndicatorStyleDefault end # We have to test contentOffset separately from contentInset @@ -21,6 +23,10 @@ class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet st.content_offset = CGPointMake(12, 12) end + def ui_scroll_view_white_indicators + st.indicator_style = :white + end + end describe 'stylers/ui_scroll_view' do @@ -40,13 +46,18 @@ describe 'stylers/ui_scroll_view' do v.isScrollEnabled.should == false v.isDirectionalLockEnabled.should == true v.contentInset.should == UIEdgeInsetsMake(1, 2, 3, 4) + v.indicatorStyle.should == UIScrollViewIndicatorStyleDefault end view = @vc.rmq.append(@view_klass, :ui_scroll_view_content_offset).get - view.tap do |v| v.contentOffset.should == CGPointMake(12, 12) end + view = @vc.rmq.append(@view_klass, :ui_scroll_view_white_indicators).get + view.tap do |v| + v.indicatorStyle.should == UIScrollViewIndicatorStyleWhite + end + end end