diff --git a/projects/core/src/lib/app-bar-tab-content/app-bar-tab-content.component.ts b/projects/core/src/lib/app-bar-tab-content/app-bar-tab-content.component.ts index ead9cdcf..8e6fb61f 100644 --- a/projects/core/src/lib/app-bar-tab-content/app-bar-tab-content.component.ts +++ b/projects/core/src/lib/app-bar-tab-content/app-bar-tab-content.component.ts @@ -1,6 +1,8 @@ -import { Component, OnInit, Input, HostBinding } from '@angular/core'; +import { AppBarComponent } from './../app-bar/app-bar.component'; +import { Component, OnInit, Input, HostBinding, Output, EventEmitter, Host } from '@angular/core'; import { NavController } from '@ionic/angular'; import { AppBarTitleLayout } from '../interfaces'; +import { TabButtonClickDetail } from '@ionic/core'; @Component({ selector: 'fiv-app-bar-tab-content', @@ -11,20 +13,31 @@ export class AppBarTabContentComponent implements OnInit { @Input() name: string; @Input() icon: string; + @Input() tab: string; @Input() href: string; @Input() active = false; @Input() titleLayout: AppBarTitleLayout = 'hide'; + private selected = false; + @HostBinding('class') get classes(): string { return `label-${this.titleLayout}`; } - constructor(private nav: NavController) { } + @Output() ionTabButtonClick = new EventEmitter(); + + constructor(private nav: NavController, @Host() private appbar: AppBarComponent) { } ngOnInit() { + } onClick() { - this.nav.navigateRoot(this.href); + // this.nav.navigateRoot(this.href); + this.ionTabButtonClick.emit({ + tab: this.tab, + href: this.href, + selected: true + }); } } diff --git a/projects/core/src/lib/app-bar-tab/app-bar-tab.component.ts b/projects/core/src/lib/app-bar-tab/app-bar-tab.component.ts index f899702b..c068208c 100644 --- a/projects/core/src/lib/app-bar-tab/app-bar-tab.component.ts +++ b/projects/core/src/lib/app-bar-tab/app-bar-tab.component.ts @@ -9,6 +9,7 @@ export class AppBarTabComponent implements OnInit { @Input() name: string; @Input() icon: string; + @Input() tab: string; @Input() href: string; constructor() { } diff --git a/projects/core/src/lib/app-bar/app-bar.component.html b/projects/core/src/lib/app-bar/app-bar.component.html index 9227a059..bf82c20c 100644 --- a/projects/core/src/lib/app-bar/app-bar.component.html +++ b/projects/core/src/lib/app-bar/app-bar.component.html @@ -1,14 +1,16 @@
- +
- +
\ No newline at end of file diff --git a/projects/core/src/lib/app-bar/app-bar.component.ts b/projects/core/src/lib/app-bar/app-bar.component.ts index 813b1fcc..7e9527f7 100644 --- a/projects/core/src/lib/app-bar/app-bar.component.ts +++ b/projects/core/src/lib/app-bar/app-bar.component.ts @@ -12,6 +12,8 @@ import { import { AppBarTabComponent } from '../app-bar-tab/app-bar-tab.component'; import { Router } from '@angular/router'; import { AppBarTitleLayout, AppBarFabPosition } from '../interfaces'; +import { IonTabs } from '@ionic/angular'; +import { TabButtonClickDetail } from '@ionic/core'; @Component({ selector: 'fiv-app-bar', @@ -31,10 +33,11 @@ export class AppBarComponent implements OnInit, AfterViewInit, AfterContentInit @ViewChild('fab') fab: LoadingFabComponent; @Input() icon = 'md-add'; + @Input() tabs: IonTabs; @Input() titleLayout: AppBarTitleLayout = 'hide'; @Output() fivFabClick = new EventEmitter(); - @ContentChildren(AppBarTabComponent) tabs: QueryList; + @ContentChildren(AppBarTabComponent) tabComponents: QueryList; @Input() set position(position: AppBarFabPosition) { @@ -118,14 +121,14 @@ export class AppBarComponent implements OnInit, AfterViewInit, AfterContentInit private prepareTabs(position: AppBarFabPosition) { if (position === 'center') { - this.tabsLeft = this.tabs.toArray().slice(0, 2); - this.tabsRight = this.tabs.toArray().slice(2, 4); + this.tabsLeft = this.tabComponents.toArray().slice(0, 2); + this.tabsRight = this.tabComponents.toArray().slice(2, 4); } else if (position === 'right') { - this.tabsLeft = this.tabs.toArray(); + this.tabsLeft = this.tabComponents.toArray(); this.tabsRight = []; } else if (position === 'left') { this.tabsLeft = []; - this.tabsRight = this.tabs.toArray(); + this.tabsRight = this.tabComponents.toArray(); } } @@ -145,4 +148,8 @@ export class AppBarComponent implements OnInit, AfterViewInit, AfterContentInit fabClick() { this.fivFabClick.emit(this); } + + ionTabButtonClick(event: TabButtonClickDetail) { + this.tabs.onTabButtonClick(event); + } } diff --git a/src/app/pages/app-bar/app-bar.module.ts b/src/app/pages/app-bar/app-bar.module.ts index 98acc2f6..e69b50d6 100644 --- a/src/app/pages/app-bar/app-bar.module.ts +++ b/src/app/pages/app-bar/app-bar.module.ts @@ -2,19 +2,12 @@ import { ComponentsModule } from '@components/components.module'; import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; -import { Routes, RouterModule } from '@angular/router'; import { IonicModule } from '@ionic/angular'; import { AppBarPage } from './app-bar.page'; import { FivethreeCoreModule } from 'core'; - -const routes: Routes = [ - { - path: '', - component: AppBarPage - } -]; +import { TabsPageRoutingModule } from './tabs.router.module'; @NgModule({ imports: [ @@ -22,9 +15,9 @@ const routes: Routes = [ FormsModule, IonicModule, FivethreeCoreModule, - RouterModule.forChild(routes), + TabsPageRoutingModule, ComponentsModule ], declarations: [AppBarPage] }) -export class AppBarPageModule {} +export class AppBarPageModule { } diff --git a/src/app/pages/app-bar/app-bar.page.html b/src/app/pages/app-bar/app-bar.page.html index 7c582265..580ec6ab 100644 --- a/src/app/pages/app-bar/app-bar.page.html +++ b/src/app/pages/app-bar/app-bar.page.html @@ -32,23 +32,25 @@ - - + - + - + - + - + + + - \ No newline at end of file + diff --git a/src/app/pages/app-bar/tabs.router.module.ts b/src/app/pages/app-bar/tabs.router.module.ts new file mode 100644 index 00000000..db00ab36 --- /dev/null +++ b/src/app/pages/app-bar/tabs.router.module.ts @@ -0,0 +1,65 @@ +import { AppBarPage } from './app-bar.page'; +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + + +const routes: Routes = [ + { + path: 'tabs', + component: AppBarPage, + children: [ + { + path: 'tab1', + children: [ + { + path: '', + loadChildren: '../bottom-sheet/bottom-sheet.module#BottomSheetPageModule' + } + ] + }, + { + path: 'tab2', + children: [ + { + path: '', + loadChildren: '../buttons/buttons.module#ButtonsPageModule' + } + ] + }, + { + path: 'tab3', + children: [ + { + path: '', + loadChildren: '../bottom-sheet/bottom-sheet.module#BottomSheetPageModule' + } + ] + }, + { + path: 'tab4', + children: [ + { + path: '', + loadChildren: '../bottom-sheet/bottom-sheet.module#BottomSheetPageModule' + } + ] + }, + { + path: '', + redirectTo: '/app-bar/tabs/tab1', + pathMatch: 'full', + }, + ] + }, + { + path: '', + redirectTo: '/app-bar/tabs/tab1', + pathMatch: 'full' + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class TabsPageRoutingModule { }