Beispiel #1
0
        public static async Task <bool> SwitchMainPageAsync(NavigableViewModel viewModel, bool isNavPage = false, params object[] prepareData)
        {
            if (!await viewModel.OnPrepareViewAsync(prepareData))
            {
                throw new Exception($"Failed OnInitializeView, viewModel: {viewModel.GetType().FullName}");
            }

            if (Application.Current.MainPage is MasterDetailPage masterPage)
            {
                if (isNavPage)
                {
                    masterPage.Detail = new MaterialNavigationPage(viewModel.CoupledPage);
                }
                else
                {
                    masterPage.Detail = viewModel.CoupledPage;
                }
            }
            else
            {
                if (isNavPage)
                {
                    Application.Current.MainPage = new MaterialNavigationPage(viewModel.CoupledPage);
                }
                else
                {
                    Application.Current.MainPage = viewModel.CoupledPage;
                }
            }

            return(true);
        }
Beispiel #2
0
        public static async Task <bool> PushNavPageAsync(NavigableViewModel viewModel, params object[] prepareData)
        {
            if (!await viewModel.OnPrepareViewAsync(prepareData))
            {
                throw new Exception($"Failed OnInitializeView, viewModel: {viewModel.GetType().FullName}");
            }

            await Application.Current.MainPage.Navigation.PushAsync(viewModel.CoupledPage, false);

            await Task.Delay(1500);

            return(true);
        }