Skip to content

Commit

Permalink
Merge pull request #9046 from hansemannn/TIMOB-20024
Browse files Browse the repository at this point in the history
[TIMOB-20024] iOS: Expose value, loginValue, passwordValue to AlertDialog
  • Loading branch information
mukherjee2 committed May 11, 2017
2 parents ae1203b + fbb6bcc commit 6b41ae7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
28 changes: 28 additions & 0 deletions apidoc/Titanium/UI/AlertDialog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ properties:
constants: Titanium.UI.RETURNKEY_*
default: <Titanium.UI.RETURNKEY_NEXT>

- name: loginValue
summary: Value of the login text field inside the dialog.
description: |
Note that this property is only available if dialog `style` property is defined as
<Titanium.UI.iOS.AlertDialogStyle.LOGIN_AND_PASSWORD_INPUT>.
type: String
since: "6.1.0"
platforms: [iphone, ipad]

- name: loginKeyboardType
summary: Keyboard type to display when this text field inside the dialog is focused.
description: |
Expand Down Expand Up @@ -352,6 +361,15 @@ properties:
constants: Titanium.UI.RETURNKEY_*
default: <Titanium.UI.RETURNKEY_DONE>

- name: passwordValue
summary: Value of the password text field inside the dialog.
description: |
Note that this property is only available if dialog `style` property is defined as
<Titanium.UI.iOS.AlertDialogStyle.LOGIN_AND_PASSWORD_INPUT>.
type: String
since: "6.1.0"
platforms: [iphone, ipad]

- name: passwordKeyboardType
summary: Keyboard type to display when this text field inside the dialog is focused.
description: |
Expand Down Expand Up @@ -430,6 +448,16 @@ properties:
summary: Key identifying a string in the locale file to use for the title text.
type: String
platforms: [android, iphone, ipad, mobileweb]

- name: value
summary: Value of the text field inside the dialog.
description: |
Note that this property is only available if dialog `style` property is defined as
<Titanium.UI.iOS.AlertDialogStyle.PLAIN_TEXT_INPUT> or
<Titanium.UI.iOS.AlertDialogStyle.SECURE_TEXT_INPUT>.
type: String
since: "6.1.0"
platforms: [iphone, ipad]

examples:
- title: Single-button Alert Dialog (using alias)
Expand Down
5 changes: 4 additions & 1 deletion iphone/Classes/TiUIAlertDialogProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,23 @@ -(void)show:(id)args
if ( (style == UIAlertViewStylePlainTextInput) || (style == UIAlertViewStyleSecureTextInput) ) {
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.secureTextEntry = (style == UIAlertViewStyleSecureTextInput);
textField.placeholder = [TiUtils stringValue:[self valueForKey:@"hintText"]] ?: @"";
textField.placeholder = [TiUtils stringValue:[self valueForKey:@"hintText"]];
textField.text = [TiUtils stringValue:[self valueForKey:@"value"]];
textField.keyboardType = [TiUtils intValue:[self valueForKey:@"keyboardType"] def:UIKeyboardTypeDefault];
textField.returnKeyType = [TiUtils intValue:[self valueForKey:@"returnKeyType"] def:UIReturnKeyDefault];
textField.keyboardAppearance = [TiUtils intValue:[self valueForKey:@"keyboardAppearance"] def:UIKeyboardAppearanceDefault];
}];
} else if ((style == UIAlertViewStyleLoginAndPasswordInput)) {
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.keyboardType = [TiUtils intValue:[self valueForKey:@"loginKeyboardType"] def:UIKeyboardTypeDefault];
textField.text = [TiUtils stringValue:[self valueForKey:@"loginValue"]];
textField.returnKeyType = [TiUtils intValue:[self valueForKey:@"loginReturnKeyType"] def:UIReturnKeyNext];
textField.keyboardAppearance = [TiUtils intValue:[self valueForKey:@"keyboardAppearance"] def:UIKeyboardAppearanceDefault];
textField.placeholder = [TiUtils stringValue:[self valueForKey:@"loginHintText"]] ?: @"Login";
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.keyboardType = [TiUtils intValue:[self valueForKey:@"passwordKeyboardType"] def:UIKeyboardTypeDefault];
textField.text = [TiUtils stringValue:[self valueForKey:@"passwordValue"]];
textField.returnKeyType = [TiUtils intValue:[self valueForKey:@"passwordReturnKeyType"] def:UIReturnKeyDone];
textField.keyboardAppearance = [TiUtils intValue:[self valueForKey:@"keyboardAppearance"] def:UIKeyboardAppearanceDefault];
textField.placeholder = [TiUtils stringValue:[self valueForKey:@"passwordHintText"]] ?: @"Password";
Expand Down

0 comments on commit 6b41ae7

Please sign in to comment.