import {NgModule, ErrorHandler, ElementRef} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {IonicApp, IonicModule, IonicErrorHandler, Config, NavParams} from 'ionic-angular';
import {MyApp} from './app.component';

import {HomePage} from '../pages/home/home';
import {TabsPage} from '../pages/tabs/tabs';

import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';
import {MineModule} from "../pages/mine/mine.module";
import {ComponentsModule} from "../components/components.module";
import {Keyboard} from "@ionic-native/keyboard";
import {LoginPageModule} from "../pages/login/login.module";
import {HomeModule} from "../pages/home/home.module";
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from "@angular/common/http";
import {InterceptorProvider} from "../core/auth.interceptor";
import {LoginService} from "../pages/login/login.service";
import {HomeService} from "../pages/home/home.service";
import {IonicStorageModule} from "@ionic/storage";
import {FileTransfer, FileTransferObject} from "@ionic-native/file-transfer";
import {CommonService} from "../core/common.service";
import {HTTP} from "@ionic-native/http";
import {AppService} from "./app.service";
import {DataFormatService} from "../core/dataFormat.service";
import {BackButtonService} from "../core/backButton.service";
import {EmitService} from "../core/emit.service";
import {FileOpener} from "@ionic-native/file-opener";
import {File} from "@ionic-native/file";
import {FileService} from "../core/file.service";
import {UntilService} from "../core/until.service";
import {MineService} from "../pages/mine/mine.service";
import {ModalFromRightEnter, ModalFromRightLeave, ModalScaleEnter, ModalScaleLeave} from "./modal-transitions";
import {InAppBrowser} from "@ionic-native/in-app-browser";
// import {PdfViewerComponent, PdfViewerModule} from "ng2-pdf-viewer";
import {TabService} from "../core/tab.service";
import {AppVersion} from "@ionic-native/app-version";
import {LogoutService} from "../secret/logout.service";
import {GetRequestService} from "../secret/getRequest.service";

import {AppUpdateService} from "../core/appUpdate.service";
import {DatePipe} from "@angular/common";
import {RandomWordService} from "../secret/randomWord.service";
import {MobileAccessibility} from "@ionic-native/mobile-accessibility";
import {ScreenOrientation} from "@ionic-native/screen-orientation";
import {GlobalData} from "../core/GlobleData";
import {VideoJsProvider} from '../providers/video-js/video-js';
import {PhotoLibrary} from "@ionic-native/photo-library";
import {DownloadFileProvider} from '../providers/download-file/download-file';
import {NewsPageModule} from "../pages/news/news.module";
import {DealPageModule} from "../pages/deal/deal.module";
import {DealPage} from "../pages/deal/deal";
import {MinePage} from "../pages/mine/mine";
import {NewsPage} from "../pages/news/news";
import {NewsService} from "../pages/news/news.service";
import {DealService} from "../pages/deal/deal.service";
import {Camera} from "@ionic-native/camera";
import {LoginPage} from "../pages/login/login";

@NgModule({
    declarations: [
        MyApp,
        TabsPage,
    ],
    imports: [
        BrowserModule,
        HttpClientModule,
        LoginPageModule,
        MineModule,
        HomeModule,
        NewsPageModule,
        DealPageModule,
        LoginPageModule,
        IonicStorageModule.forRoot(),
        IonicModule.forRoot(MyApp, {
                tabsHideOnSubPages: 'true',
                backButtonText: '',   //返回按钮显示中文
                statusbarPadding: false,
                iconModel: 'ios',   //icon显示图标为IOS版
                mode: 'ios',   //安卓和IOS的样式以IOS样式为准
                modalEnter: 'modal-slide-in',
                modalLeave: 'modal-slide-out',
                swipeBackEnabled: false
            },
        ),
        ComponentsModule,
    ],
    bootstrap: [IonicApp],
    entryComponents:
        [
            MyApp,
            HomePage,
            DealPage,
            MinePage,
            NewsPage,
            TabsPage,
            LoginPage
        ],
    providers:
        [
            StatusBar,
            SplashScreen,
            Keyboard,
            FileOpener,
            InAppBrowser,
            AppVersion,
            File,
            FileTransfer,
            FileTransfer,
            MobileAccessibility,
            ScreenOrientation,
            PhotoLibrary,
            Camera,
            TabService,
            LoginService,
            HomeService,
            CommonService,
            MineService,
            HTTP,
            AppService,
            DataFormatService,
            BackButtonService,
            EmitService,
            FileService,
            UntilService,
            LogoutService,
            GetRequestService,
            AppUpdateService,
            DatePipe,
            RandomWordService,
            GlobalData,
            NewsService,
            DealService,
            {provide: ErrorHandler, useClass: IonicErrorHandler},
            {
                provide: HTTP_INTERCEPTORS, useClass: InterceptorProvider, multi: true,
            },
            VideoJsProvider,
            DownloadFileProvider,
        ],

})

export class AppModule {
    constructor(public config: Config) {
        this.setCustomTransitions();
    }

    private setCustomTransitions() {
        this.config.setTransition('modal-from-right-enter', ModalFromRightEnter);
        this.config.setTransition('modal-from-right-leave', ModalFromRightLeave);
        this.config.setTransition('modal-scale-enter', ModalScaleEnter);
        this.config.setTransition('modal-scale-leave', ModalScaleLeave);
    }
}
