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

Stylers: add ruby-like constants for content alignment #317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions motion/ruby_motion_query/stylers/ui_control_styler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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
@view.contentVerticalAlignment
end

def content_horizontal_alignment=(value)
@view.contentHorizontalAlignment = value
@view.contentHorizontalAlignment = CONTENT_HORIZONTAL_ALIGNMENTS[value] || value
end

def content_horizontal_alignment
Expand Down
14 changes: 14 additions & 0 deletions motion/ruby_motion_query/stylers/ui_view_styler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ module Stylers
natural: NSTextAlignmentNatural
}

CONTENT_HORIZONTAL_ALIGNMENTS = {
center: UIControlContentHorizontalAlignmentCenter,
left: UIControlContentHorizontalAlignmentLeft,
right: UIControlContentHorizontalAlignmentRight,
fill: UIControlContentHorizontalAlignmentFill
}

CONTENT_VERTICAL_ALIGNMENTS = {
center: UIControlContentHorizontalAlignmentCenter,
top: UIControlContentVerticalAlignmentTop,
bottom: UIControlContentVerticalAlignmentBottom,
fill: UIControlContentHorizontalAlignmentFill
}

KEYBOARD_TYPES = {
default: UIKeyboardTypeDefault,
ascii: UIKeyboardTypeASCIICapable,
Expand Down