@@ -14,34 +14,41 @@ import { StatusBar, Splashscreen } from 'ionic-native';
14
14
15
15
import { HomePage } from '../pages/_home/home' ;
16
16
17
+ import { Subject } from 'rxjs' ;
18
+
17
19
@Component ( {
18
20
templateUrl : 'app.html'
19
21
} )
20
22
export class MyApp {
21
23
@ViewChild ( Nav ) nav : Nav ;
22
24
23
25
rootPage : any = HomePage ;
26
+ activePage = new Subject ( ) ;
24
27
25
- pages : Array < { title : string , component : any } > ;
28
+ pages : Array < { title : string , component : any , active : Boolean } > ;
26
29
state : any ;
27
30
28
31
constructor ( public platform : Platform , public global : AppState ) {
29
32
this . initializeApp ( ) ;
30
33
31
34
this . pages = [
32
- { title : 'Home' , component : HomePage } ,
33
- { title : 'Ionic Official Components' , component : IonicOfficialComponentsPage } ,
34
- { title : 'Login' , component : LoginListPage } ,
35
- { title : 'Lists' , component : ListsPage } ,
36
- { title : 'Popup Modal' , component : PopupModalsPage } ,
37
- { title : 'Miscellaneous' , component : MiscellaneousListPage } ,
38
- { title : 'Popup Menu' , component : PopupMenuListPage } ,
39
- { title : 'Profile' , component : ProfileListPage } ,
35
+ { title : 'Home' , component : HomePage , active : true } ,
36
+ { title : 'Ionic Official Components' , component : IonicOfficialComponentsPage , active : false } ,
37
+ { title : 'Login' , component : LoginListPage , active : false } ,
38
+ { title : 'Lists' , component : ListsPage , active : false } ,
39
+ { title : 'Popup Modal' , component : PopupModalsPage , active : false } ,
40
+ { title : 'Miscellaneous' , component : MiscellaneousListPage , active : false } ,
41
+ { title : 'Popup Menu' , component : PopupMenuListPage , active : false } ,
42
+ { title : 'Profile' , component : ProfileListPage , active : false } ,
40
43
// Removed for now as there were breaking changes in slides
41
44
// { title: 'Slides', component: SlidesPage },
42
- { title : 'Theming' , component : ThemingPage } ,
45
+ { title : 'Theming' , component : ThemingPage , active : false } ,
43
46
] ;
44
47
48
+ this . activePage . subscribe ( ( value : any ) => {
49
+ this . pages . map ( x => x . active = false ) ;
50
+ this . pages [ this . pages . findIndex ( x => x . title === value . title ) ] . active = true ;
51
+ } ) ;
45
52
}
46
53
47
54
initializeApp ( ) {
@@ -58,5 +65,6 @@ export class MyApp {
58
65
// Reset the content nav to have just this page
59
66
// we wouldn't want the back button to show in this scenario
60
67
this . nav . setRoot ( page . component ) ;
68
+ this . activePage . next ( page ) ;
61
69
}
62
70
}
0 commit comments