Actually use the 'defaultValue' property in AlertViewIOS.

Summary:The AlertViewIOS component takes in a 'defaultValue' for the text input but never actually sets it, this PR actually sets the value.
Closes https://github.com/facebook/react-native/pull/6257

Differential Revision: D3052412

Pulled By: nicklockwood

fb-gh-sync-id: 32285330f17ccf47189dbc8fcab48f3712fee59b
shipit-source-id: 32285330f17ccf47189dbc8fcab48f3712fee59b
This commit is contained in:
Morgan Pretty 2016-03-15 04:25:43 -07:00 committed by Facebook Github Bot 1
parent 64a09feaf7
commit 2605a2299f
2 changed files with 11 additions and 7 deletions

View File

@ -718,9 +718,6 @@ static uint32_t readUint32(const void **ptr) {
// offset where the code starts on the bundle
const uint32_t baseOffset = currentOffset + tableLength;
// skip table length
currentOffset += sizeof(baseOffset);
// pointer to first byte out of the index
const uint8_t *endOfTable = bytes + baseOffset;

View File

@ -75,6 +75,7 @@ RCT_EXPORT_METHOD(alertWithArgs:(NSDictionary *)args
NSString *message = [RCTConvert NSString:args[@"message"]];
UIAlertViewStyle type = [RCTConvert UIAlertViewStyle:args[@"type"]];
NSArray<NSDictionary *> *buttons = [RCTConvert NSDictionaryArray:args[@"buttons"]];
NSString *defaultValue = [RCTConvert NSString:args[@"defaultValue"]];
NSString *cancelButtonKey = [RCTConvert NSString:args[@"cancelButtonKey"]];
NSString *destructiveButtonKey = [RCTConvert NSString:args[@"destructiveButtonKey"]];
@ -112,7 +113,6 @@ RCT_EXPORT_METHOD(alertWithArgs:(NSDictionary *)args
alertView.message = message;
if (type != UIAlertViewStyleDefault) {
NSString *defaultValue = [RCTConvert NSString:args[@"defaultValue"]];
[alertView textFieldAtIndex:0].text = defaultValue;
}
@ -168,25 +168,32 @@ RCT_EXPORT_METHOD(alertWithArgs:(NSDictionary *)args
message:nil
preferredStyle:UIAlertControllerStyleAlert];
switch (type) {
case UIAlertViewStylePlainTextInput:
case UIAlertViewStylePlainTextInput: {
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.secureTextEntry = NO;
textField.text = defaultValue;
}];
break;
case UIAlertViewStyleSecureTextInput:
}
case UIAlertViewStyleSecureTextInput: {
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = RCTUIKitLocalizedString(@"Password");
textField.secureTextEntry = YES;
textField.text = defaultValue;
}];
break;
case UIAlertViewStyleLoginAndPasswordInput:
}
case UIAlertViewStyleLoginAndPasswordInput: {
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = RCTUIKitLocalizedString(@"Login");
textField.text = defaultValue;
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = RCTUIKitLocalizedString(@"Password");
textField.secureTextEntry = YES;
}];
break;
}
case UIAlertViewStyleDefault:
break;
}