public SendFeedbackInteractor(
            IFeedbackApi feedbackApi,
            ISingletonDataSource <IThreadSafeUser> userDataSource,
            IDataSource <IThreadSafeWorkspace, IDatabaseWorkspace> workspacesDataSource,
            IDataSource <IThreadSafeTimeEntry, IDatabaseTimeEntry> timeEntriesDataSource,
            IPlatformInfo platformInfo,
            IUserPreferences userPreferences,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            string message)
        {
            Ensure.Argument.IsNotNull(message, nameof(message));
            Ensure.Argument.IsNotNull(feedbackApi, nameof(feedbackApi));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));
            Ensure.Argument.IsNotNull(userDataSource, nameof(userDataSource));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(workspacesDataSource, nameof(workspacesDataSource));
            Ensure.Argument.IsNotNull(timeEntriesDataSource, nameof(timeEntriesDataSource));

            this.message               = message;
            this.feedbackApi           = feedbackApi;
            this.timeService           = timeService;
            this.platformInfo          = platformInfo;
            this.userDataSource        = userDataSource;
            this.userPreferences       = userPreferences;
            this.workspacesDataSource  = workspacesDataSource;
            this.timeEntriesDataSource = timeEntriesDataSource;
            this.lastTimeUsageStorage  = lastTimeUsageStorage;
        }
        public InteractorFactory(
            IIdProvider idProvider,
            ITimeService timeService,
            ITogglDataSource dataSource,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IApplicationShortcutCreator shortcutCreator,
            ILastTimeUsageStorage lastTimeUsageStorage,
            IPlatformConstants platformConstants,
            UserAgent userAgent)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(idProvider, nameof(idProvider));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(shortcutCreator, nameof(shortcutCreator));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(platformConstants, nameof(platformConstants));
            Ensure.Argument.IsNotNull(userAgent, nameof(userAgent));

            this.dataSource           = dataSource;
            this.idProvider           = idProvider;
            this.timeService          = timeService;
            this.userPreferences      = userPreferences;
            this.shortcutCreator      = shortcutCreator;
            this.analyticsService     = analyticsService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.platformConstants    = platformConstants;
            this.userAgent            = userAgent;
        }
Example #3
0
        private MvvmCrossFoundation(Builder builder)
        {
            builder.EnsureValidity();

            DialogService            = builder.DialogService;
            BrowserService           = builder.BrowserService;
            KeyValueStorage          = builder.KeyValueStorage;
            UserPreferences          = builder.UserPreferences;
            FeedbackService          = builder.FeedbackService;
            OnboardingStorage        = builder.OnboardingStorage;
            NavigationService        = builder.NavigationService;
            PasswordManagerService   = builder.PasswordManagerService;
            ErrorHandlingService     = builder.ErrorHandlingService;
            AccessRestrictionStorage = builder.AccessRestrictionStorage;
            LastTimeUsageStorage     = builder.LastTimeUsageStorage;

            Version                     = builder.Foundation.Version;
            Database                    = builder.Foundation.Database;
            UserAgent                   = builder.Foundation.UserAgent;
            Scheduler                   = builder.Foundation.Scheduler;
            ApiFactory                  = builder.Foundation.ApiFactory;
            TimeService                 = builder.Foundation.TimeService;
            MailService                 = builder.Foundation.MailService;
            RatingService               = builder.Foundation.RatingService;
            GoogleService               = builder.Foundation.GoogleService;
            ApiEnvironment              = builder.Foundation.ApiEnvironment;
            LicenseProvider             = builder.Foundation.LicenseProvider;
            ShortcutCreator             = builder.Foundation.ShortcutCreator;
            AnalyticsService            = builder.Foundation.AnalyticsService;
            PlatformConstants           = builder.Foundation.PlatformConstants;
            SchedulerProvider           = builder.Foundation.SchedulerProvider;
            BackgroundService           = builder.Foundation.BackgroundService;
            RemoteConfigService         = builder.Foundation.RemoteConfigService;
            SuggestionProviderContainer = builder.Foundation.SuggestionProviderContainer;
        }
