Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{
- return @"Change packager location";
- } handler:^{
- UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"Change packager location"
- message: @"Input packager IP and port"
- preferredStyle:UIAlertControllerStyleAlert];
- [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
- textField.placeholder = @"0.0.0.0";
- textField.clearButtonMode = UITextFieldViewModeWhileEditing;
- textField.borderStyle = UITextBorderStyleRoundedRect;
- }];
- [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
- textField.placeholder = @"8081";
- textField.clearButtonMode = UITextFieldViewModeWhileEditing;
- textField.borderStyle = UITextBorderStyleRoundedRect;
- }];
- [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction *action) {
- NSArray * textfields = alertController.textFields;
- UITextField * ip = textfields[0];
- UITextField * port = textfields[1];
- NSURLComponents *components = [NSURLComponents componentsWithURL:self->_bridge.bundleURL resolvingAgainstBaseURL:YES];
- NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
- formatter.numberStyle = NSNumberFormatterDecimalStyle;
- NSNumber *portNumber = [formatter numberFromString:port.text];
- if (portNumber == nil) portNumber = [NSNumber numberWithInt: 8081];
- components.scheme = @"http";
- components.host = ip.text;
- components.port = portNumber;
- components.path = @"/index.bundle";
- components.query = @"platform=ios&dev=true&hot=true";
- self->_bridge.bundleURL = components.URL;
- [self->_bridge reload];
- }]];
- [RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL];
- }]];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement