diff --git a/README.md b/README.md index c42ccc84..0d118dc0 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ export class AppModule { } ##### AoT -If you want to configure a custom `TranslateLoader` while using [AoT compilation](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html) or [Ionic 2](http://ionic.io/), you must use an exported function instead of an inline function. +If you want to configure a custom `TranslateLoader` while using [AoT compilation](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html) or [Ionic](http://ionic.io/), you must use an exported function instead of an inline function. ```ts export function createTranslateLoader(http: Http) { @@ -295,7 +295,7 @@ To render them, simply use the `innerHTML` attribute with the pipe on any elemen // do something }); ``` - + #### Methods: - `setDefaultLang(lang: string)`: Sets the default language to use as a fallback @@ -372,7 +372,7 @@ Setup the Missing Translation Handler in your module import by adding it to the }) ], providers: [ - + ], bootstrap: [AppComponent] }) diff --git a/examples/ionic2/.editorconfig b/examples/ionic/.editorconfig similarity index 100% rename from examples/ionic2/.editorconfig rename to examples/ionic/.editorconfig diff --git a/examples/ionic2/.gitignore b/examples/ionic/.gitignore similarity index 100% rename from examples/ionic2/.gitignore rename to examples/ionic/.gitignore diff --git a/examples/ionic/config.xml b/examples/ionic/config.xml new file mode 100644 index 00000000..54df88f6 --- /dev/null +++ b/examples/ionic/config.xml @@ -0,0 +1,95 @@ + + + ngx-translate-ionic + An awesome Ionic/Cordova app. + Ionic Framework Team + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ionic/ionic.config.json b/examples/ionic/ionic.config.json new file mode 100644 index 00000000..bf255c8c --- /dev/null +++ b/examples/ionic/ionic.config.json @@ -0,0 +1,5 @@ +{ + "name": "ngx-translate-ionic", + "app_id": "", + "type": "ionic-angular" +} diff --git a/examples/ionic/package.json b/examples/ionic/package.json new file mode 100644 index 00000000..41d1cdae --- /dev/null +++ b/examples/ionic/package.json @@ -0,0 +1,40 @@ +{ + "name": "ngx-translate-ionic", + "author": "Ionic Framework", + "homepage": "http://ionicframework.com/", + "private": true, + "description": "ionic2: An Ionic project", + "scripts": { + "clean": "ionic-app-scripts clean", + "build": "ionic-app-scripts build", + "lint": "ionic-app-scripts lint", + "ionic:build": "ionic-app-scripts build", + "ionic:serve": "ionic-app-scripts serve" + }, + "dependencies": { + "@angular/common": "4.1.2", + "@angular/compiler": "4.1.2", + "@angular/compiler-cli": "4.1.2", + "@angular/core": "4.1.2", + "@angular/forms": "4.1.2", + "@angular/http": "4.1.2", + "@angular/platform-browser": "4.1.2", + "@angular/platform-browser-dynamic": "4.1.2", + "@ionic-native/core": "3.12.1", + "@ionic-native/splash-screen": "3.12.1", + "@ionic-native/status-bar": "3.12.1", + "@ionic/storage": "2.0.1", + "@ngx-translate/core": "^6.0.1", + "@ngx-translate/http-loader": "0.0.3", + "ionic-angular": "3.3.0", + "ionicons": "3.0.0", + "rxjs": "5.1.1", + "sw-toolbox": "3.4.0", + "zone.js": "^0.8.11" + }, + "devDependencies": { + "@ionic/app-scripts": "1.3.7", + "@ionic/cli-plugin-ionic-angular": "1.3.0", + "typescript": "2.3.4" + } +} diff --git a/examples/ionic/resources/android/icon/drawable-hdpi-icon.png b/examples/ionic/resources/android/icon/drawable-hdpi-icon.png new file mode 100644 index 00000000..b5d1ce02 Binary files /dev/null and b/examples/ionic/resources/android/icon/drawable-hdpi-icon.png differ diff --git a/examples/ionic/resources/android/icon/drawable-ldpi-icon.png b/examples/ionic/resources/android/icon/drawable-ldpi-icon.png new file mode 100644 index 00000000..b3575d5f Binary files /dev/null and b/examples/ionic/resources/android/icon/drawable-ldpi-icon.png differ diff --git a/examples/ionic/resources/android/icon/drawable-mdpi-icon.png b/examples/ionic/resources/android/icon/drawable-mdpi-icon.png new file mode 100644 index 00000000..1329b905 Binary files /dev/null and b/examples/ionic/resources/android/icon/drawable-mdpi-icon.png differ diff --git a/examples/ionic/resources/android/icon/drawable-xhdpi-icon.png b/examples/ionic/resources/android/icon/drawable-xhdpi-icon.png new file mode 100644 index 00000000..b963e1c1 Binary files /dev/null and b/examples/ionic/resources/android/icon/drawable-xhdpi-icon.png differ diff --git a/examples/ionic/resources/android/icon/drawable-xxhdpi-icon.png b/examples/ionic/resources/android/icon/drawable-xxhdpi-icon.png new file mode 100644 index 00000000..44a3c49b Binary files /dev/null and b/examples/ionic/resources/android/icon/drawable-xxhdpi-icon.png differ diff --git a/examples/ionic/resources/android/icon/drawable-xxxhdpi-icon.png b/examples/ionic/resources/android/icon/drawable-xxxhdpi-icon.png new file mode 100644 index 00000000..88ebe174 Binary files /dev/null and b/examples/ionic/resources/android/icon/drawable-xxxhdpi-icon.png differ diff --git a/examples/ionic/resources/android/splash/drawable-land-hdpi-screen.png b/examples/ionic/resources/android/splash/drawable-land-hdpi-screen.png new file mode 100644 index 00000000..382549aa Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-land-hdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-land-ldpi-screen.png b/examples/ionic/resources/android/splash/drawable-land-ldpi-screen.png new file mode 100644 index 00000000..dca13a9b Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-land-ldpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-land-mdpi-screen.png b/examples/ionic/resources/android/splash/drawable-land-mdpi-screen.png new file mode 100644 index 00000000..cc813e1f Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-land-mdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-land-xhdpi-screen.png b/examples/ionic/resources/android/splash/drawable-land-xhdpi-screen.png new file mode 100644 index 00000000..78b70d8f Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-land-xhdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-land-xxhdpi-screen.png b/examples/ionic/resources/android/splash/drawable-land-xxhdpi-screen.png new file mode 100644 index 00000000..fca666c8 Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-land-xxhdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-land-xxxhdpi-screen.png b/examples/ionic/resources/android/splash/drawable-land-xxxhdpi-screen.png new file mode 100644 index 00000000..b34cab2e Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-land-xxxhdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-port-hdpi-screen.png b/examples/ionic/resources/android/splash/drawable-port-hdpi-screen.png new file mode 100644 index 00000000..b300e549 Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-port-hdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-port-ldpi-screen.png b/examples/ionic/resources/android/splash/drawable-port-ldpi-screen.png new file mode 100644 index 00000000..78c626ad Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-port-ldpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-port-mdpi-screen.png b/examples/ionic/resources/android/splash/drawable-port-mdpi-screen.png new file mode 100644 index 00000000..75a41562 Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-port-mdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-port-xhdpi-screen.png b/examples/ionic/resources/android/splash/drawable-port-xhdpi-screen.png new file mode 100644 index 00000000..1820aa0c Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-port-xhdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-port-xxhdpi-screen.png b/examples/ionic/resources/android/splash/drawable-port-xxhdpi-screen.png new file mode 100644 index 00000000..8551394e Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-port-xxhdpi-screen.png differ diff --git a/examples/ionic/resources/android/splash/drawable-port-xxxhdpi-screen.png b/examples/ionic/resources/android/splash/drawable-port-xxxhdpi-screen.png new file mode 100644 index 00000000..cefb9f61 Binary files /dev/null and b/examples/ionic/resources/android/splash/drawable-port-xxxhdpi-screen.png differ diff --git a/examples/ionic2/resources/icon.png b/examples/ionic/resources/icon.png similarity index 100% rename from examples/ionic2/resources/icon.png rename to examples/ionic/resources/icon.png diff --git a/examples/ionic/resources/ios/icon/icon-40.png b/examples/ionic/resources/ios/icon/icon-40.png new file mode 100644 index 00000000..ed8a0ec6 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-40.png differ diff --git a/examples/ionic/resources/ios/icon/icon-40@2x.png b/examples/ionic/resources/ios/icon/icon-40@2x.png new file mode 100644 index 00000000..1550dc30 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-40@2x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-40@3x.png b/examples/ionic/resources/ios/icon/icon-40@3x.png new file mode 100644 index 00000000..9f8c8f0f Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-40@3x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-50.png b/examples/ionic/resources/ios/icon/icon-50.png new file mode 100644 index 00000000..30bea444 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-50.png differ diff --git a/examples/ionic/resources/ios/icon/icon-50@2x.png b/examples/ionic/resources/ios/icon/icon-50@2x.png new file mode 100644 index 00000000..0c03bd9c Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-50@2x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-60.png b/examples/ionic/resources/ios/icon/icon-60.png new file mode 100644 index 00000000..5308b2a8 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-60.png differ diff --git a/examples/ionic/resources/ios/icon/icon-60@2x.png b/examples/ionic/resources/ios/icon/icon-60@2x.png new file mode 100644 index 00000000..9f8c8f0f Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-60@2x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-60@3x.png b/examples/ionic/resources/ios/icon/icon-60@3x.png new file mode 100644 index 00000000..a3e68b5d Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-60@3x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-72.png b/examples/ionic/resources/ios/icon/icon-72.png new file mode 100644 index 00000000..c72f9a56 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-72.png differ diff --git a/examples/ionic/resources/ios/icon/icon-72@2x.png b/examples/ionic/resources/ios/icon/icon-72@2x.png new file mode 100644 index 00000000..44a3c49b Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-72@2x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-76.png b/examples/ionic/resources/ios/icon/icon-76.png new file mode 100644 index 00000000..1891cd07 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-76.png differ diff --git a/examples/ionic/resources/ios/icon/icon-76@2x.png b/examples/ionic/resources/ios/icon/icon-76@2x.png new file mode 100644 index 00000000..03020971 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-76@2x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-83.5@2x.png b/examples/ionic/resources/ios/icon/icon-83.5@2x.png new file mode 100644 index 00000000..2b367cbc Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-83.5@2x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-small.png b/examples/ionic/resources/ios/icon/icon-small.png new file mode 100644 index 00000000..22bef5a8 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-small.png differ diff --git a/examples/ionic/resources/ios/icon/icon-small@2x.png b/examples/ionic/resources/ios/icon/icon-small@2x.png new file mode 100644 index 00000000..08cea7f7 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-small@2x.png differ diff --git a/examples/ionic/resources/ios/icon/icon-small@3x.png b/examples/ionic/resources/ios/icon/icon-small@3x.png new file mode 100644 index 00000000..be99f94e Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon-small@3x.png differ diff --git a/examples/ionic/resources/ios/icon/icon.png b/examples/ionic/resources/ios/icon/icon.png new file mode 100644 index 00000000..94d7d9c1 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon.png differ diff --git a/examples/ionic/resources/ios/icon/icon@2x.png b/examples/ionic/resources/ios/icon/icon@2x.png new file mode 100644 index 00000000..e8969643 Binary files /dev/null and b/examples/ionic/resources/ios/icon/icon@2x.png differ diff --git a/examples/ionic/resources/ios/splash/Default-568h@2x~iphone.png b/examples/ionic/resources/ios/splash/Default-568h@2x~iphone.png new file mode 100644 index 00000000..6da69066 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-568h@2x~iphone.png differ diff --git a/examples/ionic/resources/ios/splash/Default-667h.png b/examples/ionic/resources/ios/splash/Default-667h.png new file mode 100644 index 00000000..1f8b84a2 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-667h.png differ diff --git a/examples/ionic/resources/ios/splash/Default-736h.png b/examples/ionic/resources/ios/splash/Default-736h.png new file mode 100644 index 00000000..ed316963 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-736h.png differ diff --git a/examples/ionic/resources/ios/splash/Default-Landscape-736h.png b/examples/ionic/resources/ios/splash/Default-Landscape-736h.png new file mode 100644 index 00000000..583c2e1d Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-Landscape-736h.png differ diff --git a/examples/ionic/resources/ios/splash/Default-Landscape@2x~ipad.png b/examples/ionic/resources/ios/splash/Default-Landscape@2x~ipad.png new file mode 100644 index 00000000..f2413c1e Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-Landscape@2x~ipad.png differ diff --git a/examples/ionic/resources/ios/splash/Default-Landscape@~ipadpro.png b/examples/ionic/resources/ios/splash/Default-Landscape@~ipadpro.png new file mode 100644 index 00000000..64382323 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-Landscape@~ipadpro.png differ diff --git a/examples/ionic/resources/ios/splash/Default-Landscape~ipad.png b/examples/ionic/resources/ios/splash/Default-Landscape~ipad.png new file mode 100644 index 00000000..ca1fa45e Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-Landscape~ipad.png differ diff --git a/examples/ionic/resources/ios/splash/Default-Portrait@2x~ipad.png b/examples/ionic/resources/ios/splash/Default-Portrait@2x~ipad.png new file mode 100644 index 00000000..97f030b8 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-Portrait@2x~ipad.png differ diff --git a/examples/ionic/resources/ios/splash/Default-Portrait@~ipadpro.png b/examples/ionic/resources/ios/splash/Default-Portrait@~ipadpro.png new file mode 100644 index 00000000..a3704197 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-Portrait@~ipadpro.png differ diff --git a/examples/ionic/resources/ios/splash/Default-Portrait~ipad.png b/examples/ionic/resources/ios/splash/Default-Portrait~ipad.png new file mode 100644 index 00000000..af0ae251 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default-Portrait~ipad.png differ diff --git a/examples/ionic/resources/ios/splash/Default@2x~iphone.png b/examples/ionic/resources/ios/splash/Default@2x~iphone.png new file mode 100644 index 00000000..c46ce669 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default@2x~iphone.png differ diff --git a/examples/ionic/resources/ios/splash/Default~iphone.png b/examples/ionic/resources/ios/splash/Default~iphone.png new file mode 100644 index 00000000..3f97acf4 Binary files /dev/null and b/examples/ionic/resources/ios/splash/Default~iphone.png differ diff --git a/examples/ionic/resources/splash.png b/examples/ionic/resources/splash.png new file mode 100644 index 00000000..028da91b Binary files /dev/null and b/examples/ionic/resources/splash.png differ diff --git a/examples/ionic/src/app/app.component.ts b/examples/ionic/src/app/app.component.ts new file mode 100644 index 00000000..7134b6e2 --- /dev/null +++ b/examples/ionic/src/app/app.component.ts @@ -0,0 +1,47 @@ +import { Component } from '@angular/core'; +import { Platform, Config } from 'ionic-angular'; + +import { StatusBar } from '@ionic-native/status-bar'; +import { SplashScreen } from '@ionic-native/splash-screen'; + +import { TranslateService } from '@ngx-translate/core'; + +import { TabsPage } from '../pages/tabs/tabs'; + + +@Component({ + template: `` +}) +export class MyApp { + + rootPage: any = TabsPage; + + constructor(private platform: Platform, private statusBar: StatusBar, private splashScreen: SplashScreen, private translate: TranslateService, private config: Config) { + this.initTranslate(); + } + + ionViewDidLoad() { + this.platform.ready().then(() => { + // Okay, so the platform is ready and our plugins are available. + // Here you can do any higher level native things you might need. + this.statusBar.styleDefault(); + this.splashScreen.hide(); + }); + } + + initTranslate() { + // Set the default language for translation strings, and the current language. + this.translate.setDefaultLang('en'); + + if (this.translate.getBrowserLang() !== undefined) { + this.translate.use(this.translate.getBrowserLang()); + } else { + this.translate.use('en'); // Set your language here + } + + this.translate.get(['BACK_BUTTON_TEXT']).subscribe(values => { + this.config.set('ios', 'backButtonText', values.BACK_BUTTON_TEXT); + }); + } + +} diff --git a/examples/ionic/src/app/app.module.ts b/examples/ionic/src/app/app.module.ts new file mode 100644 index 00000000..8aae0836 --- /dev/null +++ b/examples/ionic/src/app/app.module.ts @@ -0,0 +1,57 @@ +import { NgModule, ErrorHandler } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { HttpModule, Http } from '@angular/http'; +import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; +import { Storage, IonicStorageModule } from '@ionic/storage'; + +import { StatusBar } from '@ionic-native/status-bar'; +import { SplashScreen } from '@ionic-native/splash-screen'; + +import { MyApp } from './app.component'; +import { AboutPage } from '../pages/about/about'; +import { ContactPage } from '../pages/contact/contact'; +import { HomePage } from '../pages/home/home'; +import { TabsPage } from '../pages/tabs/tabs'; + +import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; +import { TranslateHttpLoader } from '@ngx-translate/http-loader'; + +export function createTranslateLoader(http: Http) { + return new TranslateHttpLoader(http, './assets/i18n/', '.json'); +} + +@NgModule({ + declarations: [ + MyApp, + AboutPage, + ContactPage, + HomePage, + TabsPage + ], + imports: [ + BrowserModule, + HttpModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: (createTranslateLoader), + deps: [Http] + } + }), + IonicModule.forRoot(MyApp) + ], + bootstrap: [IonicApp], + entryComponents: [ + MyApp, + AboutPage, + ContactPage, + HomePage, + TabsPage + ], + providers: [ + StatusBar, + SplashScreen, + { provide: ErrorHandler, useClass: IonicErrorHandler } + ] +}) +export class AppModule { } diff --git a/examples/ionic2/src/app/app.scss b/examples/ionic/src/app/app.scss similarity index 100% rename from examples/ionic2/src/app/app.scss rename to examples/ionic/src/app/app.scss diff --git a/examples/ionic2/src/app/main.dev.ts b/examples/ionic/src/app/main.ts similarity index 100% rename from examples/ionic2/src/app/main.dev.ts rename to examples/ionic/src/app/main.ts diff --git a/examples/ionic2/src/assets/i18n/en.json b/examples/ionic/src/assets/i18n/en.json similarity index 100% rename from examples/ionic2/src/assets/i18n/en.json rename to examples/ionic/src/assets/i18n/en.json diff --git a/examples/ionic2/src/assets/i18n/es.json b/examples/ionic/src/assets/i18n/es.json similarity index 100% rename from examples/ionic2/src/assets/i18n/es.json rename to examples/ionic/src/assets/i18n/es.json diff --git a/examples/ionic2/src/assets/i18n/fr.json b/examples/ionic/src/assets/i18n/fr.json similarity index 100% rename from examples/ionic2/src/assets/i18n/fr.json rename to examples/ionic/src/assets/i18n/fr.json diff --git a/examples/ionic2/src/assets/icon/favicon.ico b/examples/ionic/src/assets/icon/favicon.ico similarity index 100% rename from examples/ionic2/src/assets/icon/favicon.ico rename to examples/ionic/src/assets/icon/favicon.ico diff --git a/examples/ionic2/src/index.html b/examples/ionic/src/index.html similarity index 92% rename from examples/ionic2/src/index.html rename to examples/ionic/src/index.html index 97f660ea..4e9ba610 100644 --- a/examples/ionic2/src/index.html +++ b/examples/ionic/src/index.html @@ -2,7 +2,7 @@ - Angular 2 ng2-translate with Ionic 2 + Ionic App @@ -19,7 +19,7 @@ if ('serviceWorker' in navigator) { navigator.serviceWorker.register('service-worker.js') .then(() => console.log('service worker installed')) - .catch(err => console.log('Error', err)); + .catch(err => console.error('Error', err)); } --> diff --git a/examples/ionic2/src/manifest.json b/examples/ionic/src/manifest.json similarity index 99% rename from examples/ionic2/src/manifest.json rename to examples/ionic/src/manifest.json index f6456bbb..66c7532b 100644 --- a/examples/ionic2/src/manifest.json +++ b/examples/ionic/src/manifest.json @@ -10,4 +10,4 @@ }], "background_color": "#4e8ef7", "theme_color": "#4e8ef7" -} \ No newline at end of file +} diff --git a/examples/ionic2/src/pages/about/about.html b/examples/ionic/src/pages/about/about.html similarity index 100% rename from examples/ionic2/src/pages/about/about.html rename to examples/ionic/src/pages/about/about.html diff --git a/examples/ionic/src/pages/about/about.module.ts b/examples/ionic/src/pages/about/about.module.ts new file mode 100644 index 00000000..b108c1fd --- /dev/null +++ b/examples/ionic/src/pages/about/about.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { AboutPage } from './about'; + +import { TranslateModule } from '@ngx-translate/core'; + +@NgModule({ + declarations: [ + AboutPage, + ], + imports: [ + IonicPageModule.forChild(AboutPage), + TranslateModule.forChild() + ], + exports: [ + AboutPage + ] +}) +export class AboutPageModule { } diff --git a/examples/ionic2/src/pages/about/about.scss b/examples/ionic/src/pages/about/about.scss similarity index 100% rename from examples/ionic2/src/pages/about/about.scss rename to examples/ionic/src/pages/about/about.scss diff --git a/examples/ionic2/src/pages/about/about.ts b/examples/ionic/src/pages/about/about.ts similarity index 73% rename from examples/ionic2/src/pages/about/about.ts rename to examples/ionic/src/pages/about/about.ts index 1b4c5ada..ff93bb89 100644 --- a/examples/ionic2/src/pages/about/about.ts +++ b/examples/ionic/src/pages/about/about.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { NavController } from 'ionic-angular'; +import { IonicPage, NavController } from 'ionic-angular'; +@IonicPage() @Component({ selector: 'page-about', templateUrl: 'about.html' diff --git a/examples/ionic2/src/pages/contact/contact.html b/examples/ionic/src/pages/contact/contact.html similarity index 85% rename from examples/ionic2/src/pages/contact/contact.html rename to examples/ionic/src/pages/contact/contact.html index cd1ac787..451b4767 100644 --- a/examples/ionic2/src/pages/contact/contact.html +++ b/examples/ionic/src/pages/contact/contact.html @@ -8,7 +8,7 @@ {{ 'CONTACT.TWITTER_MESSAGE' | translate }} - + @ionicframework diff --git a/examples/ionic/src/pages/contact/contact.module.ts b/examples/ionic/src/pages/contact/contact.module.ts new file mode 100644 index 00000000..3264c2af --- /dev/null +++ b/examples/ionic/src/pages/contact/contact.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { ContactPage } from './contact'; + +import { TranslateModule } from '@ngx-translate/core'; + +@NgModule({ + declarations: [ + ContactPage, + ], + imports: [ + IonicPageModule.forChild(ContactPage), + TranslateModule.forChild() + ], + exports: [ + ContactPage + ] +}) +export class AboutPageModule { } diff --git a/examples/ionic2/src/pages/contact/contact.scss b/examples/ionic/src/pages/contact/contact.scss similarity index 100% rename from examples/ionic2/src/pages/contact/contact.scss rename to examples/ionic/src/pages/contact/contact.scss diff --git a/examples/ionic2/src/pages/contact/contact.ts b/examples/ionic/src/pages/contact/contact.ts similarity index 73% rename from examples/ionic2/src/pages/contact/contact.ts rename to examples/ionic/src/pages/contact/contact.ts index a3447202..747a962c 100644 --- a/examples/ionic2/src/pages/contact/contact.ts +++ b/examples/ionic/src/pages/contact/contact.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { NavController } from 'ionic-angular'; +import { IonicPage, NavController } from 'ionic-angular'; +@IonicPage() @Component({ selector: 'page-contact', templateUrl: 'contact.html' diff --git a/examples/ionic2/src/pages/home/home.html b/examples/ionic/src/pages/home/home.html similarity index 100% rename from examples/ionic2/src/pages/home/home.html rename to examples/ionic/src/pages/home/home.html diff --git a/examples/ionic/src/pages/home/home.module.ts b/examples/ionic/src/pages/home/home.module.ts new file mode 100644 index 00000000..6da08702 --- /dev/null +++ b/examples/ionic/src/pages/home/home.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { HomePage } from './home'; + +import { TranslateModule } from '@ngx-translate/core'; + +@NgModule({ + declarations: [ + HomePage, + ], + imports: [ + IonicPageModule.forChild(HomePage), + TranslateModule.forChild() + ], + exports: [ + HomePage + ] +}) +export class AboutPageModule { } diff --git a/examples/ionic2/src/pages/home/home.scss b/examples/ionic/src/pages/home/home.scss similarity index 100% rename from examples/ionic2/src/pages/home/home.scss rename to examples/ionic/src/pages/home/home.scss diff --git a/examples/ionic2/src/pages/home/home.ts b/examples/ionic/src/pages/home/home.ts similarity index 67% rename from examples/ionic2/src/pages/home/home.ts rename to examples/ionic/src/pages/home/home.ts index 0bebf9ea..02a8559b 100644 --- a/examples/ionic2/src/pages/home/home.ts +++ b/examples/ionic/src/pages/home/home.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { NavController } from 'ionic-angular'; -import { TranslateService } from "ng2-translate"; +import { IonicPage, NavController } from 'ionic-angular'; +import { TranslateService } from '@ngx-translate/core'; +@IonicPage() @Component({ selector: 'page-home', templateUrl: 'home.html' diff --git a/examples/ionic2/src/pages/tabs/tabs.html b/examples/ionic/src/pages/tabs/tabs.html similarity index 100% rename from examples/ionic2/src/pages/tabs/tabs.html rename to examples/ionic/src/pages/tabs/tabs.html diff --git a/examples/ionic/src/pages/tabs/tabs.module.ts b/examples/ionic/src/pages/tabs/tabs.module.ts new file mode 100644 index 00000000..57ceabd3 --- /dev/null +++ b/examples/ionic/src/pages/tabs/tabs.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { TabsPage } from './tabs'; + +import { TranslateModule } from '@ngx-translate/core'; + +@NgModule({ + declarations: [ + TabsPage, + ], + imports: [ + IonicPageModule.forChild(TabsPage), + TranslateModule.forChild() + ], + exports: [ + TabsPage + ] +}) +export class AboutPageModule { } diff --git a/examples/ionic2/src/pages/tabs/tabs.ts b/examples/ionic/src/pages/tabs/tabs.ts similarity index 88% rename from examples/ionic2/src/pages/tabs/tabs.ts rename to examples/ionic/src/pages/tabs/tabs.ts index 64557add..c148a1fd 100644 --- a/examples/ionic2/src/pages/tabs/tabs.ts +++ b/examples/ionic/src/pages/tabs/tabs.ts @@ -1,9 +1,11 @@ import { Component } from '@angular/core'; +import { IonicPage } from 'ionic-angular'; import { HomePage } from '../home/home'; import { AboutPage } from '../about/about'; import { ContactPage } from '../contact/contact'; +@IonicPage() @Component({ templateUrl: 'tabs.html' }) diff --git a/examples/ionic2/src/theme/variables.scss b/examples/ionic/src/theme/variables.scss similarity index 90% rename from examples/ionic2/src/theme/variables.scss rename to examples/ionic/src/theme/variables.scss index 49e7c6bc..fd8e48a2 100644 --- a/examples/ionic2/src/theme/variables.scss +++ b/examples/ionic/src/theme/variables.scss @@ -1,5 +1,7 @@ // Ionic Variables and Theming. For more info, please see: // http://ionicframework.com/docs/v2/theming/ +$font-path: "../assets/fonts"; + @import "ionic.globals"; @@ -10,9 +12,6 @@ // To view all the possible Ionic variables, see: // http://ionicframework.com/docs/v2/theming/overriding-ionic-variables/ -$text-color: #000; -$background-color: #fff; - // Named Color Variables // -------------------------------------------------- @@ -23,7 +22,7 @@ $background-color: #fff; // The "primary" color is the only required color in the map. $colors: ( - primary: #387ef5, + primary: #488aff, secondary: #32db64, danger: #f53d3d, light: #f4f4f4, @@ -67,5 +66,11 @@ $colors: ( // The premium icon font for Ionic. For more info, please see: // http://ionicframework.com/docs/v2/ionicons/ -$ionicons-font-path: "../assets/fonts"; -@import "ionicons"; +@import "ionic.ionicons"; + + +// Fonts +// -------------------------------------------------- + +@import "roboto"; +@import "noto-sans"; diff --git a/examples/ionic2/tsconfig.json b/examples/ionic/tsconfig.json similarity index 100% rename from examples/ionic2/tsconfig.json rename to examples/ionic/tsconfig.json diff --git a/examples/ionic2/tslint.json b/examples/ionic/tslint.json similarity index 100% rename from examples/ionic2/tslint.json rename to examples/ionic/tslint.json diff --git a/examples/ionic2/config.xml b/examples/ionic2/config.xml deleted file mode 100644 index 76a599da..00000000 --- a/examples/ionic2/config.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - ionic2 - An awesome Ionic/Cordova app. - Ionic Framework Team - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/ionic2/hooks/README.md b/examples/ionic2/hooks/README.md deleted file mode 100644 index 62e58b48..00000000 --- a/examples/ionic2/hooks/README.md +++ /dev/null @@ -1,196 +0,0 @@ - -# Cordova Hooks - -Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. Hook scripts could be defined by adding them to the special predefined folder (`/hooks`) or via configuration files (`config.xml` and `plugin.xml`) and run serially in the following order: -* Application hooks from `/hooks`; -* Application hooks from `config.xml`; -* Plugin hooks from `plugins/.../plugin.xml`. - -__Remember__: Make your scripts executable. - -__Note__: `.cordova/hooks` directory is also supported for backward compatibility, but we don't recommend using it as it is deprecated. - -## Supported hook types -The following hook types are supported: - - after_build/ - after_compile/ - after_docs/ - after_emulate/ - after_platform_add/ - after_platform_rm/ - after_platform_ls/ - after_plugin_add/ - after_plugin_ls/ - after_plugin_rm/ - after_plugin_search/ - after_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed - after_prepare/ - after_run/ - after_serve/ - before_build/ - before_compile/ - before_docs/ - before_emulate/ - before_platform_add/ - before_platform_rm/ - before_platform_ls/ - before_plugin_add/ - before_plugin_ls/ - before_plugin_rm/ - before_plugin_search/ - before_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed - before_plugin_uninstall/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being uninstalled - before_prepare/ - before_run/ - before_serve/ - pre_package/ <-- Windows 8 and Windows Phone only. - -## Ways to define hooks -### Via '/hooks' directory -To execute custom action when corresponding hook type is fired, use hook type as a name for a subfolder inside 'hooks' directory and place you script file here, for example: - - # script file will be automatically executed after each build - hooks/after_build/after_build_custom_action.js - - -### Config.xml - -Hooks can be defined in project's `config.xml` using `` elements, for example: - - - - - - - - - - ... - - - - - - - ... - - -### Plugin hooks (plugin.xml) - -As a plugin developer you can define hook scripts using `` elements in a `plugin.xml` like that: - - - - - - - - ... - - -`before_plugin_install`, `after_plugin_install`, `before_plugin_uninstall` plugin hooks will be fired exclusively for the plugin being installed/uninstalled. - -## Script Interface - -### Javascript - -If you are writing hooks in Javascript you should use the following module definition: -```javascript -module.exports = function(context) { - ... -} -``` - -You can make your scipts async using Q: -```javascript -module.exports = function(context) { - var Q = context.requireCordovaModule('q'); - var deferral = new Q.defer(); - - setTimeout(function(){ - console.log('hook.js>> end'); - deferral.resolve(); - }, 1000); - - return deferral.promise; -} -``` - -`context` object contains hook type, executed script full path, hook options, command-line arguments passed to Cordova and top-level "cordova" object: -```json -{ - "hook": "before_plugin_install", - "scriptLocation": "c:\\script\\full\\path\\appBeforePluginInstall.js", - "cmdLine": "The\\exact\\command\\cordova\\run\\with arguments", - "opts": { - "projectRoot":"C:\\path\\to\\the\\project", - "cordova": { - "platforms": ["wp8"], - "plugins": ["com.plugin.withhooks"], - "version": "0.21.7-dev" - }, - "plugin": { - "id": "com.plugin.withhooks", - "pluginInfo": { - ... - }, - "platform": "wp8", - "dir": "C:\\path\\to\\the\\project\\plugins\\com.plugin.withhooks" - } - }, - "cordova": {...} -} - -``` -`context.opts.plugin` object will only be passed to plugin hooks scripts. - -You can also require additional Cordova modules in your script using `context.requireCordovaModule` in the following way: -```javascript -var Q = context.requireCordovaModule('q'); -``` - -__Note__: new module loader script interface is used for the `.js` files defined via `config.xml` or `plugin.xml` only. -For compatibility reasons hook files specified via `/hooks` folders are run via Node child_process spawn, see 'Non-javascript' section below. - -### Non-javascript - -Non-javascript scripts are run via Node child_process spawn from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables: - -* CORDOVA_VERSION - The version of the Cordova-CLI. -* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios). -* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer) -* CORDOVA_HOOK - Path to the hook that is being executed. -* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate) - -If a script returns a non-zero exit code, then the parent cordova command will be aborted. - -## Writing hooks - -We highly recommend writing your hooks using Node.js so that they are -cross-platform. Some good examples are shown here: - -[http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/) - -Also, note that even if you are working on Windows, and in case your hook scripts aren't bat files (which is recommended, if you want your scripts to work in non-Windows operating systems) Cordova CLI will expect a shebang line as the first line for it to know the interpreter it needs to use to launch the script. The shebang line should match the following example: - - #!/usr/bin/env [name_of_interpreter_executable] diff --git a/examples/ionic2/hooks/after_prepare/010_add_platform_class.js b/examples/ionic2/hooks/after_prepare/010_add_platform_class.js deleted file mode 100755 index bda3e415..00000000 --- a/examples/ionic2/hooks/after_prepare/010_add_platform_class.js +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env node - -// Add Platform Class -// v1.0 -// Automatically adds the platform class to the body tag -// after the `prepare` command. By placing the platform CSS classes -// directly in the HTML built for the platform, it speeds up -// rendering the correct layout/style for the specific platform -// instead of waiting for the JS to figure out the correct classes. - -var fs = require('fs'); -var path = require('path'); - -var rootdir = process.argv[2]; - -function addPlatformBodyTag(indexPath, platform) { - // add the platform class to the body tag - try { - var platformClass = 'platform-' + platform; - var cordovaClass = 'platform-cordova platform-webview'; - - var html = fs.readFileSync(indexPath, 'utf8'); - - var bodyTag = findBodyTag(html); - if(!bodyTag) return; // no opening body tag, something's wrong - - if(bodyTag.indexOf(platformClass) > -1) return; // already added - - var newBodyTag = bodyTag; - - var classAttr = findClassAttr(bodyTag); - if(classAttr) { - // body tag has existing class attribute, add the classname - var endingQuote = classAttr.substring(classAttr.length-1); - var newClassAttr = classAttr.substring(0, classAttr.length-1); - newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote; - newBodyTag = bodyTag.replace(classAttr, newClassAttr); - - } else { - // add class attribute to the body tag - newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">'); - } - - html = html.replace(bodyTag, newBodyTag); - - fs.writeFileSync(indexPath, html, 'utf8'); - - process.stdout.write('add to body class: ' + platformClass + '\n'); - } catch(e) { - process.stdout.write(e); - } -} - -function findBodyTag(html) { - // get the body tag - try{ - return html.match(/])(.*?)>/gi)[0]; - }catch(e){} -} - -function findClassAttr(bodyTag) { - // get the body tag's class attribute - try{ - return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0]; - }catch(e){} -} - -if (rootdir) { - - // go through each of the platform directories that have been prepared - var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []); - - for(var x=0; x` -}) -export class MyApp { - - rootPage = TabsPage; - - constructor(platform: Platform, translate: TranslateService) { - platform.ready().then(() => { - // Okay, so the platform is ready and our plugins are available. - // Here you can do any higher level native things you might need. - StatusBar.styleDefault(); - Splashscreen.hide(); - // this language will be used as a fallback when a translation isn't found in the current language - translate.setDefaultLang('en'); - // the lang to use, if the lang isn't available, it will use the current loader to get them - translate.use('en'); - }); - } - -} diff --git a/examples/ionic2/src/app/app.module.ts b/examples/ionic2/src/app/app.module.ts deleted file mode 100644 index 5c40a3eb..00000000 --- a/examples/ionic2/src/app/app.module.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { NgModule } from '@angular/core'; -import { HttpModule, Http } from '@angular/http'; -import { IonicApp, IonicModule } from 'ionic-angular'; -import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate'; - -import { MyApp } from './app.component'; -import { AboutPage } from '../pages/about/about'; -import { ContactPage } from '../pages/contact/contact'; -import { HomePage } from '../pages/home/home'; -import { TabsPage } from '../pages/tabs/tabs'; - -export function createTranslateLoader(http: Http) { - return new TranslateStaticLoader(http, './assets/i18n', '.json'); -} - -@NgModule({ - declarations: [ - MyApp, - AboutPage, - ContactPage, - HomePage, - TabsPage - ], - imports: [ - HttpModule, - TranslateModule.forRoot({ - provide: TranslateLoader, - useFactory: (createTranslateLoader), - deps: [Http] - }), - IonicModule.forRoot(MyApp) - ], - bootstrap: [IonicApp], - entryComponents: [ - MyApp, - AboutPage, - ContactPage, - HomePage, - TabsPage - ], - providers: [] -}) -export class AppModule {} diff --git a/examples/ionic2/src/app/main.prod.ts b/examples/ionic2/src/app/main.prod.ts deleted file mode 100644 index ec61e043..00000000 --- a/examples/ionic2/src/app/main.prod.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { platformBrowser } from '@angular/platform-browser'; -import { enableProdMode } from '@angular/core'; - -import { AppModuleNgFactory } from './app.module.ngfactory'; - -enableProdMode(); -platformBrowser().bootstrapModuleFactory(AppModuleNgFactory); diff --git a/examples/ionic2/src/service-worker.js b/examples/ionic2/src/service-worker.js deleted file mode 100644 index 0928a8fa..00000000 --- a/examples/ionic2/src/service-worker.js +++ /dev/null @@ -1,80 +0,0 @@ -// tick this to make the cache invalidate and update -const CACHE_VERSION = 1; -const CURRENT_CACHES = { - 'read-through': 'read-through-cache-v' + CACHE_VERSION -}; - -self.addEventListener('activate', (event) => { - // Delete all caches that aren't named in CURRENT_CACHES. - // While there is only one cache in this example, the same logic will handle the case where - // there are multiple versioned caches. - const expectedCacheNames = Object.keys(CURRENT_CACHES).map((key) => { - return CURRENT_CACHES[key]; - }); - - event.waitUntil( - caches.keys().then((cacheNames) => { - return Promise.all( - cacheNames.map((cacheName) => { - if (expectedCacheNames.indexOf(cacheName) === -1) { - // If this cache name isn't present in the array of "expected" cache names, then delete it. - console.log('Deleting out of date cache:', cacheName); - return caches.delete(cacheName); - } - }) - ); - }) - ); -}); - -// This sample illustrates an aggressive approach to caching, in which every valid response is -// cached and every request is first checked against the cache. -// This may not be an appropriate approach if your web application makes requests for -// arbitrary URLs as part of its normal operation (e.g. a RSS client or a news aggregator), -// as the cache could end up containing large responses that might not end up ever being accessed. -// Other approaches, like selectively caching based on response headers or only caching -// responses served from a specific domain, might be more appropriate for those use cases. -self.addEventListener('fetch', (event) => { - - event.respondWith( - caches.open(CURRENT_CACHES['read-through']).then((cache) => { - return cache.match(event.request).then((response) => { - if (response) { - // If there is an entry in the cache for event.request, then response will be defined - // and we can just return it. - - return response; - } - - // Otherwise, if there is no entry in the cache for event.request, response will be - // undefined, and we need to fetch() the resource. - console.log(' No response for %s found in cache. ' + - 'About to fetch from network...', event.request.url); - - // We call .clone() on the request since we might use it in the call to cache.put() later on. - // Both fetch() and cache.put() "consume" the request, so we need to make a copy. - // (see https://fetch.spec.whatwg.org/#dom-request-clone) - return fetch(event.request.clone()).then((response) => { - - // Optional: add in extra conditions here, e.g. response.type == 'basic' to only cache - // responses from the same domain. See https://fetch.spec.whatwg.org/#concept-response-type - if (response.status < 400 && response.type === 'basic') { - // We need to call .clone() on the response object to save a copy of it to the cache. - // (https://fetch.spec.whatwg.org/#dom-request-clone) - cache.put(event.request, response.clone()); - } - - // Return the original response object, which will be used to fulfill the resource request. - return response; - }); - }).catch((error) => { - // This catch() will handle exceptions that arise from the match() or fetch() operations. - // Note that a HTTP error response (e.g. 404) will NOT trigger an exception. - // It will return a normal response object that has the appropriate error code set. - console.error(' Read-through caching failed:', error); - - throw error; - }); - }) - ); -}); \ No newline at end of file