Example #4
0
        public SignupViewModel(
            IApiFactory apiFactory,
            ILoginManager loginManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IErrorHandlingService errorHandlingService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService)
        {
            Ensure.Argument.IsNotNull(apiFactory, nameof(apiFactory));
            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(errorHandlingService, nameof(errorHandlingService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));

            this.apiFactory           = apiFactory;
            this.loginManager         = loginManager;
            this.analyticsService     = analyticsService;
            this.onboardingStorage    = onboardingStorage;
            this.navigationService    = navigationService;
            this.errorHandlingService = errorHandlingService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.timeService          = timeService;

            LoginCommand                    = new MvxAsyncCommand(login);
            GoogleSignupCommand             = new MvxCommand(googleSignup);
            PickCountryCommand              = new MvxAsyncCommand(pickCountry);
            SignupCommand                   = new MvxAsyncCommand(signup, () => SignupEnabled);
            TogglePasswordVisibilityCommand = new MvxCommand(togglePasswordVisibility);
        }
Example #5
0
        public SyncManager(
            ISyncStateQueue queue,
            IStateMachineOrchestrator orchestrator,
            IAnalyticsService analyticsService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            IStopwatchProvider stopwatchProvider)
        {
            Ensure.Argument.IsNotNull(queue, nameof(queue));
            Ensure.Argument.IsNotNull(orchestrator, nameof(orchestrator));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));

            this.queue                = queue;
            this.orchestrator         = orchestrator;
            this.analyticsService     = analyticsService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.timeService          = timeService;
            this.stopwatchProvider    = stopwatchProvider;

            progress           = new BehaviorSubject <SyncProgress>(SyncProgress.Unknown);
            ProgressObservable = progress.AsObservable();

            errors = new Subject <Exception>();
            Errors = errors.AsObservable();

            orchestrator.SyncCompleteObservable.Subscribe(syncOperationCompleted);
            isFrozen = false;
        }
        public LoginViewModel(
            ILoginManager loginManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IPasswordManagerService passwordManagerService,
            IErrorHandlingService errorHandlingService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService)
        {
            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));

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

            SignupCommand                   = new MvxAsyncCommand(signup);
            GoogleLoginCommand              = new MvxCommand(googleLogin);
            LoginCommand                    = new MvxCommand(login, () => LoginEnabled);
            ForgotPasswordCommand           = new MvxAsyncCommand(forgotPassword);
            TogglePasswordVisibilityCommand = new MvxCommand(togglePasswordVisibility);
            StartPasswordManagerCommand     = new MvxAsyncCommand(startPasswordManager, () => IsPasswordManagerAvailable);
        }
        public InteractorFactory(
            IIdProvider idProvider,
            ITimeService timeService,
            ITogglDataSource dataSource,
            ITogglApi api,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            INotificationService notificationService,
            IIntentDonationService intentDonationService,
            IApplicationShortcutCreator shortcutCreator,
            ILastTimeUsageStorage lastTimeUsageStorage,
            IPlatformInfo platformInfo,
            UserAgent userAgent,
            ICalendarService calendarService,
            ISyncManager syncManager,
            IStopwatchProvider stopwatchProvider,
            ITogglDatabase database,
            IPrivateSharedStorageService privateSharedStorageService,
            IUserAccessManager userAccessManager)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(api, nameof(api));
            Ensure.Argument.IsNotNull(idProvider, nameof(idProvider));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(shortcutCreator, nameof(shortcutCreator));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(notificationService, nameof(notificationService));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));
            Ensure.Argument.IsNotNull(userAgent, nameof(userAgent));
            Ensure.Argument.IsNotNull(calendarService, nameof(calendarService));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(database, nameof(database));
            Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));

            this.dataSource                  = dataSource;
            this.api                         = api;
            this.idProvider                  = idProvider;
            this.timeService                 = timeService;
            this.userPreferences             = userPreferences;
            this.shortcutCreator             = shortcutCreator;
            this.analyticsService            = analyticsService;
            this.notificationService         = notificationService;
            this.intentDonationService       = intentDonationService;
            this.lastTimeUsageStorage        = lastTimeUsageStorage;
            this.platformInfo                = platformInfo;
            this.userAgent                   = userAgent;
            this.calendarService             = calendarService;
            this.syncManager                 = syncManager;
            this.stopwatchProvider           = stopwatchProvider;
            this.database                    = database;
            this.privateSharedStorageService = privateSharedStorageService;
            this.userAccessManager           = userAccessManager;
        }
        public AutomaticSyncingService(
            IBackgroundService backgroundService,
            ITimeService timeService,
            ILastTimeUsageStorage lastTimeUsageStorage)
        {
            Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));

            this.backgroundService    = backgroundService;
            this.timeService          = timeService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
        }
