Merge pull request #197 from infinitered/keyboard_appearance

Allow setting keyboard_appearance with a symbol
This commit is contained in:
Gant Laborde
2015-02-21 16:33:03 -06:00
3 changed files with 19 additions and 1 deletions

View File

@@ -14,7 +14,7 @@ module RubyMotionQuery
def enables_return_key_automatically=(v) ; view.enablesReturnKeyAutomatically = v ; end
def keyboard_appearance ; view.keyboardAppearance ; end
def keyboard_appearance=(v) ; view.keyboardAppearance = v ; end
def keyboard_appearance=(v) ; view.keyboardAppearance = KEYBOARD_APPEARANCES[v] || v ; end
def keyboard_type ; view.keyboardType ; end
def keyboard_type=(v) ; view.setKeyboardType(KEYBOARD_TYPES[v] || v) ; end

View File

@@ -26,6 +26,13 @@ module RubyMotionQuery
alphabet: UIKeyboardTypeASCIICapable
}
KEYBOARD_APPEARANCES = {
default: UIKeyboardAppearanceDefault,
dark: UIKeyboardAppearanceDark,
light: UIKeyboardAppearanceLight,
alert: UIKeyboardAppearanceAlert
}
RETURN_KEY_TYPES = {
default: UIReturnKeyDefault,
go: UIReturnKeyGo,

View File

@@ -9,6 +9,7 @@ describe 'stylers/ui_text_field' do
st.autocapitalization_type = :words
st.autocorrection_type = :no
st.keyboard_type = UIKeyboardTypeDefault
st.keyboard_appearance = UIKeyboardAppearanceDark
st.return_key_type = UIReturnKeyNext
st.spell_checking_type = UITextSpellCheckingTypeYes
st.right_view_mode = :always
@@ -22,6 +23,10 @@ describe 'stylers/ui_text_field' do
st.keyboard_type = :email_address
end
def ui_text_field_alert(st)
st.keyboard_appearance = :alert
end
def ui_text_field_google(st)
st.return_key_type = :google
end
@@ -63,6 +68,7 @@ describe 'stylers/ui_text_field' do
v.autocapitalizationType.should == UITextAutocapitalizationTypeWords
v.autocorrectionType == UITextAutocorrectionTypeNo
v.keyboardType.should == UIKeyboardTypeDefault
v.keyboardAppearance.should == UIKeyboardAppearanceDark
v.returnKeyType.should == UIReturnKeyNext
v.spellCheckingType.should == UITextSpellCheckingTypeYes
v.rightViewMode == UITextFieldViewModeAlways
@@ -79,6 +85,11 @@ describe 'stylers/ui_text_field' do
view.keyboardType.should == UIKeyboardTypeEmailAddress
end
it 'should allow setting a keyboard appearance via symbol' do
view = @vc.rmq.append(@view_klass, :ui_text_field_alert).get
view.keyboardAppearance.should == UIKeyboardAppearanceAlert
end
it 'should allow setting a return key via symbol' do
view = @vc.rmq.append(@view_klass, :ui_text_field_google).get
view.returnKeyType.should == UIReturnKeyGoogle