Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to create extended spalsh screen? #1714

Open
Dedecekhribecek opened this issue Nov 3, 2019 · 3 comments
Open

No way to create extended spalsh screen? #1714

Dedecekhribecek opened this issue Nov 3, 2019 · 3 comments
Assignees

Comments

@Dedecekhribecek
Copy link

In old T10 version there was a way to create extended splash screen in app constructor SplashFactory = (e) => new Views.Splash(e); There is solution to override OnLaunched method in standard UWP App. Unfortunate this method is sealed in Template 10.
I did not find any description ow web. Please will you point me out where is some docs describing my problem. Thanks in advance.

@JerryNixon
Copy link
Member

I believe the smartest thing you can do is to wait to set the Window.Content. That being said, extended splash screen hasn't been on my radar. Thanks for the tip. I will look into building a sample here in a bit. If there is something fundamentally missing in this updated Template10, I'll fix it.

@JerryNixon JerryNixon self-assigned this Nov 16, 2019
@JerryNixon
Copy link
Member

JerryNixon commented Nov 19, 2019

This works flawlessly.

public override async Task OnStartAsync(IStartArgs args)
{
    if (args.StartKind == StartKinds.Launch)
    {
        ShowExtendedSplashScreen();
        PreloadData();
        await NavigateToStart();
    }
    else { Debugger.Break(); }

    void ShowExtendedSplashScreen()
    {
        if (args.Arguments is IActivatedEventArgs act)
        {
            Window.Current.Content = new ExtendedSplash(act.SplashScreen);
        }
    }

    void PreloadData()
    {
        // TODO
    }

    async Task NavigateToStart()
    {
        var navigation = Container.Resolve<Services.NavigationService>();
        Window.Current.Content = new ShellPage(navigation.Service.GetXamlFrame());
        await navigation.Service.NavigateAsync(nameof(MainPage));
    }
}

With this ExSplash logic.

public ExtendedSplash(Windows.ApplicationModel.Activation.SplashScreen splashScreen)
{
    InitializeComponent();
    Window.Current.SizeChanged += (s, e) => Resize(splashScreen);
    SplashImage.ImageOpened += (s, e) => Window.Current.Activate();
    Resize(splashScreen);
}

private void Resize(SplashScreen splashScreen)
{
    SplashImage.Height = splashScreen.ImageLocation.Height;
    SplashImage.Width = splashScreen.ImageLocation.Width;
    SplashContainer.SetValue(Canvas.TopProperty, splashScreen.ImageLocation.Top);
    SplashContainer.SetValue(Canvas.LeftProperty, splashScreen.ImageLocation.Left);
}

I'll keep it on the backlog to remove Window.Current.Activate() from the bootstrapper, but I've been testing it locally and this works like a charm. Let me know your experience.

@Dedecekhribecek
Copy link
Author

Thank you for hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants