// 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();
        }
        public BottomNavigationViewModel(IMvxNavigationService navigationService)
        {
            _navigationService = navigationService;

            ShowHomeViewModelCommand = new MvxAsyncCommand(async() =>
            {
                ClearStack.Execute(null);
                await _navigationService.Navigate <HomeViewModel>();
            });

            ShowSearchViewModelCommand = new MvxAsyncCommand(async() =>
            {
                ClearStack.Execute(null);
                await _navigationService.Navigate <SearchViewModel>();
            });

            ShowLibraryViewModelCommand = new MvxAsyncCommand(async() =>
            {
                ClearStack.Execute(null);
                await _navigationService.Navigate <LibraryViewModel>();
            });
        }
示例#3
0
        // Private methods

        private async Task AttemptLogInAsync()
        {
            Email.Value    = Email.Value?.Trim();
            Password.Value = Password.Value?.Trim();

            if (_validationHelper.Validate())
            {
                _userDialogs.ShowLoading("Login");

                var serviceResult = await _authService.Login(Email.Value, Password.Value);

                if (serviceResult.Success)
                {
                    ClearStack.Execute(null);
                    await _navigationService.Navigate <HomeViewModel>();

                    await _bottomNavigationViewModelService.Show(new BottomNavigationViewModel.PrepareModel()
                    {
                        CheckedItem = Enums.BottomNavigationViewCheckedItemType.Home
                    });

                    _userDialogs.HideLoading();
                }
                else
                {
                    _userDialogs.HideLoading();

                    await _userDialogs.AlertAsync(new AlertConfig
                    {
                        Title   = "Login failed",
                        Message = serviceResult.Error.Description,
                        OkText  = "OK"
                    });

                    InitValidationCommand.Execute(null);
                }
            }
        }