public MainViewModel(IMvxNavigationService navigationService, IAuthService authService, ITopNavigationViewModelService topNavigationViewModelService, IBottomNavigationViewModelService bottomNavigationViewModelService)
        {
            _navigationService = navigationService;
            _authService       = authService;

            _topNavigationViewModelService    = topNavigationViewModelService;
            _bottomNavigationViewModelService = bottomNavigationViewModelService;

            ShowNavigationTopViewModelCommand    = new MvxAsyncCommand(async() => await Task.Run(() => { }));
            ShowAudioPlayerViewModelCommand      = new MvxAsyncCommand(async() => await _navigationService.Navigate <AudioPlayerViewModel>());
            ShowNavigationBottomViewModelCommand = new MvxAsyncCommand(async() => await _navigationService.Navigate <BottomNavigationViewModel>());
            ShowContentViewModelCommand          = new MvxAsyncCommand(async() =>
            {
                var serviceResult = await _authService.Authorize();
                if (!serviceResult.Success)
                {
                    await _topNavigationViewModelService.Close();
                    await _bottomNavigationViewModelService.Close();
                    await _navigationService.Navigate <LoginViewModel>();
                }
                else
                {
                    await _navigationService.Navigate <HomeViewModel>();
                    await _bottomNavigationViewModelService.Show(new BottomNavigationViewModel.PrepareModel()
                    {
                        CheckedItem = Enums.BottomNavigationViewCheckedItemType.Home
                    });
                }
            });
        }
        // Private methods

        private async Task AttemptLogOutAsync()
        {
            _userDialogs.ShowLoading("Logout");
            var serviceResult = await _authService.Logout();

            await _topNavigationViewModelService.Close();

            await _bottomNavigationViewModelService.Close();

            ClearStack.Execute(null);
            await _navigationService.Navigate <LoginViewModel>();

            _userDialogs.HideLoading();
        }
Пример #3
0
 public override void ViewAppearing()
 {
     base.ViewAppearing();
     _topNavigationViewModelService.Close();
     _bottomNavigationViewModelService.Close();
 }