From 39e473e78354174ba7e7b98160ea93e3c40de342 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 7 Sep 2018 11:44:50 +0200 Subject: [PATCH] MOBILE-2567 splitview: Change side when changing language --- .../split-view/core-split-view.html | 2 +- src/components/split-view/split-view.ts | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/split-view/core-split-view.html b/src/components/split-view/core-split-view.html index b71eba4f8..1d2d88bcd 100644 --- a/src/components/split-view/core-split-view.html +++ b/src/components/split-view/core-split-view.html @@ -1,5 +1,5 @@ - + diff --git a/src/components/split-view/split-view.ts b/src/components/split-view/split-view.ts index 8808fa88e..ac9e434f5 100644 --- a/src/components/split-view/split-view.ts +++ b/src/components/split-view/split-view.ts @@ -15,7 +15,8 @@ // Code based on https://github.com/martinpritchardelevate/ionic-split-pane-demo import { Component, ViewChild, Input, ElementRef, OnInit, Optional, OnDestroy } from '@angular/core'; -import { NavController, Nav, ViewController } from 'ionic-angular'; +import { NavController, Nav, ViewController, Platform, Menu } from 'ionic-angular'; +import { TranslateService } from '@ngx-translate/core'; import { CoreFileUploaderProvider } from '@core/fileuploader/providers/fileuploader'; import { Subscription } from 'rxjs'; @@ -45,7 +46,9 @@ import { Subscription } from 'rxjs'; export class CoreSplitViewComponent implements OnInit, OnDestroy { @ViewChild('detailNav') detailNav: Nav; + @ViewChild('menu') menu: Menu; @Input() when?: string | boolean = 'md'; + protected isEnabled = false; protected masterPageName = ''; protected masterPageIndex = 0; @@ -56,16 +59,27 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy { protected originalMasterCanLeave: Function; protected ignoreSplitChanged = false; protected audioCaptureSubscription: Subscription; + protected languageChangedSubscription: Subscription; // Empty placeholder for the 'detail' page. detailPage: any = null; + side: string; - constructor(@Optional() private masterNav: NavController, element: ElementRef, fileUploaderProvider: CoreFileUploaderProvider) { + constructor(@Optional() private masterNav: NavController, element: ElementRef, fileUploaderProvider: CoreFileUploaderProvider, + platform: Platform, translate: TranslateService) { this.element = element.nativeElement; this.audioCaptureSubscription = fileUploaderProvider.onAudioCapture.subscribe((starting) => { this.ignoreSplitChanged = starting; }); + + // Change the side when the language changes. + this.languageChangedSubscription = translate.onLangChange.subscribe((event: any) => { + setTimeout(() => { + this.side = platform.isRTL ? 'right' : 'left'; + this.menu.setElementAttribute('side', this.side); + }); + }); } /** @@ -244,5 +258,6 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy { ngOnDestroy(): void { this.detailsDidEnterSubscription && this.detailsDidEnterSubscription.unsubscribe(); this.audioCaptureSubscription.unsubscribe(); + this.languageChangedSubscription.unsubscribe(); } }