From 2605a2299fe54c2aef111bcebda47e7a652d6c05 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Tue, 15 Mar 2016 04:25:43 -0700 Subject: [PATCH] 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 --- React/Executors/RCTJSCExecutor.m | 3 --- React/Modules/RCTAlertManager.m | 15 +++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/React/Executors/RCTJSCExecutor.m b/React/Executors/RCTJSCExecutor.m index de36fe72c..8c12fdd54 100644 --- a/React/Executors/RCTJSCExecutor.m +++ b/React/Executors/RCTJSCExecutor.m @@ -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; diff --git a/React/Modules/RCTAlertManager.m b/React/Modules/RCTAlertManager.m index 7ab8f49e7..0d6557335 100644 --- a/React/Modules/RCTAlertManager.m +++ b/React/Modules/RCTAlertManager.m @@ -75,6 +75,7 @@ RCT_EXPORT_METHOD(alertWithArgs:(NSDictionary *)args NSString *message = [RCTConvert NSString:args[@"message"]]; UIAlertViewStyle type = [RCTConvert UIAlertViewStyle:args[@"type"]]; NSArray *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; }