src/services/app-header.service.ts
Properties |
|
Methods |
constructor(menuCtrl: MenuController, statusBar: StatusBar, preferences: SharedPreferences, onboardingConfigurationService: OnboardingConfigurationService)
|
|||||||||||||||
Defined in src/services/app-header.service.ts:10
|
|||||||||||||||
Parameters :
|
getDefaultPageConfig |
getDefaultPageConfig()
|
Defined in src/services/app-header.service.ts:37
|
Returns :
{ showHeader: boolean; showBurgerMenu: boolean; showKebabMenu: boolean; kebabMenuOptions: {}; pageTitle: string; actionButtons: {}; }
|
hideHeader |
hideHeader()
|
Defined in src/services/app-header.service.ts:49
|
Returns :
void
|
hideStatusBar |
hideStatusBar()
|
Defined in src/services/app-header.service.ts:102
|
Returns :
void
|
showHeaderWithBackButton | ||||||
showHeaderWithBackButton(iconList?, pageTitle?)
|
||||||
Defined in src/services/app-header.service.ts:57
|
||||||
Parameters :
Returns :
void
|
showHeaderWithHomeButton | ||||||
showHeaderWithHomeButton(iconList?, pageTitle?)
|
||||||
Defined in src/services/app-header.service.ts:67
|
||||||
Parameters :
Returns :
void
|
Async showStatusBar |
showStatusBar()
|
Defined in src/services/app-header.service.ts:81
|
Returns :
any
|
sidebarEvent | ||||||
sidebarEvent(name: any)
|
||||||
Defined in src/services/app-header.service.ts:29
|
||||||
Parameters :
Returns :
void
|
sideMenuItemEvents | ||||
sideMenuItemEvents($event)
|
||||
Defined in src/services/app-header.service.ts:33
|
||||
Parameters :
Returns :
void
|
updatePageConfig | ||||
updatePageConfig(config)
|
||||
Defined in src/services/app-header.service.ts:77
|
||||
Parameters :
Returns :
void
|
Private headerConfig |
Default value : new Subject<any>()
|
Defined in src/services/app-header.service.ts:22
|
headerConfigEmitted$ |
Default value : this.headerConfig.asObservable()
|
Defined in src/services/app-header.service.ts:23
|
Private headerEvent |
Default value : new Subject<any>()
|
Defined in src/services/app-header.service.ts:19
|
headerEventEmitted$ |
Default value : this.headerEvent.asObservable()
|
Defined in src/services/app-header.service.ts:20
|
Private sideMenuItemEvent |
Default value : new Subject<any>()
|
Defined in src/services/app-header.service.ts:26
|
sideMenuItemEventEmitted$ |
Default value : this.sideMenuItemEvent.asObservable()
|
Defined in src/services/app-header.service.ts:27
|
import {Inject, Injectable} from '@angular/core';
import {Subject} from 'rxjs';
import {MenuController} from '@ionic/angular';
import {StatusBar} from '@ionic-native/status-bar/ngx';
import {SharedPreferences} from 'sunbird-sdk';
import {AppThemes, StatusBarTheme,AppMode} from '@app/app/app.constant';
import { OnboardingConfigurationService } from '.';
@Injectable()
export class AppHeaderService {
constructor(private menuCtrl: MenuController,
private statusBar: StatusBar,
@Inject('SHARED_PREFERENCES') private preferences: SharedPreferences,
private onboardingConfigurationService: OnboardingConfigurationService
) {
}
private headerEvent = new Subject<any>();
headerEventEmitted$ = this.headerEvent.asObservable();
private headerConfig = new Subject<any>();
headerConfigEmitted$ = this.headerConfig.asObservable();
private sideMenuItemEvent = new Subject<any>();
sideMenuItemEventEmitted$ = this.sideMenuItemEvent.asObservable();
sidebarEvent(name: any) {
this.headerEvent.next(name);
}
sideMenuItemEvents($event) {
this.sideMenuItemEvent.next($event);
}
getDefaultPageConfig() {
const defaultConfig = {
showHeader: true,
showBurgerMenu: true,
showKebabMenu: false,
kebabMenuOptions: [],
pageTitle: '',
actionButtons: ['search'],
};
return defaultConfig;
}
hideHeader() {
const defaultConfig = this.getDefaultPageConfig();
defaultConfig.showHeader = false;
defaultConfig.showBurgerMenu = false;
this.updatePageConfig(defaultConfig);
this.menuCtrl.enable(false);
}
showHeaderWithBackButton(iconList?, pageTitle?) {
const defaultConfig = this.getDefaultPageConfig();
defaultConfig.showHeader = true;
defaultConfig.showBurgerMenu = false;
defaultConfig.actionButtons = iconList ? iconList : [];
defaultConfig.pageTitle = pageTitle;
this.updatePageConfig(defaultConfig);
this.menuCtrl.enable(false);
}
showHeaderWithHomeButton(iconList?, pageTitle?) {
const defaultConfig = this.getDefaultPageConfig();
defaultConfig.showHeader = true;
defaultConfig.showBurgerMenu = true;
defaultConfig.actionButtons = iconList ? iconList : [];
defaultConfig.pageTitle = pageTitle;
this.updatePageConfig(defaultConfig);
this.menuCtrl.enable(true);
}
updatePageConfig(config) {
this.headerConfig.next(config);
}
async showStatusBar() {
const theme = await this.preferences.getString('current_selected_theme').toPromise();
if (theme === 'JOYFUL') {
document.querySelector('html').setAttribute('data-theme', AppThemes.JOYFUL);
const customTheme = this.onboardingConfigurationService.getAppConfig().theme
if(customTheme.name){
document.querySelector('html').setAttribute('data-color', customTheme.name);
}
document.querySelector('html').setAttribute('device-accessable-theme','accessible' );
const themeColor = getComputedStyle(document.querySelector('html')).getPropertyValue('--app-primary-header');
this.statusBar.backgroundColorByHexString(themeColor);
}
const mode = await this.preferences.getString('data-mode').toPromise();
if(mode===AppMode.DARKMODE){
document.querySelector('html').setAttribute('data-mode',AppMode.DARKMODE);
}else{
document.querySelector('html').setAttribute('data-mode',AppMode.DEFAULT);
}
}
hideStatusBar() {
this.statusBar.backgroundColorByHexString(StatusBarTheme.SET_DEFAULT);
}
}