From e8ce45381ccb0b62c42ceb7daa9d23c4f2f21b40 Mon Sep 17 00:00:00 2001 From: Damien Date: Sun, 27 Mar 2016 18:09:48 -0700 Subject: [PATCH 1/2] Stylers: add ruby-like constants for content alignment --- motion/ruby_motion_query/stylers/ui_control_styler.rb | 4 ++-- motion/ruby_motion_query/stylers/ui_view_styler.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/motion/ruby_motion_query/stylers/ui_control_styler.rb b/motion/ruby_motion_query/stylers/ui_control_styler.rb index 8f80631..7128d6a 100644 --- a/motion/ruby_motion_query/stylers/ui_control_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_control_styler.rb @@ -3,7 +3,7 @@ module Stylers class UIControlStyler < UIViewStyler def content_vertical_alignment=(value) - @view.contentVerticalAlignment = value + @view.contentVerticalAlignment = CONTENT_VERTICAL_ALIGNMENTS[value] || value end def content_vertical_alignment @@ -11,7 +11,7 @@ def content_vertical_alignment end def content_horizontal_alignment=(value) - @view.contentHorizontalAlignment = value + @view.contentHorizontalAlignment = CONTENT_HORIZONTAL_ALIGNMENTS[value] || value end def content_horizontal_alignment diff --git a/motion/ruby_motion_query/stylers/ui_view_styler.rb b/motion/ruby_motion_query/stylers/ui_view_styler.rb index 5d7b94b..6527e35 100644 --- a/motion/ruby_motion_query/stylers/ui_view_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_view_styler.rb @@ -10,6 +10,16 @@ module Stylers natural: NSTextAlignmentNatural } + CONTENT_HORIZONTAL_ALIGNMENTS = { + left: UIControlContentHorizontalAlignmentLeft, + right: UIControlContentHorizontalAlignmentRight + } + + CONTENT_VERTICAL_ALIGNMENTS = { + top: UIControlContentVerticalAlignmentTop, + bottom: UIControlContentVerticalAlignmentBottom + } + KEYBOARD_TYPES = { default: UIKeyboardTypeDefault, ascii: UIKeyboardTypeASCIICapable, From 3bbbf0fa257b4fdc8e84fd8d6d20711e64116ba2 Mon Sep 17 00:00:00 2001 From: Damien Date: Sun, 27 Mar 2016 19:39:26 -0700 Subject: [PATCH 2/2] Stylers: add the rest of the content alignment options --- motion/ruby_motion_query/stylers/ui_view_styler.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/motion/ruby_motion_query/stylers/ui_view_styler.rb b/motion/ruby_motion_query/stylers/ui_view_styler.rb index 6527e35..de0d696 100644 --- a/motion/ruby_motion_query/stylers/ui_view_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_view_styler.rb @@ -11,13 +11,17 @@ module Stylers } CONTENT_HORIZONTAL_ALIGNMENTS = { + center: UIControlContentHorizontalAlignmentCenter, left: UIControlContentHorizontalAlignmentLeft, - right: UIControlContentHorizontalAlignmentRight + right: UIControlContentHorizontalAlignmentRight, + fill: UIControlContentHorizontalAlignmentFill } CONTENT_VERTICAL_ALIGNMENTS = { + center: UIControlContentHorizontalAlignmentCenter, top: UIControlContentVerticalAlignmentTop, - bottom: UIControlContentVerticalAlignmentBottom + bottom: UIControlContentVerticalAlignmentBottom, + fill: UIControlContentHorizontalAlignmentFill } KEYBOARD_TYPES = {