Example #9
0
        public CreatePlaceholdersStateFactory(
            ITogglDataSource dataSource,
            IAnalyticsService analyticsService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));

            this.dataSource           = dataSource;
            this.analyticsService     = analyticsService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.timeService          = timeService;
        }
Example #10
0
        private static void configurePullTimeEntriesTransitions(
            ITransitionConfigurator transitions,
            ITogglApi api,
            ITogglDataSource dataSource,
            ITogglDatabase database,
            IAnalyticsService analyticsService,
            ITimeService timeService,
            ILeakyBucket leakyBucket,
            IRateLimiter rateLimiter,
            ILastTimeUsageStorage lastTimeUsageStorage,
            StateResult entryPoint)
        {
            var fetchTimeEntries = new FetchJustTimeEntriesSinceState(api, database.SinceParameters, timeService, leakyBucket, rateLimiter);
            var ensureFetchTimeEntriesSucceeded = new EnsureFetchListSucceededState <ITimeEntry>();

            var placeholderStateFactory = new CreatePlaceholdersStateFactory(
                dataSource,
                analyticsService,
                lastTimeUsageStorage,
                timeService);
            var createWorkspacePlaceholder = placeholderStateFactory.ForWorkspaces();
            var createProjectPlaceholder   = placeholderStateFactory.ForProjects();
            var createTaskPlaceholder      = placeholderStateFactory.ForTasks();
            var createTagPlaceholder       = placeholderStateFactory.ForTags();

            var persistTimeEntries =
                new PersistListState <ITimeEntry, IDatabaseTimeEntry, IThreadSafeTimeEntry>(dataSource.TimeEntries, TimeEntry.Clean);
            var updateTimeEntriesSinceDate = new UpdateSinceDateState <ITimeEntry>(database.SinceParameters);
            var timeEntriesAnalytics       = new TimeEntriesAnalyticsState(analyticsService);


            transitions.ConfigureTransition(entryPoint, fetchTimeEntries);
            transitions.ConfigureTransition(fetchTimeEntries.PreventOverloadingServer, new DeadEndState());
            transitions.ConfigureTransition(fetchTimeEntries.Done, ensureFetchTimeEntriesSucceeded);
            transitions.ConfigureTransition(ensureFetchTimeEntriesSucceeded.ErrorOccured, new FailureState());

            transitions.ConfigureTransition(ensureFetchTimeEntriesSucceeded.Done, timeEntriesAnalytics);

            transitions.ConfigureTransition(timeEntriesAnalytics.Done, createWorkspacePlaceholder);
            transitions.ConfigureTransition(createWorkspacePlaceholder.Done, createProjectPlaceholder);
            transitions.ConfigureTransition(createProjectPlaceholder.Done, createTaskPlaceholder);
            transitions.ConfigureTransition(createTaskPlaceholder.Done, createTagPlaceholder);

            transitions.ConfigureTransition(createTagPlaceholder.Done, persistTimeEntries);
            transitions.ConfigureTransition(persistTimeEntries.Done, updateTimeEntriesSinceDate);
            transitions.ConfigureTransition(updateTimeEntriesSinceDate.Done, new DeadEndState());
        }
        public static ISyncManager CreateSyncManager(
            ITogglDatabase database,
            ITogglApi api,
            ITogglDataSource dataSource,
            ITimeService timeService,
            IAnalyticsService analyticsService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            IScheduler scheduler)
        {
            var queue       = new SyncStateQueue();
            var entryPoints = new StateMachineEntryPoints();
            var transitions = new TransitionHandlerProvider();

            ConfigureTransitions(transitions, database, api, dataSource, scheduler, timeService, analyticsService, entryPoints, queue);
            var stateMachine = new StateMachine(transitions, scheduler);
            var orchestrator = new StateMachineOrchestrator(stateMachine, entryPoints);

            return(new SyncManager(queue, orchestrator, analyticsService, lastTimeUsageStorage, timeService));
        }
        public static void ConfigureTransitions(
            ITransitionConfigurator transitions,
            ITogglDatabase database,
            ITogglApi api,
            ITogglDataSource dataSource,
            IScheduler scheduler,
            ITimeService timeService,
            IAnalyticsService analyticsService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            StateMachineEntryPoints entryPoints,
            ISyncStateQueue queue)
        {
            var minutesLeakyBucket = new LeakyBucket(timeService, analyticsService, slotsPerWindow: 60, movingWindowSize: TimeSpan.FromSeconds(60));
            var secondsLeakyBucket = new LeakyBucket(timeService, analyticsService, slotsPerWindow: 3, movingWindowSize: TimeSpan.FromSeconds(1));
            var rateLimiter        = new RateLimiter(secondsLeakyBucket, scheduler);

            configurePullTransitions(transitions, database, api, dataSource, timeService, analyticsService, scheduler, entryPoints.StartPullSync, minutesLeakyBucket, rateLimiter, queue);
            configurePushTransitions(transitions, api, dataSource, analyticsService, minutesLeakyBucket, rateLimiter, scheduler, entryPoints.StartPushSync);
            configureCleanUpTransitions(transitions, timeService, dataSource, analyticsService, entryPoints.StartCleanUp);
            configurePullTimeEntriesTransitions(transitions, api, dataSource, database, analyticsService, timeService, minutesLeakyBucket, rateLimiter, lastTimeUsageStorage, entryPoints.StartPullTimeEntries);
        }
        public CreatePlaceholdersState(
            IDataSource <TThreadSafe, TDatabase> dataSource,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            IAnalyticsEvent <int> analyticsEvent,
            Func <ITimeEntry, long[]> dependencyIdsSelector,
            Func <long, long, TThreadSafe> buildDependencyPlaceholder)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(analyticsEvent, nameof(analyticsEvent));
            Ensure.Argument.IsNotNull(dependencyIdsSelector, nameof(dependencyIdsSelector));
            Ensure.Argument.IsNotNull(buildDependencyPlaceholder, nameof(buildDependencyPlaceholder));

            this.dataSource                 = dataSource;
            this.lastTimeUsageStorage       = lastTimeUsageStorage;
            this.timeService                = timeService;
            this.analyticsEvent             = analyticsEvent;
            this.dependencyIdsSelector      = dependencyIdsSelector;
            this.buildDependencyPlaceholder = buildDependencyPlaceholder;
        }
        public static ISyncManager CreateSyncManager(
            ITogglDatabase database,
            ITogglApi api,
            ITogglDataSource dataSource,
            ITimeService timeService,
            IAnalyticsService analyticsService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            TimeSpan?retryLimit,
            IScheduler scheduler)
        {
            var random                      = new Random();
            var queue                       = new SyncStateQueue();
            var entryPoints                 = new StateMachineEntryPoints();
            var transitions                 = new TransitionHandlerProvider();
            var apiDelay                    = new RetryDelayService(random, retryLimit);
            var delayCancellation           = new Subject <Unit>();
            var delayCancellationObservable = delayCancellation.AsObservable().Replay();

            ConfigureTransitions(transitions, database, api, dataSource, apiDelay, scheduler, timeService, analyticsService, entryPoints, delayCancellationObservable);
            var stateMachine = new StateMachine(transitions, scheduler, delayCancellation);
            var orchestrator = new StateMachineOrchestrator(stateMachine, entryPoints);

            return(new SyncManager(queue, orchestrator, analyticsService, lastTimeUsageStorage, timeService));
        }
Example #15
0
 public Builder WithLastTimeUsageStorage(ILastTimeUsageStorage lastTimeUsageStorage)
 {
     LastTimeUsageStorage = lastTimeUsageStorage;
     return(this);
 }
Example #16
0
        public LoginViewModel(
            IUserAccessManager userAccessManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            INavigationService navigationService,
            IErrorHandlingService errorHandlingService,
            ILastTimeUsageStorage lastTimeUsageStorage,
            ITimeService timeService,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IInteractorFactory interactorFactory)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            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(interactorFactory, nameof(interactorFactory));

            this.timeService          = timeService;
            this.userAccessManager    = userAccessManager;
            this.analyticsService     = analyticsService;
            this.onboardingStorage    = onboardingStorage;
            this.errorHandlingService = errorHandlingService;
            this.lastTimeUsageStorage = lastTimeUsageStorage;
            this.schedulerProvider    = schedulerProvider;
            this.interactorFactory    = interactorFactory;

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

            Signup         = rxActionFactory.FromAsync(signup);
            ForgotPassword = rxActionFactory.FromAsync(forgotPassword);

            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);
        }
Example #17
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);
        }
Example #18
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;
        }