示例#1
0
        public TokenResetViewModel(
            ILoginManager loginManager,
            ITogglDataSource dataSource,
            IDialogService dialogService,
            IForkingNavigationService navigationService,
            IUserPreferences userPreferences,
            IOnboardingStorage onboardingStorage,
            IAnalyticsService analyticsService
            )
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(loginManager, nameof(loginManager));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));

            this.dataSource        = dataSource;
            this.loginManager      = loginManager;
            this.dialogService     = dialogService;
            this.navigationService = navigationService;
            this.userPreferences   = userPreferences;
            this.onboardingStorage = onboardingStorage;
            this.analyticsService  = analyticsService;

            DoneCommand    = new MvxCommand(done);
            SignOutCommand = new MvxAsyncCommand(signout);
            TogglePasswordVisibilityCommand = new MvxCommand(togglePasswordVisibility);
        }
        public TokenResetViewModel(
            IUserAccessManager userAccessManager,
            ITogglDataSource dataSource,
            IDialogService dialogService,
            IForkingNavigationService navigationService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IInteractorFactory interactorFactory
            )
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));

            this.dataSource        = dataSource;
            this.userAccessManager = userAccessManager;
            this.dialogService     = dialogService;
            this.navigationService = navigationService;
            this.userPreferences   = userPreferences;
            this.analyticsService  = analyticsService;
            this.schedulerProvider = schedulerProvider;
            this.rxActionFactory   = rxActionFactory;
            this.interactorFactory = interactorFactory;

            Email = emailSubject
                    .DistinctUntilChanged()
                    .AsDriver(schedulerProvider);

            IsPasswordMasked = isPasswordMaskedSubject
                               .DistinctUntilChanged()
                               .AsDriver(schedulerProvider);

            TogglePasswordVisibility = rxActionFactory.FromAction(togglePasswordVisibility);

            Done    = rxActionFactory.FromObservable(done);
            SignOut = rxActionFactory.FromAsync(signout);

            Error = Done.Errors
                    .Select(transformException);

            HasError = Error
                       .Select(error => !string.IsNullOrEmpty(error))
                       .DistinctUntilChanged()
                       .AsDriver(schedulerProvider);

            NextIsEnabled = Password
                            .Select(Multivac.Password.From)
                            .CombineLatest(Done.Executing, (password, isExecuting) => password.IsValid && !isExecuting)
                            .DistinctUntilChanged()
                            .AsDriver(schedulerProvider);
        }
示例#3
0
        protected override IMvxNavigationService InitializeNavigationService(IMvxViewModelLocatorCollection collection)
        {
            analyticsService = new AnalyticsServiceIos();

            var loader = CreateViewModelLoader(collection);

            Mvx.RegisterSingleton <IMvxViewModelLoader>(loader);

            navigationService = new NavigationService(null, loader, analyticsService, Platform.Daneel);

            Mvx.RegisterSingleton <IForkingNavigationService>(navigationService);
            Mvx.RegisterSingleton <IMvxNavigationService>(navigationService);
            return(navigationService);
        }
示例#4
0
        public AppStart(
            IMvxApplication app,
            ITimeService timeService,
            ILoginManager loginManager,
            IOnboardingStorage onboardingStorage,
            IForkingNavigationService navigationService,
            IAccessRestrictionStorage accessRestrictionStorage)
            : base(app, navigationService)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(loginManager, nameof(loginManager));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));

            this.timeService              = timeService;
            this.loginManager             = loginManager;
            this.onboardingStorage        = onboardingStorage;
            this.navigationService        = navigationService;
            this.accessRestrictionStorage = accessRestrictionStorage;
        }
