MOBILE-3532 ionic: Apply ios mode on iPadOS

main
Pau Ferrer Ocaña 2020-09-15 15:56:38 +02:00
parent dbae55bff2
commit c69d108c11
1 changed files with 56 additions and 6 deletions

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Component, OnInit, NgZone } from '@angular/core'; import { Component, OnInit, NgZone } from '@angular/core';
import { Platform, IonicApp } from 'ionic-angular'; import { Config, Platform, IonicApp } from 'ionic-angular';
import { Network } from '@ionic-native/network'; import { Network } from '@ionic-native/network';
import { CoreApp, CoreAppProvider } from '@providers/app'; import { CoreApp, CoreAppProvider } from '@providers/app';
import { CoreEventsProvider } from '@providers/events'; import { CoreEventsProvider } from '@providers/events';
@ -28,6 +28,7 @@ import { Keyboard } from '@ionic-native/keyboard';
import { ScreenOrientation } from '@ionic-native/screen-orientation'; import { ScreenOrientation } from '@ionic-native/screen-orientation';
import { CoreLoginSitesPage } from '@core/login/pages/sites/sites'; import { CoreLoginSitesPage } from '@core/login/pages/sites/sites';
import { CoreWindow } from '@singletons/window'; import { CoreWindow } from '@singletons/window';
import { Device } from '@ionic-native/device';
@Component({ @Component({
templateUrl: 'app.html' templateUrl: 'app.html'
@ -40,13 +41,62 @@ export class MoodleMobileApp implements OnInit {
protected lastUrls = {}; protected lastUrls = {};
protected lastInAppUrl: string; protected lastInAppUrl: string;
constructor(private platform: Platform, logger: CoreLoggerProvider, keyboard: Keyboard, private app: IonicApp, constructor(
private eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider, private zone: NgZone, private platform: Platform,
private appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider, logger: CoreLoggerProvider,
private screenOrientation: ScreenOrientation, private urlSchemesProvider: CoreCustomURLSchemesProvider, keyboard: Keyboard,
private utils: CoreUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private network: Network) { config: Config,
device: Device,
private app: IonicApp,
private eventsProvider: CoreEventsProvider,
private loginHelper: CoreLoginHelperProvider,
private zone: NgZone,
private appProvider: CoreAppProvider,
private langProvider: CoreLangProvider,
private sitesProvider: CoreSitesProvider,
private screenOrientation: ScreenOrientation,
private urlSchemesProvider: CoreCustomURLSchemesProvider,
private utils: CoreUtilsProvider,
private urlUtils: CoreUrlUtilsProvider,
private network: Network
) {
this.logger = logger.getInstance('AppComponent'); this.logger = logger.getInstance('AppComponent');
if (this.appProvider.isIOS() && !platform.is('ios')) {
// Solve problem with wrong detected iPadOS.
const platforms = platform.platforms();
const index = platforms.indexOf('core');
if (index > -1) {
platforms.splice(index, 1);
}
platforms.push('mobile');
platforms.push('ios');
platforms.push('ipad');
platforms.push('tablet');
app.setElementClass('app-root-ios', true);
platform.ready().then(() => {
if (device.version) {
const [major, minor]: string[] = device.version.split('.', 2);
app.setElementClass('platform-ios' + major, true);
app.setElementClass('platform-ios' + major + '_' + minor, true);
}
});
app._elementRef.nativeElement.classList.remove('app-root-md');
const iosConfig = config.getModeConfig('ios');
config.set('mode', 'ios');
Object.keys(iosConfig).forEach((key) => {
// Already overriden: pageTransition, do not change.
if (key != 'pageTransition') {
config.set('ios', key, iosConfig[key]);
}
});
}
platform.ready().then(() => { platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available. // Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need. // Here you can do any higher level native things you might need.