XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

STHApplication

【MAUI】寄当家——安卓端交易管理系统

公开
关注 0 Fork 0 Star 0
UTF-8
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<Views.FormPage>().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;
    }
}