mirror of
https://github.com/tomfong/simple-qr.git
synced 2025-06-28 20:19:59 +00:00
feat(ios): show splash screen when app pause
This commit is contained in:
parent
9263e05a2d
commit
01de9b31c9
1 changed files with 27 additions and 0 deletions
|
@ -1,4 +1,7 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
import { App } from '@capacitor/app';
|
||||||
|
import { SplashScreen } from '@capacitor/splash-screen';
|
||||||
|
import { Toast } from '@capacitor/toast';
|
||||||
import { Platform } from '@ionic/angular';
|
import { Platform } from '@ionic/angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { EnvService } from './services/env.service';
|
import { EnvService } from './services/env.service';
|
||||||
|
@ -17,5 +20,29 @@ export class AppComponent {
|
||||||
) {
|
) {
|
||||||
translate.addLangs(this.env.languages);
|
translate.addLangs(this.env.languages);
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
|
if (this.platform.is('ios')) {
|
||||||
|
App.addListener('appStateChange', async ({ isActive }) => {
|
||||||
|
if (env.isDebugging) {
|
||||||
|
this.presentToast(`App state changed. Is active?: ${isActive}`, "short", "bottom");
|
||||||
|
}
|
||||||
|
if (isActive) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
await SplashScreen.hide();
|
||||||
|
}, 300);
|
||||||
|
} else {
|
||||||
|
await SplashScreen.show({
|
||||||
|
autoHide: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async presentToast(msg: string, duration: "short" | "long", pos: "top" | "center" | "bottom") {
|
||||||
|
await Toast.show({
|
||||||
|
text: msg,
|
||||||
|
duration: duration,
|
||||||
|
position: pos
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue