Ejemplo n.º 1
0
        public LoginViewModel(IMvxNavigationService navigationService, IAuthService authService, IUserDialogs userDialogs, IValidator validator, IBottomNavigationViewModelService bottomNavigationViewModelService, ITopNavigationViewModelService topNavigationViewModelService)
        {
            _navigationService                = navigationService;
            _topNavigationViewModelService    = topNavigationViewModelService;
            _bottomNavigationViewModelService = bottomNavigationViewModelService;

            _authService = authService;
            _userDialogs = userDialogs;

            _validationHelper = new ValidationHelper(validator, this, Errors.Value, (propertyName) => { FocusName.Value = propertyName; });

            ValidateEmailCommand    = new MvxCommand(() => _validationHelper.Validate(() => Email));
            ValidatePasswordCommand = new MvxCommand(() => _validationHelper.Validate(() => Password));

            InitValidationCommand = new MvxCommand(() => {
                _validationHelper.ResetValidation();
            });

            LogInCommand = new MvxCommand(() =>
            {
                if (!IsTaskExecutedValueConverter.Convert(LogInTask.Value))
                {
                    LogInTask.Value = NotifyTaskCompletion.Create(AttemptLogInAsync);
                }
            });

            ShowRegistrationViewModelCommand = new MvxAsyncCommand(async() =>
            {
                await _navigationService.Navigate <RegistrationViewModel>();
            });
        }
        public ChangeArtistViewModel(IMvxNavigationService navigationService, IUserDialogs userDialogs, IValidator validator, IArtistService artistService, IBottomNavigationViewModelService bottomNavigationViewModelService, ITopNavigationViewModelService topNavigationViewModelService)
        {
            _navigationService                = navigationService;
            _topNavigationViewModelService    = topNavigationViewModelService;
            _bottomNavigationViewModelService = bottomNavigationViewModelService;

            _userDialogs = userDialogs;

            _validationHelper = new ValidationHelper(validator, this, Errors.Value, (propertyName) => { FocusName.Value = propertyName; });

            _artistService = artistService;

            ValidateNameCommand = new MvxCommand(() => _validationHelper.Validate(() => Name));

            InitValidationCommand = new MvxCommand(() => {
                _validationHelper.ResetValidation();
            });

            ChangeCommand = new MvxCommand(() =>
            {
                if (!IsTaskExecutedValueConverter.Convert(ChangeTask.Value))
                {
                    ChangeTask.Value = NotifyTaskCompletion.Create(AttemptChangeAsync);
                }
            });
        }
Ejemplo n.º 3
0
        public ChangeAlbumViewModel(IMvxNavigationService navigationService, IUserDialogs userDialogs, IValidator validator, ISongService songService, IGenreService genreService, IArtistService artistService, IAlbumService albumService, IBottomNavigationViewModelService bottomNavigationViewModelService, ITopNavigationViewModelService topNavigationViewModelService)
        {
            _navigationService                = navigationService;
            _topNavigationViewModelService    = topNavigationViewModelService;
            _bottomNavigationViewModelService = bottomNavigationViewModelService;

            _userDialogs = userDialogs;

            _validationHelper = new ValidationHelper(validator, this, Errors.Value, (propertyName) => { FocusName.Value = propertyName; });

            _songService   = songService;
            _genreService  = genreService;
            _artistService = artistService;
            _albumService  = albumService;

            ValidateNameCommand = new MvxCommand(() => _validationHelper.Validate(() => Name));

            ValidateGenresCommand = new MvxCommand(() => _validationHelper.Validate(() => Genres));

            ValidateArtistsCommand = new MvxCommand(() => _validationHelper.Validate(() => Artists));

            ValidateSongsCommand = new MvxCommand(() => _validationHelper.Validate(() => Songs));

            InitValidationCommand = new MvxCommand(() => {
                _validationHelper.ResetValidation();
            });

            ChangeCommand = new MvxCommand(() =>
            {
                if (!IsTaskExecutedValueConverter.Convert(ChangeTask.Value))
                {
                    ChangeTask.Value = NotifyTaskCompletion.Create(AttemptChangeAsync);
                }
            });

            _genresTokenParentObject = new TokenParentHelper(new MvxCommand <TokenViewModel>((_) =>
            {
                Genres.Value?.Remove(_ as TokenViewModel <GenreModel>);
                ValidateGenresCommand.Execute(null);
            }));

            _artistsTokenParentObject = new TokenParentHelper(new MvxCommand <TokenViewModel>((_) =>
            {
                Artists.Value?.Remove(_ as TokenViewModel <ArtistModel>);
                ValidateArtistsCommand.Execute(null);
            }));

            _songsTokenParentObject = new TokenParentHelper(new MvxCommand <TokenViewModel>((_) =>
            {
                Songs.Value?.Remove(_ as TokenViewModel <SongModel>);
                ValidateSongsCommand.Execute(null);
            }));
        }
Ejemplo n.º 4
0
        public RegistrationViewModel(IMvxNavigationService navigationService, IAuthService authService, IUserDialogs userDialogs, IValidator validator /*, ILocationService locationService*/, MvvmCross.Plugins.Validation.IMvxToastService toastService, IBottomNavigationViewModelService bottomNavigationViewModelService, ITopNavigationViewModelService topNavigationViewModelService)
        {
            _navigationService                = navigationService;
            _topNavigationViewModelService    = topNavigationViewModelService;
            _bottomNavigationViewModelService = bottomNavigationViewModelService;

            _authService  = authService;
            _userDialogs  = userDialogs;
            _toastService = toastService;

            _validationHelper = new ValidationHelper(validator, this, Errors.Value, (propertyName) => { FocusName.Value = propertyName; });

            //_locationService = locationService;

            ValidateEmailCommand     = new MvxCommand(() => _validationHelper.Validate(() => Email));
            ValidateFirstNameCommand = new MvxCommand(() => _validationHelper.Validate(() => FirstName));
            ValidateLastNameCommand  = new MvxCommand(() => _validationHelper.Validate(() => LastName));
            ValidatePasswordCommand  = new MvxCommand(() => _validationHelper.Validate(() => Password));
            ValidateBirthDateCommand = new MvxCommand(() => _validationHelper.Validate(() => BirthDate));

            RegisterCommand = new MvxCommand(() =>
            {
                if (!IsTaskExecutedValueConverter.Convert(RegisterTask.Value))
                {
                    RegisterTask.Value = NotifyTaskCompletion.Create(AttemptRegisterAsync);
                }
            });

            ChangeBirthDateCommand = new MvxAsyncCommand(async() => {
                var datePromptResult = await _userDialogs.DatePromptAsync(new DatePromptConfig()
                {
                    MinimumDate = new DateTime(1900, 1, 1), MaximumDate = DateTime.Now, SelectedDate = BirthDate.Value ?? new DateTime?(new DateTime(1990, 1, 1)), OkText = "OK", CancelText = "Cancel"
                });
                if (datePromptResult.Ok)
                {
                    BirthDate.Value = new DateTime?(datePromptResult.SelectedDate);
                }
                else
                {
                    BirthDate.Value = null;
                }
                ValidateBirthDateCommand.Execute(null);
            });

            InitValidationCommand = new MvxCommand(() => {
                _validationHelper.ResetValidation();
            });
        }