|
@@ -1,5 +1,6 @@
|
|
|
import { Component } from '@angular/core';
|
|
|
-import { NavController } from 'ionic-angular';
|
|
|
+import { NavController, ToastController } from 'ionic-angular';
|
|
|
+import { Storage } from '@ionic/storage';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'page-settings',
|
|
@@ -7,8 +8,45 @@ import { NavController } from 'ionic-angular';
|
|
|
})
|
|
|
export class SettingsPage {
|
|
|
|
|
|
- constructor(public navCtrl: NavController) {
|
|
|
+ keywords: string;
|
|
|
+ privateKey: string;
|
|
|
+ publicKey: string;
|
|
|
|
|
|
+ constructor(
|
|
|
+ public navCtrl: NavController,
|
|
|
+ public toastCtrl: ToastController,
|
|
|
+ private storage: Storage
|
|
|
+ ) {
|
|
|
+ this.loadValuesFromStorage()
|
|
|
}
|
|
|
|
|
|
+ loadValuesFromStorage() {
|
|
|
+ this.storage.get("privateKey")
|
|
|
+ .then(value => {
|
|
|
+ this.privateKey = value;
|
|
|
+ })
|
|
|
+
|
|
|
+ this.storage.get("publicKey")
|
|
|
+ .then(value => {
|
|
|
+ this.publicKey = value;
|
|
|
+ })
|
|
|
+
|
|
|
+ this.storage.get("keywords")
|
|
|
+ .then(value => {
|
|
|
+ this.keywords = value;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ save() {
|
|
|
+ this.storage.set("publicKey", this.publicKey);
|
|
|
+ this.storage.set("privateKey", this.privateKey);
|
|
|
+ this.storage.set("keywords", this.keywords);
|
|
|
+
|
|
|
+ const toast = this.toastCtrl.create({
|
|
|
+ message: 'Successfully saved!',
|
|
|
+ position: 'bottom',
|
|
|
+ duration: 3000
|
|
|
+ });
|
|
|
+ toast.present();
|
|
|
+ }
|
|
|
}
|