1- import { Component , EnvironmentInjector , inject } from '@angular/core' ;
1+ import {
2+ ChangeDetectionStrategy ,
3+ Component ,
4+ EnvironmentInjector ,
5+ inject ,
6+ } from '@angular/core' ;
27import {
38 IonIcon ,
49 IonLabel ,
510 IonTabBar ,
611 IonTabButton ,
712 IonTabs ,
13+ Platform ,
814 ToastController ,
915} from '@ionic/angular/standalone' ;
1016import { addIcons } from 'ionicons' ;
11- import {
12- gridOutline ,
13- qrCodeOutline ,
14- settingsOutline
15- } from 'ionicons/icons' ;
17+ import { gridOutline , qrCodeOutline , settingsOutline } from 'ionicons/icons' ;
1618import { ErrorHandlerService } from '../services/error-handler.service' ;
19+ import { BehaviorSubject } from 'rxjs' ;
20+ import { AsyncPipe } from '@angular/common' ;
1721
1822@Component ( {
1923 selector : 'app-tabs' ,
24+ changeDetection : ChangeDetectionStrategy . OnPush ,
2025 template : `
21- <ion-tabs>
22- <ion-tab-bar slot="bottom">
23- <ion-tab-button tab="dashboard" href="/tabs/dashboard">
24- <ion-icon aria-hidden="true" name="grid-outline"></ion-icon>
25- <ion-label>Dashboard</ion-label>
26- </ion-tab-button>
27-
28- <ion-tab-button tab="qr-code" href="/tabs/qr-code">
29- <ion-icon aria-hidden="true" name="qr-code-outline"></ion-icon>
30- <ion-label>QR Code</ion-label>
31- </ion-tab-button>
32-
33- <ion-tab-button tab="settings" href="/tabs/settings">
34- <ion-icon aria-hidden="true" name="settings-outline"></ion-icon>
35- <ion-label>Settings</ion-label>
36- </ion-tab-button>
37- </ion-tab-bar>
38- </ion-tabs>
39- ` ,
40- imports : [ IonTabs , IonTabBar , IonTabButton , IonIcon , IonLabel ] ,
26+ @if ((hideTabs$|async)!==true){
27+ <ion-tabs>
28+ <ion-tab-bar slot="bottom">
29+ <ion-tab-button tab="dashboard" href="/tabs/dashboard">
30+ <ion-icon aria-hidden="true" name="grid-outline"></ion-icon>
31+ <ion-label>Dashboard</ion-label>
32+ </ion-tab-button>
33+
34+ <ion-tab-button tab="qr-code" href="/tabs/qr-code">
35+ <ion-icon aria-hidden="true" name="qr-code-outline"></ion-icon>
36+ <ion-label>QR Code</ion-label>
37+ </ion-tab-button>
38+
39+ <ion-tab-button tab="settings" href="/tabs/settings">
40+ <ion-icon aria-hidden="true" name="settings-outline"></ion-icon>
41+ <ion-label>Settings</ion-label>
42+ </ion-tab-button>
43+ </ion-tab-bar>
44+ </ion-tabs>
45+ }@else {
46+
47+ <ion-tabs> </ion-tabs>
48+ }
49+ ` ,
50+ imports : [ IonTabs , IonTabBar , IonTabButton , IonIcon , IonLabel , AsyncPipe ] ,
4151} )
4252export class TabsPage {
53+ hideTabs$ = new BehaviorSubject ( false ) ;
4354 public environmentInjector = inject ( EnvironmentInjector ) ;
4455 private toastController = inject ( ToastController ) ;
4556 private errorHandler = inject ( ErrorHandlerService ) ;
4657
58+ private readonly platform = inject ( Platform ) ;
59+
4760 constructor ( ) {
4861 addIcons ( { settingsOutline, qrCodeOutline, gridOutline } ) ;
4962 // Initialize the error handler with the toast controller
5063 this . errorHandler . initialize ( this . toastController ) ;
5164 }
52- }
65+
66+ ionViewWillEnter ( ) {
67+ this . platform . resize . subscribe ( ( ) => {
68+ console . log ( 'Размер экрана изменился' ) ;
69+ console . log ( 'Портрет?' , this . platform . isPortrait ( ) ) ;
70+ console . log ( 'Ландшафт?' , this . platform . isLandscape ( ) ) ;
71+ this . hideTabs$ . next ( this . platform . isLandscape ( ) ) ;
72+ } ) ;
73+
74+ this . hideTabs$ . next ( this . platform . isLandscape ( ) ) ;
75+ }
76+ }
0 commit comments