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

[TIMOB-20024] iOS: Expose value, loginValue, passwordValue to AlertDialog #9046

Merged
merged 2 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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