Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Actually use the 'defaultValue' property in AlertViewIOS.
Browse files Browse the repository at this point in the history
Summary:The AlertViewIOS component takes in a 'defaultValue' for the text input but never actually sets it, this PR actually sets the value.
Closes facebook#6257

Differential Revision: D3052412

Pulled By: nicklockwood

fb-gh-sync-id: 32285330f17ccf47189dbc8fcab48f3712fee59b
shipit-source-id: 32285330f17ccf47189dbc8fcab48f3712fee59b
  • Loading branch information
Morgan Pretty authored and Facebook Github Bot 1 committed Mar 15, 2016
1 parent 64a09fe commit 2605a22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions React/Executors/RCTJSCExecutor.m
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,6 @@ - (NSData *)loadRAMBundle:(NSData *)script
// 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;

Expand Down
15 changes: 11 additions & 4 deletions React/Modules/RCTAlertManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ - (void)invalidate
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"]];

Expand Down Expand Up @@ -112,7 +113,6 @@ - (void)invalidate
alertView.message = message;

if (type != UIAlertViewStyleDefault) {
NSString *defaultValue = [RCTConvert NSString:args[@"defaultValue"]];
[alertView textFieldAtIndex:0].text = defaultValue;
}

Expand Down Expand Up @@ -168,25 +168,32 @@ - (void)invalidate
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;
}
Expand Down

0 comments on commit 2605a22

Please sign in to comment.