settings.ts 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Component } from "@angular/core";
  2. import { NavController, ToastController } from "ionic-angular";
  3. import { Storage } from "@ionic/storage";
  4. @Component({
  5. selector: "page-settings",
  6. templateUrl: "settings.html"
  7. })
  8. export class SettingsPage {
  9. keywords: string;
  10. privateKey: string;
  11. publicKey: string;
  12. constructor(
  13. public navCtrl: NavController,
  14. public toastCtrl: ToastController,
  15. private storage: Storage
  16. ) {
  17. this.loadValuesFromStorage();
  18. }
  19. async loadValuesFromStorage() {
  20. this.privateKey = await this.storage.get("privateKey");
  21. this.publicKey = await this.storage.get("publicKey");
  22. this.keywords = await this.storage.get("keywords");
  23. }
  24. save() {
  25. this.storage.set("publicKey", this.publicKey);
  26. this.storage.set("privateKey", this.privateKey);
  27. this.storage.set("keywords", this.keywords);
  28. const toast = this.toastCtrl.create({
  29. message: "Successfully saved!",
  30. position: "bottom",
  31. duration: 3000
  32. });
  33. toast.present();
  34. }
  35. }