Overview
AppComponent is the root component of the Jet application. It manages the overall layout with Material Design sidenav, handles theme switching, language selection, viewport responsiveness, and coordinates navigation between different parts of the application.
Selector
Usage
main.ts bootstrap configuration.
Features
- Responsive Layout: Adapts between mobile and desktop viewports
- Theme Management: Supports light, dark, and automatic color schemes
- Internationalization: Multi-language support with RTL/LTR directionality
- Navigation: Integrated sidenav and bottom tab navigation
- Progress Tracking: Shows loading progress during navigation
- PWA Support: Enhanced viewport handling for PWA mode
- Analytics Integration: Tracks application usage and navigation events
Properties
Protected Properties
Currently active navigation menu item path, updated on navigation events
Text directionality signal (‘ltr’ or ‘rtl’) based on selected language
Signal indicating if viewport matches large screen breakpoint (desktop)
Writable signal controlling sidenav open/closed state
Computed signal returning ‘side’ for large viewports or ‘over’ for small viewports
Array of navigation menu items from
NAVIGATION_MENU_ITEMS constantComputed signal determining if safe area padding should be applied
Lifecycle Methods
ngOnInit()
Initializes the component:- Logs analytics start event with app version
- Subscribes to router events for navigation tracking
- Handles navigation errors with alerts
- Controls progress bar visibility during navigation
- Sets up Material icons
- Configures viewport zoom for PWA mode
ngOnDestroy()
Cleanup method that removes the dark color scheme media query event listener.Private Methods
#loadFontPair(fontPairUrl: string)
Dynamically loads custom font pair stylesheet when non-default language is selected.URL to the font pair stylesheet
#setColorScheme(colorScheme: string)
Applies color scheme class to document body.Color scheme value: ‘light’, ‘dark’, or ‘automatic’
#setFontPair(fontPair: string)
Applies font pair class to document body.Font pair identifier
#setIcons()
Configures Material Icon Registry with default font set and custom SVG icons.#setLanguage(language: string)
Sets HTML lang attribute and activates Transloco language.Language code (e.g., ‘en’, ‘ar’)
#setThemeColorMeta(colorScheme: string)
Updates theme-color meta tag based on color scheme.Color scheme value
#setZoom(isPwaMode: boolean)
Adjusts viewport meta tag for PWA mode with custom zoom level.Whether app is running in PWA standalone mode
Template Structure
The component template includes:Dependencies
The component injects these services:BreakpointObserver- Viewport size detectionRouter- Navigation event handlingAlertService- Error notificationsAnalyticsService- Usage trackingLoggerService- Debug loggingProgressBarService- Loading indicatorsSettingsService- Theme and language settingsTranslocoService- InternationalizationMatIconRegistry- Icon configurationDomSanitizer- Safe resource URLsMeta- Meta tag managementRenderer2- DOM manipulation
Effects
The component uses Angular effects to react to setting changes:colorSchemeOption Effect
Watches color scheme changes and updates:- Document body classes
- Theme-color meta tag
languageOption Effect
Watches language changes and updates:- Font pair stylesheet loading
- Font pair body classes
- HTML lang attribute
- Transloco active language
Source
Location:src/app/components/app/app.component.ts