public RatingViewModel( ITimeService timeService, IRatingService ratingService, IAnalyticsService analyticsService, IOnboardingStorage onboardingStorage, INavigationService navigationService, ISchedulerProvider schedulerProvider, IRxActionFactory rxActionFactory) : base(navigationService) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.timeService = timeService; this.ratingService = ratingService; this.analyticsService = analyticsService; this.onboardingStorage = onboardingStorage; this.schedulerProvider = schedulerProvider; Impression = impressionSubject.AsDriver(this.schedulerProvider); IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsDriver(this.schedulerProvider); HideRatingView = hideRatingView.AsDriver(this.schedulerProvider); PerformMainAction = rxActionFactory.FromAsync(performMainAction); }
public RatingViewModel( ITimeService timeService, ITogglDataSource dataSource, IRatingService ratingService, IAnalyticsService analyticsService, IOnboardingStorage onboardingStorage, IMvxNavigationService navigationService, ISchedulerProvider schedulerProvider, IRxActionFactory rxActionFactory) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); this.dataSource = dataSource; this.timeService = timeService; this.ratingService = ratingService; this.analyticsService = analyticsService; this.onboardingStorage = onboardingStorage; this.navigationService = navigationService; this.schedulerProvider = schedulerProvider; this.rxActionFactory = rxActionFactory; Impression = impressionSubject.AsDriver(this.schedulerProvider); CallToActionTitle = impressionSubject .Select(callToActionTitle) .AsDriver(this.schedulerProvider); CallToActionDescription = impressionSubject .Select(callToActionDescription) .AsDriver(this.schedulerProvider); CallToActionButtonTitle = impressionSubject .Select(callToActionButtonTitle) .AsDriver(this.schedulerProvider); IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsDriver(this.schedulerProvider); HideRatingView = hideRatingView.AsDriver(this.schedulerProvider); PerformMainAction = rxActionFactory.FromAsync(performMainAction); }
public RatingViewModel( ITimeService timeService, ITogglDataSource dataSource, IRatingService ratingService, IAnalyticsService analyticsService, IOnboardingStorage onboardingStorage, IMvxNavigationService navigationService, ISchedulerProvider schedulerProvider) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(ratingService, nameof(ratingService)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); this.dataSource = dataSource; this.timeService = timeService; this.ratingService = ratingService; this.analyticsService = analyticsService; this.onboardingStorage = onboardingStorage; this.navigationService = navigationService; this.schedulerProvider = schedulerProvider; Impression = impressionSubject.AsDriver(this.schedulerProvider); CtaTitle = impressionSubject .Select(ctaTitle) .AsDriver(this.schedulerProvider); CtaDescription = impressionSubject .Select(ctaDescription) .AsDriver(this.schedulerProvider); CtaButtonTitle = impressionSubject .Select(ctaButtonTitle) .AsDriver(this.schedulerProvider); IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsDriver(this.schedulerProvider); }
public SiriShortcutsCustomTimeEntryViewModel( ITogglDataSource dataSource, IInteractorFactory interactorFactory, IRxActionFactory rxActionFactory, IOnboardingStorage onboardingStorage, ISchedulerProvider schedulerProvider, INavigationService navigationService) : base(navigationService) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); this.navigationService = navigationService; this.interactorFactory = interactorFactory; this.onboardingStorage = onboardingStorage; SelectTags = rxActionFactory.FromAsync(selectTags); SelectProject = rxActionFactory.FromAsync(selectProject); SelectClipboard = rxActionFactory.FromAsync(selectClipboard); IsBillableAvailable = Workspace .Where(ws => ws?.Id != null) .SelectMany(ws => interactorFactory.IsBillableAvailableForWorkspace(ws.Id).Execute()) .DistinctUntilChanged() .AsDriver(false, schedulerProvider); HasTags = Tags.Select(tags => tags.Any()).AsDriver(false, schedulerProvider); TagNames = Tags .Select(tags => tags.Select(t => t.Name)) .AsDriver(Enumerable.Empty <string>(), schedulerProvider); ProjectClientTask = projectClientTaskInfo.AsDriver(EditTimeEntryViewModel.ProjectClientTaskInfo.Empty, schedulerProvider); }
public EditTimeEntryViewModel( ITimeService timeService, ITogglDataSource dataSource, ISyncManager syncManager, IInteractorFactory interactorFactory, IMvxNavigationService navigationService, IOnboardingStorage onboardingStorage, IDialogService dialogService, IAnalyticsService analyticsService, IStopwatchProvider stopwatchProvider, IRxActionFactory actionFactory, ISchedulerProvider schedulerProvider) { 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(interactorFactory, nameof(interactorFactory)); Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage)); Ensure.Argument.IsNotNull(navigationService, nameof(navigationService)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); Ensure.Argument.IsNotNull(actionFactory, nameof(actionFactory)); this.dataSource = dataSource; this.syncManager = syncManager; this.timeService = timeService; this.dialogService = dialogService; this.interactorFactory = interactorFactory; this.navigationService = navigationService; this.analyticsService = analyticsService; this.stopwatchProvider = stopwatchProvider; this.schedulerProvider = schedulerProvider; this.actionFactory = actionFactory; OnboardingStorage = onboardingStorage; workspaceIdSubject .Where(id => id.HasValue) .Subscribe(id => workspaceId = id.Value) .DisposedBy(disposeBag); isEditingDescriptionSubject = new BehaviorSubject <bool>(false); Description = new BehaviorRelay <string>(string.Empty, CommonFunctions.Trim); projectClientTaskSubject = new BehaviorSubject <ProjectClientTaskInfo>(ProjectClientTaskInfo.Empty); ProjectClientTask = projectClientTaskSubject .AsDriver(ProjectClientTaskInfo.Empty, schedulerProvider); IsBillableAvailable = workspaceIdSubject .Where(id => id.HasValue) .SelectMany(workspaceId => interactorFactory.IsBillableAvailableForWorkspace(workspaceId.Value).Execute()) .DistinctUntilChanged() .AsDriver(false, schedulerProvider); isBillableSubject = new BehaviorSubject <bool>(false); IsBillable = isBillableSubject .DistinctUntilChanged() .AsDriver(false, schedulerProvider); startTimeSubject = new BehaviorSubject <DateTimeOffset>(DateTimeOffset.UtcNow); var startTimeObservable = startTimeSubject.DistinctUntilChanged(); StartTime = startTimeObservable .AsDriver(default(DateTimeOffset), schedulerProvider); var now = timeService.CurrentDateTimeObservable.StartWith(timeService.CurrentDateTime); durationSubject = new ReplaySubject <TimeSpan?>(bufferSize: 1); Duration = durationSubject .Select(duration => duration.HasValue ? Observable.Return(duration.Value) : now.CombineLatest( startTimeObservable, (currentTime, startTime) => currentTime - startTime)) .Switch() .DistinctUntilChanged() .AsDriver(TimeSpan.Zero, schedulerProvider); var stopTimeObservable = Observable.CombineLatest(startTimeObservable, durationSubject, calculateStopTime) .DistinctUntilChanged(); StopTime = stopTimeObservable .AsDriver(null, schedulerProvider); var isTimeEntryRunningObservable = stopTimeObservable .Select(stopTime => !stopTime.HasValue) .Do(value => isRunning = value) .DistinctUntilChanged(); IsTimeEntryRunning = isTimeEntryRunningObservable .AsDriver(false, schedulerProvider); tagsSubject = new BehaviorSubject <IEnumerable <IThreadSafeTag> >(Enumerable.Empty <IThreadSafeTag>()); Tags = tagsSubject .Select(tags => tags.Select(ellipsize).ToImmutableList()) .AsDriver(ImmutableList <string> .Empty, schedulerProvider); isInaccessibleSubject = new BehaviorSubject <bool>(false); IsInaccessible = isInaccessibleSubject .DistinctUntilChanged() .AsDriver(false, schedulerProvider); syncErrorMessageSubject = new BehaviorSubject <string>(string.Empty); SyncErrorMessage = syncErrorMessageSubject .Select(error => error ?? string.Empty) .DistinctUntilChanged() .AsDriver(string.Empty, schedulerProvider); IsSyncErrorMessageVisible = syncErrorMessageSubject .Select(error => !string.IsNullOrEmpty(error)) .DistinctUntilChanged() .AsDriver(false, schedulerProvider); Preferences = interactorFactory.GetPreferences().Execute() .AsDriver(null, schedulerProvider); // Actions Close = actionFactory.FromAsync(closeWithConfirmation); SelectProject = actionFactory.FromAsync(selectProject); SelectTags = actionFactory.FromAsync(selectTags); ToggleBillable = actionFactory.FromAction(toggleBillable); EditTimes = actionFactory.FromAsync <EditViewTapSource>(editTimes); SelectStartDate = actionFactory.FromAsync(selectStartDate); StopTimeEntry = actionFactory.FromAction(stopTimeEntry, isTimeEntryRunningObservable); DismissSyncErrorMessage = actionFactory.FromAction(dismissSyncErrorMessage); Save = actionFactory.FromAsync(save); Delete = actionFactory.FromAsync(delete); }
public EditDurationViewModel(INavigationService navigationService, ITimeService timeService, ITogglDataSource dataSource, IAnalyticsService analyticsService, IRxActionFactory rxActionFactory, ISchedulerProvider schedulerProvider) : base(navigationService) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService)); Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory)); Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider)); this.timeService = timeService; this.analyticsService = analyticsService; this.dataSource = dataSource; Save = rxActionFactory.FromAction(save); EditStartTime = rxActionFactory.FromAction(editStartTime); EditStopTime = rxActionFactory.FromAction(editStopTime); StopEditingTime = rxActionFactory.FromAction(stopEditingTime); ChangeStartTime = rxActionFactory.FromAction <DateTimeOffset>(updateStartTime); ChangeStopTime = rxActionFactory.FromAction <DateTimeOffset>(updateStopTime); ChangeActiveTime = rxActionFactory.FromAction <DateTimeOffset>(changeActiveTime); ChangeDuration = rxActionFactory.FromAction <TimeSpan>(changeDuration); StopTimeEntry = rxActionFactory.FromAction(stopTimeEntry); var start = startTime.Where(v => v != default(DateTimeOffset)); var stop = stopTime.Where(v => v != default(DateTimeOffset)); var duration = Observable.CombineLatest(start, stop, (startValue, stopValue) => stopValue - startValue); StartTime = start.AsDriver(schedulerProvider); StopTime = stop.AsDriver(schedulerProvider); Duration = duration.AsDriver(schedulerProvider); IsEditingTime = editMode.Select(v => v != EditMode.None).AsDriver(schedulerProvider); IsEditingStartTime = editMode.Select(v => v == EditMode.StartTime).AsDriver(schedulerProvider); IsEditingStopTime = editMode.Select(v => v == EditMode.EndTime).AsDriver(schedulerProvider); var preferences = dataSource.Preferences.Current.ShareReplay(); var dateFormat = preferences.Select(p => p.DateFormat); var timeFormat = preferences.Select(p => p.TimeOfDayFormat); var durationFormat = preferences.Select(p => p.DurationFormat); StartDateString = Observable.CombineLatest(start, dateFormat, toFormattedString) .AsDriver(schedulerProvider); StartTimeString = Observable.CombineLatest(start, timeFormat, toFormattedString) .AsDriver(schedulerProvider); StopDateString = Observable.CombineLatest(stop, dateFormat, toFormattedString) .AsDriver(schedulerProvider); StopTimeString = Observable.CombineLatest(stop, timeFormat, toFormattedString) .AsDriver(schedulerProvider); DurationString = Observable.CombineLatest(duration, durationFormat, toFormattedString) .AsDriver(schedulerProvider); TimeFormat = timeFormat.AsDriver(schedulerProvider); IsRunning = isRunning.AsDriver(schedulerProvider); MinimumDateTime = minimumDateTime.AsDriver(schedulerProvider); MaximumDateTime = maximumDateTime.AsDriver(schedulerProvider); MinimumStartTime = stopTime.Select(v => v.AddHours(-MaxTimeEntryDurationInHours)).AsDriver(schedulerProvider); MaximumStartTime = stopTime.AsDriver(schedulerProvider); MinimumStopTime = startTime.AsDriver(schedulerProvider); MaximumStopTime = startTime.Select(v => v.AddHours(MaxTimeEntryDurationInHours)).AsDriver(schedulerProvider); }