示例#5
0
        public LoginViewModel(
            ILoginManager loginManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IForkingNavigationService navigationService,
            IPasswordManagerService passwordManagerService,
            IErrorHandlingService errorHandlingService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            ISchedulerProvider schedulerProvider)
        {
            Ensure.Argument.IsNotNull(loginManager, nameof(loginManager));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(passwordManagerService, nameof(passwordManagerService));
            Ensure.Argument.IsNotNull(errorHandlingService, nameof(errorHandlingService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            this.timeService            = timeService;
            this.loginManager           = loginManager;
            this.analyticsService       = analyticsService;
            this.onboardingStorage      = onboardingStorage;
            this.navigationService      = navigationService;
            this.errorHandlingService   = errorHandlingService;
            this.lastTimeUsageStorage   = lastTimeUsageStorage;
            this.passwordManagerService = passwordManagerService;
            this.schedulerProvider      = schedulerProvider;

            var emailObservable = emailSubject.Select(email => email.TrimmedEnd());

            Shake = shakeSubject.AsDriver(this.schedulerProvider);

            Email = emailObservable
                    .Select(email => email.ToString())
                    .DistinctUntilChanged()
                    .AsDriver(this.schedulerProvider);

            Password = passwordSubject
                       .Select(password => password.ToString())
                       .DistinctUntilChanged()
                       .AsDriver(this.schedulerProvider);

            IsLoading = isLoadingSubject
                        .DistinctUntilChanged()
                        .AsDriver(this.schedulerProvider);

            ErrorMessage = errorMessageSubject
                           .DistinctUntilChanged()
                           .AsDriver(this.schedulerProvider);

            IsPasswordMasked = isPasswordMaskedSubject
                               .DistinctUntilChanged()
                               .AsDriver(this.schedulerProvider);

            IsShowPasswordButtonVisible = Password
                                          .Select(password => password.Length > 1)
                                          .CombineLatest(isShowPasswordButtonVisibleSubject.AsObservable(), CommonFunctions.And)
                                          .DistinctUntilChanged()
                                          .AsDriver(this.schedulerProvider);

            HasError = ErrorMessage
                       .Select(string.IsNullOrEmpty)
                       .Select(CommonFunctions.Invert)
                       .AsDriver(this.schedulerProvider);

            LoginEnabled = emailObservable
                           .CombineLatest(
                passwordSubject.AsObservable(),
                IsLoading,
                (email, password, isLoading) => email.IsValid && password.IsValid && !isLoading)
                           .DistinctUntilChanged()
                           .AsDriver(this.schedulerProvider);

            IsPasswordManagerAvailable = passwordManagerService.IsAvailable;
        }
示例#6
0
        public SignupViewModel(
            IApiFactory apiFactory,
            IUserAccessManager userAccessManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IForkingNavigationService navigationService,
            IErrorHandlingService errorHandlingService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IPlatformInfo platformInfo)
        {
            Ensure.Argument.IsNotNull(apiFactory, nameof(apiFactory));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(errorHandlingService, nameof(errorHandlingService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));

            this.apiFactory           = apiFactory;
            this.userAccessManager    = userAccessManager;
            this.analyticsService     = analyticsService;
            this.onboardingStorage    = onboardingStorage;
            this.navigationService    = navigationService;
            this.errorHandlingService = errorHandlingService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.timeService          = timeService;
            this.schedulerProvider    = schedulerProvider;
            this.rxActionFactory      = rxActionFactory;
            this.platformInfo         = platformInfo;

            Login        = rxActionFactory.FromAsync(login);
            Signup       = rxActionFactory.FromAsync(signup);
            GoogleSignup = rxActionFactory.FromAsync(googleSignup);
            PickCountry  = rxActionFactory.FromAsync(pickCountry);

            var emailObservable = emailSubject.Select(email => email.TrimmedEnd());

            Shake = shakeSubject.AsDriver(this.schedulerProvider);

            Email = emailObservable
                    .Select(email => email.ToString())
                    .DistinctUntilChanged()
                    .AsDriver(this.schedulerProvider);

            Password = passwordSubject
                       .Select(password => password.ToString())
                       .DistinctUntilChanged()
                       .AsDriver(this.schedulerProvider);

            IsLoading = isLoadingSubject
                        .DistinctUntilChanged()
                        .AsDriver(this.schedulerProvider);

            IsCountryErrorVisible = isCountryErrorVisibleSubject
                                    .DistinctUntilChanged()
                                    .AsDriver(this.schedulerProvider);

            ErrorMessage = errorMessageSubject
                           .DistinctUntilChanged()
                           .AsDriver(this.schedulerProvider);

            CountryButtonTitle = countryNameSubject
                                 .DistinctUntilChanged()
                                 .AsDriver(this.schedulerProvider);

            IsPasswordMasked = isPasswordMaskedSubject
                               .DistinctUntilChanged()
                               .AsDriver(this.schedulerProvider);

            IsShowPasswordButtonVisible = Password
                                          .Select(password => password.Length > 1)
                                          .CombineLatest(isShowPasswordButtonVisibleSubject.AsObservable(), CommonFunctions.And)
                                          .DistinctUntilChanged()
                                          .AsDriver(this.schedulerProvider);

            HasError = ErrorMessage
                       .Select(string.IsNullOrEmpty)
                       .Select(CommonFunctions.Invert)
                       .AsDriver(this.schedulerProvider);

            SignupEnabled = emailObservable
                            .CombineLatest(
                passwordSubject.AsObservable(),
                IsLoading,
                countryNameSubject.AsObservable(),
                (email, password, isLoading, countryName) => email.IsValid && password.IsValid && !isLoading && (countryName != Resources.SelectCountry))
                            .DistinctUntilChanged()
                            .AsDriver(this.schedulerProvider);

            SuccessfulSignup = successfulSignupSubject
                               .AsDriver(this.schedulerProvider);
        }
 public Builder WithNavigationService(IForkingNavigationService navigationService)
 {
     NavigationService = navigationService;
     return(this);
 }