|  | @@ -8,11 +8,14 @@
 | 
	
		
			
			| 8 | 8 |  
 | 
	
		
			
			| 9 | 9 |  #import "RNNViewController.h"
 | 
	
		
			
			| 10 | 10 |  #import "RCTRootView.h"
 | 
	
		
			
			|  | 11 | +#import "MMDrawerController.h"
 | 
	
		
			
			| 11 | 12 |  
 | 
	
		
			
			| 12 |  | -#define SCREEN              @"screen"
 | 
	
		
			
			| 13 |  | -#define SIDE_MENU           @"sideMenu"
 | 
	
		
			
			| 14 |  | -#define TABS                @"tabs"
 | 
	
		
			
			| 15 |  | -#define SCREEN_KEY          @"key"
 | 
	
		
			
			|  | 13 | +#define SCREEN                  @"screen"
 | 
	
		
			
			|  | 14 | +#define SIDE_MENU               @"sideMenu"
 | 
	
		
			
			|  | 15 | +#define TABS                    @"tabs"
 | 
	
		
			
			|  | 16 | +#define SCREEN_KEY              @"key"
 | 
	
		
			
			|  | 17 | +#define SIDE_MENU_LEFT          @"left"
 | 
	
		
			
			|  | 18 | +#define SIDE_MENU_RIGHT         @"right"
 | 
	
		
			
			| 16 | 19 |  
 | 
	
		
			
			| 17 | 20 |  
 | 
	
		
			
			| 18 | 21 |  @interface RNNViewController ()
 | 
	
	
		
			
			|  | @@ -22,36 +25,134 @@
 | 
	
		
			
			| 22 | 25 |  @implementation RNNViewController
 | 
	
		
			
			| 23 | 26 |  
 | 
	
		
			
			| 24 | 27 |  
 | 
	
		
			
			| 25 |  | -#pragma mark - Static function 
 | 
	
		
			
			|  | 28 | +#pragma mark - Static function
 | 
	
		
			
			| 26 | 29 |  
 | 
	
		
			
			| 27 | 30 |  
 | 
	
		
			
			| 28 | 31 |  + (UIViewController*)controllerWithLayout:(NSDictionary *)layout bridge:(RCTBridge *)bridge {
 | 
	
		
			
			| 29 | 32 |      
 | 
	
		
			
			| 30 | 33 |      UIViewController *controller = nil;
 | 
	
		
			
			| 31 |  | -    
 | 
	
		
			
			| 32 | 34 |      NSDictionary *screen = layout[SCREEN];
 | 
	
		
			
			|  | 35 | +    NSArray *tabs = layout[TABS];
 | 
	
		
			
			|  | 36 | +    NSDictionary *sideMenu = layout[SIDE_MENU];
 | 
	
		
			
			|  | 37 | +    
 | 
	
		
			
			|  | 38 | +    if (sideMenu) {
 | 
	
		
			
			|  | 39 | +        NSDictionary *centerScreenDictionary;
 | 
	
		
			
			|  | 40 | +        if (screen) {
 | 
	
		
			
			|  | 41 | +            centerScreenDictionary = @{SCREEN: screen};
 | 
	
		
			
			|  | 42 | +        }
 | 
	
		
			
			|  | 43 | +        else if (tabs){
 | 
	
		
			
			|  | 44 | +            centerScreenDictionary = @{TABS: layout[TABS]};
 | 
	
		
			
			|  | 45 | +        }
 | 
	
		
			
			|  | 46 | +        else {
 | 
	
		
			
			|  | 47 | +            return nil;
 | 
	
		
			
			|  | 48 | +        }
 | 
	
		
			
			|  | 49 | +        
 | 
	
		
			
			|  | 50 | +        UIViewController *centerViewController = [RNNViewController controllerWithLayout:centerScreenDictionary bridge:bridge];
 | 
	
		
			
			|  | 51 | +        controller = [RNNViewController sideMenuWithLayout:sideMenu centerViewController:centerViewController bridge:bridge];
 | 
	
		
			
			|  | 52 | +        
 | 
	
		
			
			|  | 53 | +        return controller;
 | 
	
		
			
			|  | 54 | +    }
 | 
	
		
			
			|  | 55 | +    
 | 
	
		
			
			|  | 56 | +    if (tabs) {
 | 
	
		
			
			|  | 57 | +        controller = [RNNViewController tabBarWithTabsArray:tabs bridge:bridge];
 | 
	
		
			
			|  | 58 | +        return controller;
 | 
	
		
			
			|  | 59 | +    }
 | 
	
		
			
			|  | 60 | +    
 | 
	
		
			
			| 33 | 61 |      if (screen) {
 | 
	
		
			
			| 34 | 62 |          NSString *screenKey = screen[SCREEN_KEY];
 | 
	
		
			
			| 35 |  | -        if (screenKey)
 | 
	
		
			
			|  | 63 | +        if (screenKey) {
 | 
	
		
			
			|  | 64 | +            controller = [RNNViewController navigationControllerWithScreenKey:screenKey bridge:bridge];
 | 
	
		
			
			|  | 65 | +        }
 | 
	
		
			
			| 36 | 66 |          
 | 
	
		
			
			| 37 |  | -        controller = [RNNViewController navigationControllerWithScreenKey:screenKey bridge:bridge];
 | 
	
		
			
			|  | 67 | +        return controller;
 | 
	
		
			
			| 38 | 68 |      }
 | 
	
		
			
			| 39 | 69 |      
 | 
	
		
			
			| 40 | 70 |      return controller;
 | 
	
		
			
			|  | 71 | +}
 | 
	
		
			
			|  | 72 | +
 | 
	
		
			
			|  | 73 | +
 | 
	
		
			
			|  | 74 | ++(UIViewController*)controllerWithScreenKey:(NSString*)screenKey bridge:(RCTBridge *)bridge {
 | 
	
		
			
			| 41 | 75 |      
 | 
	
		
			
			|  | 76 | +    UIViewController *controller = nil;
 | 
	
		
			
			|  | 77 | +    
 | 
	
		
			
			|  | 78 | +    RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:screenKey initialProperties:nil];
 | 
	
		
			
			|  | 79 | +    if (!reactView) return nil;
 | 
	
		
			
			|  | 80 | +    
 | 
	
		
			
			|  | 81 | +    controller = [UIViewController new];
 | 
	
		
			
			|  | 82 | +    controller.view = reactView;
 | 
	
		
			
			|  | 83 | +    
 | 
	
		
			
			|  | 84 | +    return controller;
 | 
	
		
			
			| 42 | 85 |  }
 | 
	
		
			
			| 43 | 86 |  
 | 
	
		
			
			|  | 87 | +
 | 
	
		
			
			| 44 | 88 |  +(UINavigationController*)navigationControllerWithScreenKey:(NSString*)screenKey bridge:(RCTBridge*)bridge {
 | 
	
		
			
			| 45 | 89 |      
 | 
	
		
			
			| 46 | 90 |      UINavigationController *controller = nil;
 | 
	
		
			
			| 47 |  | -
 | 
	
		
			
			| 48 |  | -    UIViewController *viewController = [UIViewController new];
 | 
	
		
			
			| 49 |  | -    RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:SCREEN_KEY initialProperties:nil];
 | 
	
		
			
			|  | 91 | +    
 | 
	
		
			
			|  | 92 | +    UIViewController *viewController = [RNNViewController controllerWithScreenKey:screenKey bridge:bridge];
 | 
	
		
			
			|  | 93 | +    if (!viewController) return nil;
 | 
	
		
			
			|  | 94 | +    
 | 
	
		
			
			| 50 | 95 |      controller = [[UINavigationController alloc] initWithRootViewController:viewController];
 | 
	
		
			
			|  | 96 | +    [controller.tabBarItem setTitle:@"tab"];
 | 
	
		
			
			| 51 | 97 |      
 | 
	
		
			
			| 52 | 98 |      return controller;
 | 
	
		
			
			| 53 | 99 |  }
 | 
	
		
			
			| 54 | 100 |  
 | 
	
		
			
			| 55 | 101 |  
 | 
	
		
			
			|  | 102 | ++(UIViewController*)sideMenuWithLayout:(NSDictionary*)layout centerViewController:(UIViewController*)centerViewController bridge:(RCTBridge*)bridge {
 | 
	
		
			
			|  | 103 | +    
 | 
	
		
			
			|  | 104 | +    UIViewController *leftViewController, *rightViewController, *sideMenuViewController = nil;
 | 
	
		
			
			|  | 105 | +    
 | 
	
		
			
			|  | 106 | +    NSDictionary *left = layout[SIDE_MENU_LEFT];
 | 
	
		
			
			|  | 107 | +    if (left) {
 | 
	
		
			
			|  | 108 | +        NSString *leftScreenKey = left[SCREEN_KEY];
 | 
	
		
			
			|  | 109 | +        leftViewController = [RNNViewController controllerWithScreenKey:leftScreenKey bridge:bridge];
 | 
	
		
			
			|  | 110 | +    }
 | 
	
		
			
			|  | 111 | +    
 | 
	
		
			
			|  | 112 | +    NSDictionary *right = layout[SIDE_MENU_RIGHT];
 | 
	
		
			
			|  | 113 | +    if (right) {
 | 
	
		
			
			|  | 114 | +        NSString *rightScreenKey = right[SCREEN_KEY];
 | 
	
		
			
			|  | 115 | +        rightViewController = [RNNViewController controllerWithScreenKey:rightScreenKey bridge:bridge];
 | 
	
		
			
			|  | 116 | +    }
 | 
	
		
			
			|  | 117 | +    
 | 
	
		
			
			|  | 118 | +    if (rightViewController || leftViewController) {
 | 
	
		
			
			|  | 119 | +        sideMenuViewController = [[MMDrawerController alloc] initWithCenterViewController:centerViewController leftDrawerViewController:leftViewController rightDrawerViewController:rightViewController];
 | 
	
		
			
			|  | 120 | +        
 | 
	
		
			
			|  | 121 | +        // TODO: CHANGE THIS
 | 
	
		
			
			|  | 122 | +        ((MMDrawerController*)sideMenuViewController).openDrawerGestureModeMask = MMOpenDrawerGestureModeAll;
 | 
	
		
			
			|  | 123 | +        ((MMDrawerController*)sideMenuViewController).closeDrawerGestureModeMask = MMCloseDrawerGestureModeAll;
 | 
	
		
			
			|  | 124 | +    }
 | 
	
		
			
			|  | 125 | +    
 | 
	
		
			
			|  | 126 | +    return sideMenuViewController;
 | 
	
		
			
			|  | 127 | +}
 | 
	
		
			
			|  | 128 | +
 | 
	
		
			
			|  | 129 | ++(UITabBarController*)tabBarWithTabsArray:(NSArray*)tabsArray bridge:(RCTBridge*)bridge {
 | 
	
		
			
			|  | 130 | +    
 | 
	
		
			
			|  | 131 | +    UITabBarController *tabBarController = nil;
 | 
	
		
			
			|  | 132 | +    NSMutableArray *tabsViewControllersArray = [[NSMutableArray alloc] init];
 | 
	
		
			
			|  | 133 | +    
 | 
	
		
			
			|  | 134 | +    for (NSDictionary *tab in tabsArray) {
 | 
	
		
			
			|  | 135 | +        UIViewController *tabViewController = [RNNViewController controllerWithLayout:tab bridge:bridge];
 | 
	
		
			
			|  | 136 | +        if (tabViewController) {
 | 
	
		
			
			|  | 137 | +            [tabsViewControllersArray addObject:tabViewController];
 | 
	
		
			
			|  | 138 | +        }
 | 
	
		
			
			|  | 139 | +    }
 | 
	
		
			
			|  | 140 | +    if ([tabsViewControllersArray count] > 0) {
 | 
	
		
			
			|  | 141 | +        tabBarController = [UITabBarController new];
 | 
	
		
			
			|  | 142 | +        tabBarController.viewControllers = tabsViewControllersArray;
 | 
	
		
			
			|  | 143 | +    }
 | 
	
		
			
			|  | 144 | +    
 | 
	
		
			
			|  | 145 | +    return tabBarController;
 | 
	
		
			
			|  | 146 | +}
 | 
	
		
			
			|  | 147 | +
 | 
	
		
			
			|  | 148 | +-(void)viewWillAppear:(BOOL)animated {
 | 
	
		
			
			|  | 149 | +    [super viewWillAppear:animated];
 | 
	
		
			
			|  | 150 | +    
 | 
	
		
			
			|  | 151 | +}
 | 
	
		
			
			|  | 152 | +
 | 
	
		
			
			|  | 153 | +
 | 
	
		
			
			|  | 154 | +
 | 
	
		
			
			|  | 155 | +
 | 
	
		
			
			|  | 156 | +
 | 
	
		
			
			| 56 | 157 |  @end
 | 
	
		
			
			| 57 | 158 |  
 |