//
//  AppDelegate.swift
//  XCODE_TEMPLATE_PROJECT
//
//  Created by ice on 2020/8/19.
//  Copyright © 2020 vv. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, RCTBridgeDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        if let bridge = RCTBridge.init(delegate: self, launchOptions: launchOptions) {
            let rootView = RCTRootView.init(bridge: bridge, moduleName: "XCODE_TEMPLATE_PROJECT", initialProperties: ["routerName":"Xupd"])
            rootView.backgroundColor = UIColor.white
            
            self.window = UIWindow(frame: UIScreen.main.bounds)
            let rootViewController = UIViewController.init()
            rootViewController.view = rootView
            self.window?.rootViewController = rootViewController
            self.window?.makeKeyAndVisible()
        }
        
        return true
    }
}

extension AppDelegate {
    func sourceURL(for bridge: RCTBridge!) -> URL! {
        #if DEBUG
        return RCTBundleURLProvider.sharedSettings()?.jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
        #else
        return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
        #endif
    }
}

