Repository navigation
Expand file tree
/
Copy pathRCTBrowser.m
More file actions
53 lines (44 loc) · 2.42 KB
/
Copy pathRCTBrowser.m
File metadata and controls
53 lines (44 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#import "RCTBrowser.h"
#import "TOWebViewController.h"
@implementation RCTBrowser
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(presentUrl:(NSString *)url withOptions:(NSDictionary *)options) {
TOWebViewController *webVC = [[TOWebViewController alloc] initWithURLString:url];
[options enumerateKeysAndObjectsUsingBlock:^(NSString* key, id obj, BOOL *stop) {
if ([key isEqualToString:@"showLoadingBar"]) {
webVC.showLoadingBar = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"showUrlWhileLoading"]) {
webVC.showUrlWhileLoading = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"loadingBarTintColor"]) {
webVC.loadingBarTintColor = [RCTConvert UIColor:obj];
} else if ([key isEqualToString:@"navigationButtonsHidden"]) {
webVC.navigationButtonsHidden = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"showActionButton"]) {
webVC.showActionButton = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"showDoneButton"]) {
webVC.showDoneButton = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"doneButtonTitle"]) {
webVC.doneButtonTitle = (NSString*)obj;
} else if ([key isEqualToString:@"showPageTitles"]) {
webVC.showPageTitles = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"disableContextualPopupMenu"]) {
webVC.disableContextualPopupMenu = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"hideWebViewBoundaries"]) {
webVC.hideWebViewBoundaries = ([obj isEqual: @(YES)]);
} else if ([key isEqualToString:@"modalCompletionHandler"]) {
// TODO: turn this into a callback
} else if ([key isEqualToString:@"shouldStartLoadRequestHandler"]) {
// TODO: turn this into a callback
} else if ([key isEqualToString:@"buttonTintColor"]) {
webVC.buttonTintColor = [RCTConvert UIColor:obj];
} else if ([key isEqualToString:@"buttonBevelOpacity"]) {
// TODO: NOT YET IMPLEMENTED
}
}];
UIViewController *rootVC = [[UIApplication sharedApplication] keyWindow].rootViewController;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:webVC];
dispatch_async(dispatch_get_main_queue(), ^{
[rootVC presentViewController:nav animated:YES completion: nil];
});
}
@end