Archived
1
0
This repository has been archived on 2026-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FoxTube/FoxTube/SplashScreen.xaml.cs
T
Michael Gordeev 787a6e9f48 Refactored core
UI navigation framework

Related Work Items: #408, #414, #416
2020-06-15 15:46:38 +03:00

92 lines
2.7 KiB
C#

using FoxTube.Services;
using FoxTube.Utils;
using System;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;
namespace FoxTube
{
/// <summary>
/// Extended splash screen. Does all initialization
/// </summary>
public sealed partial class SplashScreen : Page
{
private readonly Windows.ApplicationModel.Activation.SplashScreen splashScreen;
private readonly string navigationParameter;
public SplashScreen(IActivatedEventArgs args, string parameter = null)
{
InitializeComponent();
splashScreen = args.SplashScreen;
navigationParameter = parameter;
Window.Current.SizeChanged += Current_SizeChanged;
UpdateImagePosition();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
ProgressRingControl.IsActive = true;
Initialize();
}
public async void Initialize()
{
Frame frame = Window.Current.Content as Frame;
frame.RequestedTheme = SettingsService.Theme;
if (frame.RequestedTheme == ElementTheme.Default)
Utils.Utils.UpdateTitleBarTheme(Application.Current.RequestedTheme == ApplicationTheme.Dark);
else
Utils.Utils.UpdateTitleBarTheme(frame.RequestedTheme == ElementTheme.Dark);
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
if (StorageService.PromptReview)
FeedbackInterop.PromptReview();
if (StorageService.PromptFeedback)
FeedbackInterop.PromptFeedback();
#region App init
await UserService.Initialize();
await DownloadsService.Initialize();
await AddonsInterop.UpdateProPurchasedState();
InboxService.PushChangelog();
BackgroundManager.RegisterBackgroundTasks();
#endregion
if (navigationParameter.ToUri() is Uri uri && uri.Segments.Length > 0)
{
if (uri.Segments[0].ToLowerInvariant() == "action")
await BackgroundManager.ProcessBackgroundAction(navigationParameter);
}
frame.Navigate(typeof(MainPage), navigationParameter, new SlideNavigationTransitionInfo { Effect = SlideNavigationTransitionEffect.FromLeft });
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
Window.Current.SizeChanged -= Current_SizeChanged;
}
private void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) =>
UpdateImagePosition();
private void UpdateImagePosition()
{
Canvas.SetLeft(SplashScreenImage, splashScreen.ImageLocation.Left);
Canvas.SetTop(SplashScreenImage, splashScreen.ImageLocation.Top);
SplashScreenImage.Height = splashScreen.ImageLocation.Height;
SplashScreenImage.Width = splashScreen.ImageLocation.Width;
}
}
}