
var authenticationApp = angular.module('authenticationApp', ['ionic','authenticationSvc','ngCordova']);
    
authenticationApp.run(function ($ionicPlatform,$rootScope) {
    $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        var devicePlatform = "";
        try { devicePlatform = device.platform; } catch (err) { console.log(err) }
        if (devicePlatform != "iPhone" && devicePlatform != "iOS") {
            // $scope.deviceLoading = "ios";
            isiOs = false;
        }

        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            cordova.plugins.Keyboard.disableScroll(true);
        }
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            // StatusBar.styleDefault();
            StatusBar.show();
            StatusBar.backgroundColorByHexString("#327EBB");
            StatusBar.styleLightContent();
            //StatusBar.hide();
            StatusBar.overlaysWebView(false);
        }
        //initPushwoosh();
    });

    // $ionicPlatform.registerBackButtonAction(function (event) {
    //       // console.log($state.current.name);
    //        //console.log($ionicViewService.getBackView());
    //     if($ionicViewService.getBackView().stateName=="login"){
    //       navigator.app.exitApp();
    //       //ionic.Platform.exitApp();
    //     }
    //     else {
    //       navigator.app.backHistory();
    //     }
    // }, 100);


});

authenticationApp.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider

        /*/////////////////////// AUTH ///////////////////////////*/
        .state('login', {
            url: '/auth/login',
            templateUrl: 'templates/authentication/login.html',
            controller: 'authenticationCtrl',
            cache: false
        })

        .state('forgetpassword', {
            url: '/auth/forgetpassword',
            templateUrl: 'templates/authentication/forgetpassword.html',
            controller: 'authenticationCtrl',
            cache: false
        })

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/auth/login');
});


