Advertisement
DODMax

Untitled

Oct 21st, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, ViewChild} from '@angular/core';
  2. import {Platform, MenuController, ToastController, Events, Nav} from 'ionic-angular';
  3. import { StatusBar } from '@ionic-native/status-bar';
  4. import { SplashScreen } from '@ionic-native/splash-screen';
  5. import { GoogleAnalytics } from '@ionic-native/google-analytics';
  6. import { Storage } from '@ionic/storage';
  7. import { ImageLoaderConfig } from 'ionic-image-loader';
  8. import { Deeplinks  } from "@ionic-native/deeplinks";
  9.  
  10. // import pages
  11. import {WelcomeIntroPage} from '../pages/welcome/intro/intro-welcome';
  12. import {LoginPage} from '../pages/login/login-page';
  13. import {ExperienceShowPage} from "../pages/experience/show/show-experience";
  14. import {UserProfilePage} from "../pages/user/profile/profile-user";
  15.  
  16.  
  17. @Component({
  18.     templateUrl: 'app.component.html',
  19.     providers : [Deeplinks]
  20. })
  21. export class MyCApp {
  22.  
  23.  
  24.     public rootPage:any;
  25.     public nav:any;
  26.  
  27.     constructor(public platform:Platform,
  28.             public storage: Storage,
  29.             public events: Events,
  30.             public menuCtrl: MenuController,
  31.             public toastCtrl: ToastController,
  32.             private splashScreen: SplashScreen,
  33.             private statusBar: StatusBar,
  34.             private ga: GoogleAnalytics,
  35.             private imageLoaderConfig: ImageLoaderConfig,
  36.             private deeplinks : Deeplinks)
  37.     {
  38.         // show splash screen
  39.         this.splashScreen.show();
  40.  
  41.         //Image loader global config
  42.         //See https://github.com/zyra/ionic-image-loader#global-configuration
  43.         this.imageLoaderConfig.setBackgroundSize('cover');
  44.         this.imageLoaderConfig.setFallbackUrl('assets/icon/no-pic.png');
  45.         this.imageLoaderConfig.setMaximumCacheSize(20 * 1024 * 1024); // set max size to 20MB
  46.         this.imageLoaderConfig.setMaximumCacheAge(30 * 24 * 60 * 60 * 1000); // 30 days
  47.         this.imageLoaderConfig.enableSpinner(true);
  48.         //this.imageLoaderConfig.enableDebugMode();
  49.  
  50.  
  51.         platform.ready().then(() => {
  52.             // Okay, so the platform is ready and our plugins are available.
  53.             // Here you can do any higher level native things you might need.
  54.             this.statusBar.styleDefault();
  55.             //this.statusBar.overlaysWebView(true);
  56.             this.splashScreen.hide();
  57.             console.log('after hide'); //This shows in the console
  58.  
  59.             //Start Google Analytics
  60.             this.ga.startTrackerWithId('UA-XXXXXX-2').then(() => {
  61.                 console.log('Google analytics ready');
  62.             }).catch(e => console.log('Error starting GoogleAnalytics', e));
  63.  
  64.  
  65.             //Check if we need to display the login screen or tutorial
  66.             this.storage.get('welcome_intro').then((welcome_intro) => {
  67.                 if (! welcome_intro) {
  68.                     this.rootPage = WelcomeIntroPage;
  69.                     this.storage.set('welcome_intro', true);
  70.                 } else {
  71.                     this.rootPage = LoginPage;
  72.                     this.ga.trackView('Login page');
  73.                 }
  74.             });
  75.         });
  76.     }
  77.  
  78.     // Deeplinks navigate to the pages
  79.     ngAfterViewInit() {
  80.         this.platform.ready().then(() => {
  81.             // Convenience to route with a given nav
  82.             this.deeplinks.routeWithNavController(this.nav, {
  83.                 '/experience/:experience_id': ExperienceShowPage,
  84.                 '/talent/:user_id': UserProfilePage ,
  85.  
  86.             }).subscribe((match) => {
  87.                 console.log('Successfully routed: '+ JSON.stringify(match));
  88.             }, (nomatch) => {
  89.                 console.log('Unmatched Route: '+ nomatch);
  90.             });
  91.         })
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement