forked from cfjedimaster/Cordova-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7fcd93
commit 0866eef
Showing
82 changed files
with
1,406 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
www/build/ | ||
platforms/ | ||
plugins/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Component} from '@angular/core'; | ||
import {Platform, ionicBootstrap} from 'ionic-angular'; | ||
import {StatusBar} from 'ionic-native'; | ||
import {HomePage} from './pages/home/home'; | ||
|
||
|
||
@Component({ | ||
template: '<ion-nav [root]="rootPage"></ion-nav>' | ||
}) | ||
export class MyApp { | ||
rootPage: any = HomePage; | ||
|
||
constructor(platform: Platform) { | ||
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(); | ||
}); | ||
} | ||
} | ||
|
||
ionicBootstrap(MyApp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<ion-header> | ||
<ion-navbar> | ||
<ion-title> | ||
Secure Storage Example | ||
</ion-title> | ||
</ion-navbar> | ||
</ion-header> | ||
|
||
<ion-content padding> | ||
|
||
<ion-list> | ||
|
||
<ion-item> | ||
<ion-label fixed>Username</ion-label> | ||
<ion-input type="text" [(ngModel)]="username"></ion-input> | ||
</ion-item> | ||
|
||
<ion-item> | ||
<ion-label fixed>Password</ion-label> | ||
<ion-input type="password" [(ngModel)]="password"></ion-input> | ||
</ion-item> | ||
|
||
</ion-list> | ||
|
||
<button primary block (click)="login()" *ngIf="readyToLogin">Login</button> | ||
|
||
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.home { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import {Component} from '@angular/core'; | ||
import {NavController,Platform} from 'ionic-angular'; | ||
import {LoginProvider} from '../../providers/login-provider/login-provider'; | ||
import { Dialogs } from 'ionic-native'; | ||
import {MainPage} from '../main-page/main-page'; | ||
import {SecureStorage} from 'ionic-native'; | ||
|
||
@Component({ | ||
templateUrl: 'build/pages/home/home.html', | ||
providers:[LoginProvider] | ||
}) | ||
export class HomePage { | ||
|
||
public username:string; | ||
public password:string; | ||
private loginService:LoginProvider; | ||
public readyToLogin:boolean; | ||
private secureStorage:SecureStorage; | ||
|
||
constructor(public navCtrl: NavController, platform:Platform ) { | ||
console.log('hello world'); | ||
this.loginService = new LoginProvider(); | ||
this.readyToLogin = false; | ||
|
||
platform.ready().then(() => { | ||
|
||
this.secureStorage = new SecureStorage(); | ||
this.secureStorage.create('demoapp').then( | ||
() => { | ||
console.log('Storage is ready!'); | ||
|
||
this.secureStorage.get('loginInfo') | ||
.then( | ||
data => { | ||
console.log('data was '+data); | ||
let {u,p} = JSON.parse(data); | ||
this.username = u; | ||
this.password = p; | ||
this.login(); | ||
}, | ||
error => { | ||
// do nothing - it just means it doesn't exist | ||
} | ||
); | ||
|
||
this.readyToLogin = true; | ||
}, | ||
error => console.log(error) | ||
); | ||
|
||
}); | ||
|
||
} | ||
|
||
login() { | ||
|
||
console.log('login',this.username,this.password); | ||
this.loginService.login(this.username,this.password).subscribe((res) => { | ||
|
||
console.log(res); | ||
|
||
if(res.success) { | ||
|
||
//securely store | ||
this.secureStorage.set('loginInfo', JSON.stringify({u:this.username, p:this.password})) | ||
.then( | ||
data => { | ||
console.log('stored info'); | ||
}, | ||
error => console.log(error) | ||
); | ||
|
||
//thx mike for hack to remove back btn | ||
this.navCtrl.setRoot(MainPage, null, { | ||
animate: true | ||
}); | ||
|
||
} else { | ||
Dialogs.alert('Bad login. Use \'password\' for password.','Bad Login','Ok'); | ||
this.secureStorage.remove('loginInfo'); | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
securestorage_ionicnative/app/pages/main-page/main-page.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- | ||
Generated template for the MainPage page. | ||
See http://ionicframework.com/docs/v2/components/#navigation for more info on | ||
Ionic pages and navigation. | ||
--> | ||
<ion-header> | ||
|
||
<ion-navbar> | ||
<ion-title>Main Page</ion-title> | ||
</ion-navbar> | ||
|
||
</ion-header> | ||
|
||
|
||
<ion-content padding> | ||
|
||
<p> | ||
Nothing to see here. | ||
</p> | ||
|
||
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.main-page { | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
securestorage_ionicnative/app/pages/main-page/main-page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Component } from '@angular/core'; | ||
import { NavController } from 'ionic-angular'; | ||
|
||
/* | ||
Generated class for the MainPagePage page. | ||
See http://ionicframework.com/docs/v2/components/#navigation for more info on | ||
Ionic pages and navigation. | ||
*/ | ||
@Component({ | ||
templateUrl: 'build/pages/main-page/main-page.html', | ||
}) | ||
export class MainPage { | ||
|
||
constructor(private navCtrl: NavController) { | ||
|
||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
securestorage_ionicnative/app/providers/login-provider/login-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Injectable } from '@angular/core'; | ||
import 'rxjs/add/operator/map'; | ||
import {Observable} from 'rxjs'; | ||
//import 'rxjs/Observable/from'; | ||
|
||
@Injectable() | ||
export class LoginProvider { | ||
|
||
constructor() {} | ||
|
||
public login(username:string,password:string) { | ||
let data = {success:1}; | ||
|
||
if(password !== 'password') data.success = 0; | ||
|
||
return Observable.from([data]); | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// http://ionicframework.com/docs/v2/theming/ | ||
|
||
|
||
// App Shared Imports | ||
// -------------------------------------------------- | ||
// These are the imports which make up the design of this app. | ||
// By default each design mode includes these shared imports. | ||
// App Shared Sass variables belong in app.variables.scss. | ||
|
||
@import "../pages/home/home"; | ||
@import "../pages/main-page/main-page.scss"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// http://ionicframework.com/docs/v2/theming/ | ||
|
||
|
||
// App Shared Variables | ||
// -------------------------------------------------- | ||
// Shared Sass variables go in the app.variables.scss file | ||
@import "app.variables"; | ||
|
||
|
||
// App iOS Variables | ||
// -------------------------------------------------- | ||
// iOS only Sass variables can go here | ||
|
||
|
||
// Ionic iOS Sass | ||
// -------------------------------------------------- | ||
// Custom App variables must be declared before importing Ionic. | ||
// Ionic will use its default values when a custom variable isn't provided. | ||
@import "ionic.ios"; | ||
|
||
|
||
// App Shared Sass | ||
// -------------------------------------------------- | ||
// All Sass files that make up this app goes into the app.core.scss file. | ||
// For simpler CSS overrides, custom app CSS must come after Ionic's CSS. | ||
@import "app.core"; | ||
|
||
|
||
// App iOS Only Sass | ||
// -------------------------------------------------- | ||
// CSS that should only apply to the iOS app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// http://ionicframework.com/docs/v2/theming/ | ||
|
||
|
||
// App Shared Variables | ||
// -------------------------------------------------- | ||
// Shared Sass variables go in the app.variables.scss file | ||
@import "app.variables"; | ||
|
||
|
||
// App Material Design Variables | ||
// -------------------------------------------------- | ||
// Material Design only Sass variables can go here | ||
|
||
|
||
// Ionic Material Design Sass | ||
// -------------------------------------------------- | ||
// Custom App variables must be declared before importing Ionic. | ||
// Ionic will use its default values when a custom variable isn't provided. | ||
@import "ionic.md"; | ||
|
||
|
||
// App Shared Sass | ||
// -------------------------------------------------- | ||
// All Sass files that make up this app goes into the app.core.scss file. | ||
// For simpler CSS overrides, custom app CSS must come after Ionic's CSS. | ||
@import "app.core"; | ||
|
||
|
||
// App Material Design Only Sass | ||
// -------------------------------------------------- | ||
// CSS that should only apply to the Material Design app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// http://ionicframework.com/docs/v2/theming/ | ||
|
||
// Ionic Shared Functions | ||
// -------------------------------------------------- | ||
// Makes Ionic Sass functions available to your App | ||
|
||
@import "globals.core"; | ||
|
||
// App Shared Variables | ||
// -------------------------------------------------- | ||
// To customize the look and feel of this app, you can override | ||
// the Sass variables found in Ionic's source scss files. Setting | ||
// variables before Ionic's Sass will use these variables rather than | ||
// Ionic's default Sass variable values. App Shared Sass imports belong | ||
// in the app.core.scss file and not this file. Sass variables specific | ||
// to the mode belong in either the app.ios.scss or app.md.scss files. | ||
|
||
|
||
// App Shared Color Variables | ||
// -------------------------------------------------- | ||
// It's highly recommended to change the default colors | ||
// to match your app's branding. Ionic uses a Sass map of | ||
// colors so you can add, rename and remove colors as needed. | ||
// The "primary" color is the only required color in the map. | ||
// Both iOS and MD colors can be further customized if colors | ||
// are different per mode. | ||
|
||
$colors: ( | ||
primary: #387ef5, | ||
secondary: #32db64, | ||
danger: #f53d3d, | ||
light: #f4f4f4, | ||
dark: #222, | ||
favorite: #69BB7B | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// http://ionicframework.com/docs/v2/theming/ | ||
|
||
|
||
// App Shared Variables | ||
// -------------------------------------------------- | ||
// Shared Sass variables go in the app.variables.scss file | ||
@import "app.variables"; | ||
|
||
|
||
// App Windows Variables | ||
// -------------------------------------------------- | ||
// Windows only Sass variables can go here | ||
|
||
|
||
// Ionic Windows Sass | ||
// -------------------------------------------------- | ||
// Custom App variables must be declared before importing Ionic. | ||
// Ionic will use its default values when a custom variable isn't provided. | ||
@import "ionic.wp"; | ||
|
||
|
||
// App Shared Sass | ||
// -------------------------------------------------- | ||
// All Sass files that make up this app goes into the app.core.scss file. | ||
// For simpler CSS overrides, custom app CSS must come after Ionic's CSS. | ||
@import "app.core"; | ||
|
||
|
||
// App Windows Only Sass | ||
// -------------------------------------------------- | ||
// CSS that should only apply to the Windows app |
Oops, something went wrong.