mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-27 01:19:52 -04:00
FEATURE: Adding settings and user profile
* fixed bug in card closing injected during other work * fixed modal close *
This commit is contained in:
parent
d92b370326
commit
61709105e3
@ -5,6 +5,7 @@ import { Platform, MenuController, Nav } from 'ionic-angular';
|
|||||||
import { StatusBar, Splashscreen } from 'ionic-native';
|
import { StatusBar, Splashscreen } from 'ionic-native';
|
||||||
|
|
||||||
import {SearchPage} from "../pages/search/search";
|
import {SearchPage} from "../pages/search/search";
|
||||||
|
import {SettingsPage} from "../pages/settings/settings";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'app.html'
|
templateUrl: 'app.html'
|
||||||
@ -24,7 +25,8 @@ export class MyApp {
|
|||||||
|
|
||||||
// set our app's pages
|
// set our app's pages
|
||||||
this.pages = [
|
this.pages = [
|
||||||
{ title: 'Dynamic Bible', component: SearchPage }
|
{ title: 'Search', component: SearchPage },
|
||||||
|
{ title: 'Settings', component: SettingsPage }
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
import { NgModule, ErrorHandler } from '@angular/core';
|
import { NgModule, ErrorHandler } from '@angular/core';
|
||||||
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
|
|
||||||
import { MyApp } from './app.component';
|
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
|
||||||
|
import { Storage } from '@ionic/storage';
|
||||||
|
|
||||||
|
import { MyApp } from './app.component';
|
||||||
|
|
||||||
import {SearchPage} from "../pages/search/search";
|
import {SearchPage} from "../pages/search/search";
|
||||||
|
import {SettingsPage} from "../pages/settings/settings";
|
||||||
|
|
||||||
import {ComponentLoader} from "../components/component-loader/component-loader.ts";
|
import {ComponentLoader} from "../components/component-loader/component-loader.ts";
|
||||||
import {Passage} from "../components/passage/passage.ts";
|
import {Passage} from "../components/passage/passage.ts";
|
||||||
import {Strongs} from "../components/strongs/strongs.ts";
|
import {Strongs} from "../components/strongs/strongs.ts";
|
||||||
@ -13,6 +18,7 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts";
|
|||||||
declarations: [
|
declarations: [
|
||||||
MyApp,
|
MyApp,
|
||||||
SearchPage,
|
SearchPage,
|
||||||
|
SettingsPage,
|
||||||
ComponentLoader,
|
ComponentLoader,
|
||||||
Passage,
|
Passage,
|
||||||
Strongs,
|
Strongs,
|
||||||
@ -26,10 +32,11 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts";
|
|||||||
entryComponents: [
|
entryComponents: [
|
||||||
MyApp,
|
MyApp,
|
||||||
SearchPage,
|
SearchPage,
|
||||||
|
SettingsPage,
|
||||||
Passage,
|
Passage,
|
||||||
Strongs,
|
Strongs,
|
||||||
StrongsModal,
|
StrongsModal,
|
||||||
],
|
],
|
||||||
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }]
|
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage]
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule { }
|
@ -7,7 +7,7 @@ export class Passage {
|
|||||||
@Output()
|
@Output()
|
||||||
onStrongs = new EventEmitter<string>();
|
onStrongs = new EventEmitter<string>();
|
||||||
@Output()
|
@Output()
|
||||||
onClose = new EventEmitter<BiblePassageResult>();
|
onClose = new EventEmitter<CardItem>();
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
item: BiblePassageResult;
|
item: BiblePassageResult;
|
||||||
@ -15,11 +15,14 @@ export class Passage {
|
|||||||
@Input()
|
@Input()
|
||||||
dict: string;
|
dict: string;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
cardItem: CardItem;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.onClose.emit(this.item);
|
this.onClose.emit(this.cardItem);
|
||||||
}
|
}
|
||||||
openStrongs(strongs: string) {
|
openStrongs(strongs: string) {
|
||||||
this.onStrongs.emit(this.dict+strongs);
|
this.onStrongs.emit(this.dict+strongs);
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
Strongs: {{item.prefix}}{{item.sn}}
|
Strongs: {{item.prefix}}{{item.sn}}
|
||||||
</ion-title>
|
</ion-title>
|
||||||
<ion-buttons start>
|
<ion-buttons start>
|
||||||
<button ion-button (click)="dismiss()">
|
<button ion-button (click)="dismiss()" large>
|
||||||
<span color="primary" showWhen="ios">Cancel</span>
|
<ion-icon name="md-close"></ion-icon>
|
||||||
<ion-icon name="md-close" showWhen="android,windows"></ion-icon>
|
|
||||||
</button>
|
</button>
|
||||||
</ion-buttons>
|
</ion-buttons>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Component} from "@angular/core";
|
import {Component} from "@angular/core";
|
||||||
import { ModalController, Platform, NavParams, ViewController } from 'ionic-angular';
|
import { Platform, NavParams, ViewController } from 'ionic-angular';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "strongs-modal",
|
selector: "strongs-modal",
|
||||||
|
@ -6,15 +6,18 @@ import {EventEmitter, Component, Input, Output} from "@angular/core";
|
|||||||
})
|
})
|
||||||
export class Strongs {
|
export class Strongs {
|
||||||
@Output()
|
@Output()
|
||||||
onClose = new EventEmitter<StrongsResult>();
|
onClose = new EventEmitter<CardItem>();
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
item: StrongsResult;
|
item: StrongsResult;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
cardItem: CardItem;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.onClose.emit(this.item);
|
this.onClose.emit(this.cardItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,15 @@
|
|||||||
<ion-header>
|
<ion-header>
|
||||||
<ion-navbar>
|
<ion-navbar>
|
||||||
<button menuToggle item-left large>
|
<ion-searchbar (search)="getQuery($event)" (input)="setQuery($event)"></ion-searchbar>
|
||||||
|
<button menuToggle item-left large clear>
|
||||||
<ion-icon name="menu"></ion-icon>
|
<ion-icon name="menu"></ion-icon>
|
||||||
</button>
|
</button>
|
||||||
<ion-searchbar (search)="getQuery($event)" (input)="setQuery($event)"></ion-searchbar>
|
|
||||||
</ion-navbar>
|
</ion-navbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
<ion-content padding class="search-card">
|
<ion-content padding class="search-card">
|
||||||
<ion-card *ngFor="let item of items" (swipe)="removeItem(item)">
|
<ion-card *ngFor="let item of items" (swipe)="removeItem(item)">
|
||||||
<passage *ngIf="isPassage(item.type)" [item]="item.data" [dict]="item.dict" (onStrongs)="getItems($event)" (onClose)="removeItem($event)"></passage>
|
<passage *ngIf="isPassage(item.type)" [cardItem]="item" [item]="item.data" [dict]="item.dict" (onStrongs)="getItems($event)" (onClose)="removeItem($event)"></passage>
|
||||||
<strongs *ngIf="isStrongs(item.type)" [item]="item.data" (onClose)="removeItem($event)"></strongs>
|
<strongs *ngIf="isStrongs(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)"></strongs>
|
||||||
<button ion-button icon-left clear small (click)="removeItem(item)">
|
<button ion-button icon-left clear small (click)="removeItem(item)">
|
||||||
<ion-icon name="close-circle"></ion-icon>
|
<ion-icon name="close-circle"></ion-icon>
|
||||||
<div>Close</div>
|
<div>Close</div>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.search-card .content {
|
.search-card {
|
||||||
p {
|
p {
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
|
@ -6,8 +6,8 @@ import {LoadingController, ModalController } from "ionic-angular";
|
|||||||
import {StrongsService} from "../../strongs-service";
|
import {StrongsService} from "../../strongs-service";
|
||||||
import {Strongs} from "../../components/strongs/strongs";
|
import {Strongs} from "../../components/strongs/strongs";
|
||||||
import {Passage} from "../../components/passage/passage.ts";
|
import {Passage} from "../../components/passage/passage.ts";
|
||||||
import {ComponentLoader} from "../../components/component-loader/component-loader.ts";
|
|
||||||
import {StrongsModal} from "../../components/strongs-modal/strongs-modal.ts";
|
import {StrongsModal} from "../../components/strongs-modal/strongs-modal.ts";
|
||||||
|
import {Storage} from '@ionic/storage';
|
||||||
|
|
||||||
class Item {
|
class Item {
|
||||||
id: number;
|
id: number;
|
||||||
@ -22,15 +22,27 @@ class Item {
|
|||||||
})
|
})
|
||||||
export class SearchPage {
|
export class SearchPage {
|
||||||
searchQuery: string = "";
|
searchQuery: string = "";
|
||||||
items: any[];
|
items: CardItem[];
|
||||||
last: number;
|
last: number;
|
||||||
|
user: User = { strongs_modal: true };
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private strongsService: StrongsService
|
private strongsService: StrongsService
|
||||||
, private bibleService: BibleService
|
, private bibleService: BibleService
|
||||||
, public loadingCtrl: LoadingController
|
, public loadingCtrl: LoadingController
|
||||||
, public modalCtrl: ModalController) {
|
, public modalCtrl: ModalController
|
||||||
|
, public local: Storage) {
|
||||||
this.initializeItems();
|
this.initializeItems();
|
||||||
|
// Check if there is a profile saved in local storage
|
||||||
|
this.local.get('profile').then(profile => {
|
||||||
|
if (profile === null) {
|
||||||
|
this.local.set('profile', JSON.stringify(this.user));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.user = JSON.parse(profile);
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeItems() {
|
initializeItems() {
|
||||||
@ -39,7 +51,7 @@ export class SearchPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
presentStrongsModal(strongs: StrongsResult) {
|
presentStrongsModal(strongs: StrongsResult) {
|
||||||
let modal = this.modalCtrl.create(StrongsModal, { strongsid: strongs});
|
let modal = this.modalCtrl.create(StrongsModal, { strongsid: strongs });
|
||||||
modal.present();
|
modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,15 +103,17 @@ export class SearchPage {
|
|||||||
}
|
}
|
||||||
q = q.substring(1, q.length);
|
q = q.substring(1, q.length);
|
||||||
let result = this.strongsService.getStrongs(parseInt(q), dict);
|
let result = this.strongsService.getStrongs(parseInt(q), dict);
|
||||||
this.presentStrongsModal(result);
|
if (this.user.strongs_modal)
|
||||||
//this.items.unshift({ id: this.last++, data: result, type: Strongs });
|
this.presentStrongsModal(result);
|
||||||
|
else
|
||||||
|
this.items.unshift({ id: this.last++, data: result, type: Strongs, dict: "na" });
|
||||||
} else {
|
} else {
|
||||||
// its a verse reference.
|
// its a verse reference.
|
||||||
if (q.trim() !== "") {
|
if (q.trim() !== "") {
|
||||||
let myref = new Reference(q.trim());
|
let myref = new Reference(q.trim());
|
||||||
let r = this.bibleService.getPassage(myref.Section);
|
let r = this.bibleService.getPassage(myref.Section);
|
||||||
r.ref = myref.toString();
|
r.ref = myref.toString();
|
||||||
this.items.unshift({ id: this.last++, data: r, type: Passage, dict: r.testament == 'new' ? "G":"H" });
|
this.items.unshift({ id: this.last++, data: r, type: Passage, dict: r.testament == 'new' ? "G" : "H" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
DynamicBibleIonic/src/pages/settings/settings.html
Normal file
15
DynamicBibleIonic/src/pages/settings/settings.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<ion-header>
|
||||||
|
<ion-navbar>
|
||||||
|
|
||||||
|
<button menuToggle item-left large>
|
||||||
|
<ion-icon name="menu"></ion-icon>
|
||||||
|
</button>
|
||||||
|
<ion-title>Settings</ion-title>
|
||||||
|
</ion-navbar>
|
||||||
|
</ion-header>
|
||||||
|
<ion-content padding>
|
||||||
|
<ion-item *ngIf="user">
|
||||||
|
<ion-label>Show Strongs as Modal</ion-label>
|
||||||
|
<ion-toggle color="dark" [(ngModel)]="user.strongs_modal" (ionChange)="save()"></ion-toggle>
|
||||||
|
</ion-item>
|
||||||
|
</ion-content>
|
3
DynamicBibleIonic/src/pages/settings/settings.scss
Normal file
3
DynamicBibleIonic/src/pages/settings/settings.scss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
page-settings {
|
||||||
|
|
||||||
|
}
|
33
DynamicBibleIonic/src/pages/settings/settings.ts
Normal file
33
DynamicBibleIonic/src/pages/settings/settings.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/// <reference path="../../types.ts" />
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { NavController } from 'ionic-angular';
|
||||||
|
import { Storage } from '@ionic/storage';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'settings',
|
||||||
|
templateUrl: 'settings.html'
|
||||||
|
})
|
||||||
|
export class SettingsPage {
|
||||||
|
user: User = { strongs_modal: true };
|
||||||
|
constructor(public navCtrl: NavController, public local: Storage) {
|
||||||
|
|
||||||
|
// Check if there is a profile saved in local storage
|
||||||
|
this.local.get('profile').then(profile => {
|
||||||
|
if (profile === null) {
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.user = JSON.parse(profile);
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
save() {
|
||||||
|
this.local.set('profile', JSON.stringify(this.user));
|
||||||
|
}
|
||||||
|
|
||||||
|
ionViewDidLoad() {
|
||||||
|
console.log('Hello SettingsPage Page');
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,10 @@
|
|||||||
|
|
||||||
|
type CardItem = { id: number, data: any, type: any, dict: string}
|
||||||
|
|
||||||
|
type User = {
|
||||||
|
strongs_modal: boolean
|
||||||
|
}
|
||||||
|
|
||||||
type BiblePassage = {
|
type BiblePassage = {
|
||||||
ch: number,
|
ch: number,
|
||||||
vss: BibleVerse[]
|
vss: BibleVerse[]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user