public ForgotPasswordViewModel( ITimeService timeService, IUserAccessManager userAccessManager, IAnalyticsService analyticsService, INavigationService navigationService, IRxActionFactory rxActionFactory) : base(navigationService) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.timeService = timeService; this.userAccessManager = userAccessManager; this.analyticsService = analyticsService; this.rxActionFactory = rxActionFactory; Reset = rxActionFactory.FromObservable(reset, Email.Select(email => email.IsValid)); var resetActionStartedObservable = Reset .Executing .Where(executing => executing) .Select(_ => (Exception)null); ErrorMessage = Reset.Errors .Merge(resetActionStartedObservable) .Select(toErrorString) .StartWith("") .DistinctUntilChanged(); PasswordResetSuccessful = Reset.Elements .Select(_ => true) .StartWith(false); }
public ForgotPasswordViewModel( ITimeService timeService, IUserAccessManager userAccessManager, IAnalyticsService analyticsService, IMvxNavigationService navigationService, IRxActionFactory rxActionFactory) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.timeService = timeService; this.userAccessManager = userAccessManager; this.analyticsService = analyticsService; this.navigationService = navigationService; this.rxActionFactory = rxActionFactory; Reset = rxActionFactory.FromObservable(reset, Email.Select(email => email.IsValid)); Close = rxActionFactory.FromAction(returnEmail, Reset.Executing.Invert()); ErrorMessage = Reset.Errors .Select(toErrorString) .StartWith(""); PasswordResetSuccessful = Reset.Elements .Select(_ => true) .StartWith(false); }
public LogoutInteractor( IAnalyticsService analyticsService, INotificationService notificationService, IApplicationShortcutCreator shortcutCreator, ISyncManager syncManager, ITogglDatabase database, IUserPreferences userPreferences, IPrivateSharedStorageService privateSharedStorageService, IUserAccessManager userAccessManager, LogoutSource source) { Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(notificationService, nameof(notificationService)); Ensure.Argument.IsNotNull(shortcutCreator, nameof(shortcutCreator)); Ensure.Argument.IsNotNull(syncManager, nameof(syncManager)); Ensure.Argument.IsNotNull(database, nameof(database)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsADefinedEnumValue(source, nameof(source)); this.analyticsService = analyticsService; this.shortcutCreator = shortcutCreator; this.notificationService = notificationService; this.syncManager = syncManager; this.database = database; this.userPreferences = userPreferences; this.privateSharedStorageService = privateSharedStorageService; this.userAccessManager = userAccessManager; this.source = source; }
public TokenResetViewModel( IUserAccessManager userAccessManager, ITogglDataSource dataSource, IDialogService dialogService, IMvxNavigationService 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); }
public InteractorFactory( ITogglApi api, IUserAccessManager userAccessManager, Lazy <IIdProvider> idProvider, Lazy <ITogglDatabase> database, Lazy <ITimeService> timeService, Lazy <ISyncManager> syncManager, Lazy <IPlatformInfo> platformInfo, Lazy <ITogglDataSource> dataSource, Lazy <ICalendarService> calendarService, Lazy <IUserPreferences> userPreferences, Lazy <IAnalyticsService> analyticsService, Lazy <INotificationService> notificationService, Lazy <ILastTimeUsageStorage> lastTimeUsageStorage, Lazy <IApplicationShortcutCreator> shortcutCreator, Lazy <IPrivateSharedStorageService> privateSharedStorageService, Lazy <IKeyValueStorage> keyValueStorage, Lazy <IPushNotificationsTokenService> pushNotificationsTokenService, Lazy <IPushNotificationsTokenStorage> pushNotificationsTokenStorage) { Ensure.Argument.IsNotNull(api, nameof(api)); Ensure.Argument.IsNotNull(database, nameof(database)); Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(idProvider, nameof(idProvider)); Ensure.Argument.IsNotNull(syncManager, nameof(syncManager)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo)); Ensure.Argument.IsNotNull(calendarService, nameof(calendarService)); Ensure.Argument.IsNotNull(shortcutCreator, nameof(shortcutCreator)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(notificationService, nameof(notificationService)); Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage)); Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService)); Ensure.Argument.IsNotNull(keyValueStorage, nameof(keyValueStorage)); Ensure.Argument.IsNotNull(pushNotificationsTokenService, nameof(pushNotificationsTokenService)); Ensure.Argument.IsNotNull(pushNotificationsTokenStorage, nameof(pushNotificationsTokenStorage)); this.api = api; this.userAccessManager = userAccessManager; lazyDatabase = database; lazyDataSource = dataSource; lazyIdProvider = idProvider; lazySyncManager = syncManager; lazyTimeService = timeService; lazyPlatformInfo = platformInfo; lazyCalendarService = calendarService; lazyUserPreferences = userPreferences; lazyShortcutCreator = shortcutCreator; lazyAnalyticsService = analyticsService; lazyNotificationService = notificationService; lazyLastTimeUsageStorage = lastTimeUsageStorage; lazyPrivateSharedStorageService = privateSharedStorageService; lazyKeyValueStorage = keyValueStorage; lazyPushNotificationsTokenService = pushNotificationsTokenService; lazyPushNotificationsTokenStorage = pushNotificationsTokenStorage; }
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; }
protected UserAccessManagerTest() { UserAccessManager = new UserAccessManager(ApiFactory, Database, GoogleService, ApplicationShortcutCreator, PrivateSharedStorageService, CreateDataSource); Api.User.Get().Returns(Observable.Return(User)); Api.User.SignUp(Email, Password, TermsAccepted, CountryId, Timezone).Returns(Observable.Return(User)); Api.User.GetWithGoogle().Returns(Observable.Return(User)); ApiFactory.CreateApiWith(Arg.Any <Credentials>()).Returns(Api); Database.Clear().Returns(Observable.Return(Unit.Default)); }
public void SetupBackgroundSync(IUserAccessManager loginManager) { loggedInDisposable = loginManager.UserLoggedIn .Do(EnableBackgroundSync) .Subscribe(); loggedOutDisposable = loginManager.UserLoggedOut .Do(DisableBackgroundSync) .Subscribe(); }
public void SetupAutomaticSync(IUserAccessManager userAccessManager) { userAccessManager.UserLoggedIn .Subscribe(start) .DisposedBy(disposeBag); userAccessManager.UserLoggedOut .Subscribe(_ => stop()) .DisposedBy(disposeBag); }
public AccountController(UserManager <User> userManager, SignInManager <User> signInManager, IRepositoryWrapper repoWrapper, ILogger <AccountController> logger, IEmailConfirmation emailConfirmation, IHostingEnvironment env, IUserAccessManager userAccessManager) { _userManager = userManager; _signInManager = signInManager; _repoWrapper = repoWrapper; _logger = logger; _emailConfirmation = emailConfirmation; _env = env; _userAccessManager = userAccessManager; }
public AppStart( IMvxApplication app, ITimeService timeService, IUserAccessManager userAccessManager, IOnboardingStorage onboardingStorage, IForkingNavigationService navigationService, IAccessRestrictionStorage accessRestrictionStorage) : base(app, navigationService) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage)); this.timeService = timeService; this.userAccessManager = userAccessManager; this.onboardingStorage = onboardingStorage; this.navigationService = navigationService; this.accessRestrictionStorage = accessRestrictionStorage; }
public TokenResetViewModel( IUserAccessManager userAccessManager, ITogglDataSource dataSource, INavigationService navigationService, IUserPreferences userPreferences, IAnalyticsService analyticsService, ISchedulerProvider schedulerProvider, IRxActionFactory rxActionFactory, IInteractorFactory interactorFactory) : base(navigationService) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); this.dataSource = dataSource; this.userAccessManager = userAccessManager; this.interactorFactory = interactorFactory; 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(Shared.Password.From) .CombineLatest(Done.Executing, (password, isExecuting) => password.IsValid && !isExecuting) .DistinctUntilChanged() .AsDriver(schedulerProvider); }
public MainTabBarViewModel( ITimeService timeService, ITogglDataSource dataSource, ISyncManager syncManager, IRatingService ratingService, IUserPreferences userPreferences, IAnalyticsService analyticsService, IBackgroundService backgroundService, IInteractorFactory interactorFactory, IOnboardingStorage onboardingStorage, ISchedulerProvider schedulerProvider, IPermissionsChecker permissionsChecker, INavigationService navigationService, IRemoteConfigService remoteConfigService, IAccessibilityService accessibilityService, IUpdateRemoteConfigCacheService updateRemoteConfigCacheService, IAccessRestrictionStorage accessRestrictionStorage, IRxActionFactory rxActionFactory, IUserAccessManager userAccessManager, IPrivateSharedStorageService privateSharedStorageService, IPlatformInfo platformInfo) : base(navigationService) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(syncManager, nameof(syncManager)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService)); Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker)); Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService)); Ensure.Argument.IsNotNull(accessibilityService, nameof(accessibilityService)); Ensure.Argument.IsNotNull(updateRemoteConfigCacheService, nameof(updateRemoteConfigCacheService)); Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService)); Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo)); this.remoteConfigService = remoteConfigService; this.platformInfo = platformInfo; mainViewModel = new MainViewModel( dataSource, syncManager, timeService, ratingService, userPreferences, analyticsService, onboardingStorage, interactorFactory, navigationService, remoteConfigService, accessibilityService, updateRemoteConfigCacheService, accessRestrictionStorage, schedulerProvider, rxActionFactory, permissionsChecker, backgroundService, platformInfo); reportsViewModel = new ReportsViewModel( dataSource, timeService, navigationService, interactorFactory, analyticsService, schedulerProvider, rxActionFactory); calendarViewModel = new CalendarViewModel( dataSource, timeService, userPreferences, analyticsService, backgroundService, interactorFactory, onboardingStorage, schedulerProvider, permissionsChecker, navigationService, rxActionFactory); settingsViewModel = new SettingsViewModel( dataSource, syncManager, platformInfo, userPreferences, analyticsService, interactorFactory, onboardingStorage, navigationService, rxActionFactory, permissionsChecker, schedulerProvider); Tabs = getViewModels().ToList(); }
public LoginViewModel( IUserAccessManager userAccessManager, IAnalyticsService analyticsService, IOnboardingStorage onboardingStorage, IMvxNavigationService navigationService, IPasswordManagerService passwordManagerService, IErrorHandlingService errorHandlingService, ILastTimeUsageStorage lastTimeUsageStorage, ITimeService timeService, ISchedulerProvider schedulerProvider, IRxActionFactory rxActionFactory) { 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(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)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.timeService = timeService; this.userAccessManager = userAccessManager; 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()); Signup = rxActionFactory.FromAsync(signup); ForgotPassword = rxActionFactory.FromAsync(forgotPassword); StartPasswordManager = rxActionFactory.FromAsync(startPasswordManager); 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; }
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 SettingsViewModel( ITogglDataSource dataSource, ISyncManager syncManager, IPlatformInfo platformInfo, IDialogService dialogService, IUserPreferences userPreferences, IAnalyticsService analyticsService, IUserAccessManager userAccessManager, IInteractorFactory interactorFactory, IOnboardingStorage onboardingStorage, IMvxNavigationService navigationService, IPrivateSharedStorageService privateSharedStorageService, IIntentDonationService intentDonationService, IStopwatchProvider stopwatchProvider, IRxActionFactory rxActionFactory, IPermissionsService permissionsService, ISchedulerProvider schedulerProvider) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(syncManager, nameof(syncManager)); Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo)); Ensure.Argument.IsNotNull(dialogService, nameof(dialogService)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService)); Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService)); Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); Ensure.Argument.IsNotNull(permissionsService, nameof(permissionsService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); this.dataSource = dataSource; this.syncManager = syncManager; this.platformInfo = platformInfo; this.dialogService = dialogService; this.userPreferences = userPreferences; this.rxActionFactory = rxActionFactory; this.analyticsService = analyticsService; this.interactorFactory = interactorFactory; this.navigationService = navigationService; this.userAccessManager = userAccessManager; this.onboardingStorage = onboardingStorage; this.stopwatchProvider = stopwatchProvider; this.intentDonationService = intentDonationService; this.privateSharedStorageService = privateSharedStorageService; this.rxActionFactory = rxActionFactory; this.schedulerProvider = schedulerProvider; this.permissionsService = permissionsService; IsSynced = syncManager.ProgressObservable .SelectMany(checkSynced) .AsDriver(schedulerProvider); IsRunningSync = syncManager.ProgressObservable .Select(isRunningSync) .AsDriver(schedulerProvider); Name = dataSource.User.Current .Select(user => user.Fullname) .DistinctUntilChanged() .AsDriver(schedulerProvider); Email = dataSource.User.Current .Select(user => user.Email.ToString()) .DistinctUntilChanged() .AsDriver(schedulerProvider); IsManualModeEnabled = userPreferences.IsManualModeEnabledObservable .AsDriver(schedulerProvider); AreRunningTimerNotificationsEnabled = userPreferences.AreRunningTimerNotificationsEnabledObservable .AsDriver(schedulerProvider); AreStoppedTimerNotificationsEnabled = userPreferences.AreStoppedTimerNotificationsEnabledObservable .AsDriver(schedulerProvider); WorkspaceName = dataSource.User.Current .DistinctUntilChanged(user => user.DefaultWorkspaceId) .SelectMany(_ => interactorFactory.GetDefaultWorkspace() .TrackException <InvalidOperationException, IThreadSafeWorkspace>("SettingsViewModel.constructor") .Execute() ) .Select(workspace => workspace.Name) .AsDriver(schedulerProvider); BeginningOfWeek = dataSource.User.Current .Select(user => user.BeginningOfWeek) .DistinctUntilChanged() .Select(beginningOfWeek => beginningOfWeek.ToString()) .AsDriver(schedulerProvider); DateFormat = dataSource.Preferences.Current .Select(preferences => preferences.DateFormat.Localized) .DistinctUntilChanged() .AsDriver(schedulerProvider); DurationFormat = dataSource.Preferences.Current .Select(preferences => preferences.DurationFormat) .Select(DurationFormatToString.Convert) .DistinctUntilChanged() .AsDriver(schedulerProvider); UseTwentyFourHourFormat = dataSource.Preferences.Current .Select(preferences => preferences.TimeOfDayFormat.IsTwentyFourHoursFormat) .DistinctUntilChanged() .AsDriver(schedulerProvider); IsGroupingTimeEntries = dataSource.Preferences.Current .Select(preferences => preferences.CollapseTimeEntries) .DistinctUntilChanged() .AsDriver(false, schedulerProvider); IsCalendarSmartRemindersVisible = calendarPermissionGranted.AsObservable() .CombineLatest(userPreferences.EnabledCalendars.Select(ids => ids.Any()), CommonFunctions.And); CalendarSmartReminders = userPreferences.CalendarNotificationsSettings() .Select(s => s.Title()) .DistinctUntilChanged(); UserAvatar = dataSource.User.Current .Select(user => user.ImageUrl) .DistinctUntilChanged() .SelectMany(url => interactorFactory.GetUserAvatar(url).Execute()) .AsDriver(schedulerProvider) .Where(avatar => avatar != null); Workspaces = dataSource.User.Current .DistinctUntilChanged(user => user.DefaultWorkspaceId) .SelectMany(user => interactorFactory .GetAllWorkspaces() .Execute() .Select(selectableWorkspacesFromWorkspaces(user)) ) .AsDriver(schedulerProvider); LoggingOut = loggingOutSubject.AsObservable() .AsDriver(schedulerProvider); dataSource.User.Current .Subscribe(user => currentUser = user) .DisposedBy(disposeBag); dataSource.Preferences.Current .Subscribe(preferences => currentPreferences = preferences) .DisposedBy(disposeBag); IsRunningSync .Subscribe(isSyncing => this.isSyncing = isSyncing) .DisposedBy(disposeBag); IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsObservable() .AsDriver(schedulerProvider); OpenCalendarSettings = rxActionFactory.FromAsync(openCalendarSettings); OpenCalendarSmartReminders = rxActionFactory.FromAsync(openCalendarSmartReminders); OpenNotificationSettings = rxActionFactory.FromAsync(openNotificationSettings); ToggleTwentyFourHourSettings = rxActionFactory.FromAsync(toggleUseTwentyFourHourClock); OpenHelpView = rxActionFactory.FromAsync(openHelpView); TryLogout = rxActionFactory.FromAsync(tryLogout); OpenAboutView = rxActionFactory.FromAsync(openAboutView); SubmitFeedback = rxActionFactory.FromAsync(submitFeedback); SelectDateFormat = rxActionFactory.FromAsync(selectDateFormat); PickDefaultWorkspace = rxActionFactory.FromAsync(pickDefaultWorkspace); SelectDurationFormat = rxActionFactory.FromAsync(selectDurationFormat); SelectBeginningOfWeek = rxActionFactory.FromAsync(selectBeginningOfWeek); ToggleTimeEntriesGrouping = rxActionFactory.FromAsync(toggleTimeEntriesGrouping); SelectDefaultWorkspace = rxActionFactory.FromAsync <SelectableWorkspaceViewModel>(selectDefaultWorkspace); Close = rxActionFactory.FromAsync(close); }
public MainTabBarViewModel( ITimeService timeService, ITogglDataSource dataSource, ISyncManager syncManager, IDialogService dialogService, IRatingService ratingService, IUserPreferences userPreferences, IAnalyticsService analyticsService, IBackgroundService backgroundService, IInteractorFactory interactorFactory, IOnboardingStorage onboardingStorage, ISchedulerProvider schedulerProvider, IPermissionsService permissionsService, IMvxNavigationService navigationService, IRemoteConfigService remoteConfigService, ISuggestionProviderContainer suggestionProviders, IIntentDonationService intentDonationService, IAccessRestrictionStorage accessRestrictionStorage, IStopwatchProvider stopwatchProvider, IRxActionFactory rxActionFactory, IUserAccessManager userAccessManager, IPrivateSharedStorageService privateSharedStorageService, IPlatformInfo platformInfo) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(syncManager, nameof(syncManager)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(dialogService, nameof(dialogService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService)); Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(permissionsService, nameof(permissionsService)); Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService)); Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders)); Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage)); Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService)); Ensure.Argument.IsNotNull(dialogService, nameof(dialogService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager)); Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService)); Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo)); this.remoteConfigService = remoteConfigService; this.stopwatchProvider = stopwatchProvider; this.platformInfo = platformInfo; mainViewModel = new MainViewModel( dataSource, syncManager, timeService, ratingService, userPreferences, analyticsService, onboardingStorage, interactorFactory, navigationService, remoteConfigService, suggestionProviders, intentDonationService, accessRestrictionStorage, schedulerProvider, stopwatchProvider, rxActionFactory); reportsViewModel = new ReportsViewModel( dataSource, timeService, navigationService, interactorFactory, analyticsService, dialogService, intentDonationService, schedulerProvider, stopwatchProvider, rxActionFactory); calendarViewModel = new CalendarViewModel( dataSource, timeService, dialogService, userPreferences, analyticsService, backgroundService, interactorFactory, onboardingStorage, schedulerProvider, permissionsService, navigationService, stopwatchProvider, rxActionFactory); settingsViewModel = new SettingsViewModel( dataSource, syncManager, platformInfo, dialogService, userPreferences, analyticsService, userAccessManager, interactorFactory, onboardingStorage, navigationService, privateSharedStorageService, intentDonationService, stopwatchProvider, rxActionFactory, permissionsService, schedulerProvider); }