namespace JiDangJia; public partial class App : Application { private Window? mainWindow; public App(){InitializeComponent();} protected override Window CreateWindow(IActivationState? activationState) { if(mainWindow is not null)return mainWindow; var window=mainWindow=new Window(new NavigationPage(new Views.LoginPage())); window.Deactivated+=(_,_)=>{ #if COMMUNITY_APP Views.CommunityVideo.SetBackgrounded(true); #else (window.Page as NavigationPage)?.Navigation.NavigationStack.OfType().LastOrDefault()?.PreserveDraft(); #endif Services.ExternalPhotoScope.Background(window); }; #if COMMUNITY_APP window.Activated+=(_,_)=>Views.CommunityVideo.SetBackgrounded(false); #endif window.Stopped+=(_,_)=>{ #if COMMUNITY_APP Views.CommunityVideo.SetBackgrounded(true); #endif Services.BiometricUnlock.Cancel();Services.ExternalPhotoScope.Background(window); if((window.Page as NavigationPage)?.RootPage is MainPage root)root.Suspend(); }; window.Resumed+=async(_,_)=>{ #if COMMUNITY_APP Views.CommunityVideo.SetBackgrounded(false); #endif Services.AppPrivacy.Apply();await Services.ExternalPhotoScope.Resumed(window); if(Services.AuthClient.Current.Locked)return; if((window.Page as NavigationPage)?.RootPage is MainPage root)root.Resume(); }; return window; } }