@@ -14,34 +14,42 @@ 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 ( ( selectedPage : any ) => {
49
+ this . pages . map ( page => {
50
+ page . active = page . title === selectedPage . title ;
51
+ } ) ;
52
+ } ) ;
45
53
}
46
54
47
55
initializeApp ( ) {
@@ -58,5 +66,6 @@ export class MyApp {
58
66
// Reset the content nav to have just this page
59
67
// we wouldn't want the back button to show in this scenario
60
68
this . nav . setRoot ( page . component ) ;
69
+ this . activePage . next ( page ) ;
61
70
}
62
71
}
0 commit comments