コード例 #1
0
        async void HandleInitializationComplete(object sender, InitializationCompleteEventArgs e)
        {
            _animationCancellationToken?.Cancel();
            if (e.IsInitializationSuccessful)
            {
#if DEBUG
                await ChangeLabelText(SplashScreenPageConstants.PreviewMode, SplashScreenPageConstants.WarningsMayAppear);

                //Display Text
                await Task.Delay(TimeSpan.FromMilliseconds(500));
#else
                await ChangeLabelText("Let's go!");
#endif
                await NavigateToNextPage();
            }
            else
            {
                await ChangeLabelText(SplashScreenPageConstants.InitializationFailed, $"\n{SplashScreenPageConstants.EnsureInternetConnectionAndLatestVersion}");

                AnalyticsService.Track("Initialization Failed");
            }

            Task NavigateToNextPage()
            {
                return(MainThread.InvokeOnMainThreadAsync(async() =>
                {
                    //Explode & Fade Everything
                    var explodeImageTask = Task.WhenAll(Content.ScaleTo(100, 250, Easing.CubicOut), Content.FadeTo(0, 250, Easing.CubicIn));
                    BackgroundColor = (Color)Application.Current.Resources[nameof(BaseTheme.PageBackgroundColor)];

                    var scope = ContainerService.Container.BeginLifetimeScope();
                    var repositoryPage = scope.Resolve <RepositoryPage>();

                    if (_firstRunService.IsFirstRun)
                    {
                        repositoryPage.Appearing += HandleRepositoryPageAppearing;
                    }

                    await explodeImageTask;

                    Application.Current.MainPage = new BaseNavigationPage(repositoryPage);

                    async void HandleRepositoryPageAppearing(object sender, EventArgs e)
                    {
                        repositoryPage.Appearing -= HandleRepositoryPageAppearing;

                        //Yield the UI thread to allow MainPage to be set
                        await Task.Delay(TimeSpan.FromMilliseconds(500));

                        var onboardingCarouselPage = scope.Resolve <OnboardingCarouselPage>();
                        await repositoryPage.Navigation.PushModalAsync(onboardingCarouselPage);
                    }
                }));
            }
        }
コード例 #2
0
ファイル: SplashScreenPage.cs プロジェクト: kmil0/GitTrends
        async void HandleInitializationComplete(object sender, InitializationCompleteEventArgs e)
        {
            _animationCancellationToken?.Cancel();
            if (e.IsInitializationSuccessful)
            {
#if DEBUG
                await ChangeLabelText("Preview Mode", "Certain license warnings may appear");

                //Display Text
                await Task.Delay(500);
#else
                await ChangeLabelText("Let's go!");
#endif
                await NavigateToNextPage();
            }
            else
            {
                await ChangeLabelText("Initialization Failed", "\nEnsure Internet Connection Is Available and Update GitTrends to the Latest Version");

                AnalyticsService.Track("Initialization Failed");
            }

            Task NavigateToNextPage()
            {
                return(MainThread.InvokeOnMainThreadAsync(async() =>
                {
                    //Explode & Fade Everything
                    var explodeImageTask = Task.WhenAll(Content.ScaleTo(100, 250, Easing.CubicOut), Content.FadeTo(0, 250, Easing.CubicIn));
                    BackgroundColor = (Color)Application.Current.Resources[nameof(BaseTheme.PageBackgroundColor)];

                    using var scope = ContainerService.Container.BeginLifetimeScope();
                    var repositoryPage = scope.Resolve <RepositoryPage>();

                    await explodeImageTask;

                    Application.Current.MainPage = new BaseNavigationPage(repositoryPage);

                    if (FirstRunService.IsFirstRun)
                    {
                        //Yield the UI thread to allow MainPage to be set
                        await Task.Delay(250);

                        var onboardingCarouselPage = scope.Resolve <OnboardingCarouselPage>();
                        await repositoryPage.Navigation.PushModalAsync(onboardingCarouselPage);
                    }
                }));
            }
        }
コード例 #3
0
ファイル: SplashScreenPage.cs プロジェクト: MrClan/GitTrends
        async void HandleInitializationComplete(object sender, InitializationCompleteEventArgs e)
        {
            _animationCancellationToken?.Cancel();
#if DEBUG
            await ChangeLabelText(new FormattedString
            {
                Spans =
                {
                    new Span
                    {
                        FontAttributes = FontAttributes.Bold,
                        Text           = "Preview Mode"
                    },
                    new Span
                    {
                        Text = "\nCertain license warnings may appear"
                    }
                }
            });

            //Display Text
            await Task.Delay(500);

            await NavigateToRepositoryPage();
#else
            if (e.IsInitializationSuccessful)
            {
                await ChangeLabelText("Let's go!");

                await NavigateToRepositoryPage();
            }
            else
            {
                await ChangeLabelText(new FormattedString
                {
                    Spans =
                    {
                        new Span
                        {
                            FontAttributes = FontAttributes.Bold,
                            Text           = "Initialization Failed\n"
                        },
                        new Span
                        {
                            Text = "Ensure Internet Connection Is Available\n + \nUpdate App to the Latest Version"
                        }
                    }
                });

                AnalyticsService.Track("Initialization Failed");
            }
#endif

            Task NavigateToRepositoryPage()
            {
                return(MainThread.InvokeOnMainThreadAsync(async() =>
                {
                    //Explode & Fade Everything
                    var explodeImageTask = Task.WhenAll(Content.ScaleTo(100, 250, Easing.CubicOut), Content.FadeTo(0, 250, Easing.CubicIn));
                    BackgroundColor = (Color)Application.Current.Resources[nameof(BaseTheme.PageBackgroundColor)];

                    await explodeImageTask;

                    using var scope = ContainerService.Container.BeginLifetimeScope();
                    Application.Current.MainPage = new BaseNavigationPage(scope.Resolve <RepositoryPage>());
                }));
            }
        }