janpio / ionic-epubjs

Ionic 3 app using Epub.js
https://janpio.github.io/ionic-epubjs/
31 stars 20 forks source link

Move Chapter Menu to Sidemenu #48

Open ibby89 opened 6 years ago

ibby89 commented 6 years ago

Hi Jan,

I've been trying and trying with this but cannot get the chapter menu into the sidemenu unfortunately.

I am aware that the TOC page maps the epub chapter data using navParams, and this cannot be done on app.ts as the sidemenu data is mapped using ViewChild(Nav).

If I set the app.html up to list the chapters exactly as the TOC page does, could you let me know what I am doing wrong? It currently looks like this:

<ion-menu [content]="content">
    <ion-header>
      <ion-toolbar>
        <ion-title>Menu</ion-title>
      </ion-toolbar>
    </ion-header>

    <ion-content>
      <ion-list>
        <ion-item class="toc" *ngFor="let chapter of toc" (click)="selectToc(chapter)">
          {{chapter.label}}
        </ion-item>
      </ion-list>
    </ion-content>

  </ion-menu>

  <!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
  <ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

App.ts:

import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';
import { TocPage } from '../pages/toc/toc';
import { BookPage } from '../pages/book/book';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;
  rootPage:any = BookPage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    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();
    });
  }
}
janpio commented 6 years ago

Sorry, my head really is not in this project any more :/ Maybe try asking at http://forum.ionicframework.com/

ibby89 commented 6 years ago

Hi Jan,

Thanks for the reply, I understand. I'll spend some more time on it and see if I can do it myself. I'm also upgrading the code to use ePUBJS v0.3 as well so might as well do it all together if I can.

janpio commented 6 years ago

Be aware that there is already a PR for the 0.3 update that should give you a good starting point.