Exemple #1
0
        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);
        }
Exemple #2
0
        private void prepareSwipeGesturesOnboarding(IOnboardingStorage storage)
        {
            timeEntriesCountSubject.OnNext(ViewModel.TimeEntriesCount);

            timeEntriesCountDisposable = ViewModel.WeakSubscribe(() => ViewModel.TimeEntriesCount, onTimeEntriesCountChanged);

            swipeRightStep = new SwipeRightOnboardingStep(timeEntriesCountSubject.AsObservable())
                             .ToDismissable(nameof(SwipeRightOnboardingStep), storage);

            swipeLeftStep = new SwipeLeftOnboardingStep(timeEntriesCountSubject.AsObservable(), swipeRightStep.ShouldBeVisible)
                            .ToDismissable(nameof(SwipeLeftOnboardingStep), storage);

            swipeLeftStep.DismissByTapping(SwipeLeftBubbleView);
            swipeLeftOnboardingDisposable = swipeLeftStep.ManageVisibilityOf(SwipeLeftBubbleView);
            swipeLeftAnimationDisposable  = swipeLeftStep.ManageSwipeActionAnimationOf(firstTimeEntry, Direction.Left);

            swipeRightStep.DismissByTapping(SwipeRightBubbleView);
            swipeRightOnboardingDisposable = swipeRightStep.ManageVisibilityOf(SwipeRightBubbleView);
            swipeRightAnimationDisposable  = swipeRightStep.ManageSwipeActionAnimationOf(firstTimeEntry, Direction.Right);

            swipeToContinueWasUsedDisposable = Observable.FromEventPattern(source, nameof(MainTableViewSource.SwipeToContinueWasUsed))
                                               .Subscribe(_ =>
            {
                swipeRightStep.Dismiss();
                swipeToContinueWasUsedDisposable?.Dispose();
                swipeToContinueWasUsedDisposable = null;
            });
            updateSwipeDismissGestures(firstTimeEntry);
        }
        public LoginViewModel(
            ILoginManager loginManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IPasswordManagerService passwordManagerService,
            IErrorHandlingService errorHandlingService)
        {
            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));

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

            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);
        }
Exemple #4
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 StartTimeEntryOnboardingStep(IOnboardingStorage onboardingStorage)
        {
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));

            ShouldBeVisible = onboardingStorage.IsNewUser.CombineLatest(onboardingStorage.StartButtonWasTappedBefore,
                                                                        (isNewUser, startButtonWasTapped) => isNewUser && !startButtonWasTapped);
        }
Exemple #6
0
        public TimeEntriesLogViewModel(ITimeService timeService,
                                       ITogglDataSource dataSource,
                                       IInteractorFactory interactorFactory,
                                       IOnboardingStorage onboardingStorage,
                                       IAnalyticsService analyticsService,
                                       IMvxNavigationService navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));

            this.dataSource        = dataSource;
            this.timeService       = timeService;
            this.onboardingStorage = onboardingStorage;
            this.analyticsService  = analyticsService;
            this.interactorFactory = interactorFactory;
            this.navigationService = navigationService;

            EditCommand              = new MvxAsyncCommand <TimeEntryViewModel>(edit);
            DeleteCommand            = new MvxAsyncCommand <TimeEntryViewModel>(delete);
            ContinueTimeEntryCommand = new MvxAsyncCommand <TimeEntryViewModel>(continueTimeEntry, _ => areContineButtonsEnabled);
        }
Exemple #7
0
        public RatingViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            IRatingService ratingService,
            IFeedbackService feedbackService,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(ratingService, nameof(ratingService));
            Ensure.Argument.IsNotNull(feedbackService, nameof(feedbackService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));

            this.dataSource        = dataSource;
            this.timeService       = timeService;
            this.ratingService     = ratingService;
            this.feedbackService   = feedbackService;
            this.analyticsService  = analyticsService;
            this.onboardingStorage = onboardingStorage;
            this.navigationService = navigationService;

            Impression     = impressionSubject.AsObservable();
            CtaTitle       = Impression.Select(ctaTitle);
            CtaDescription = Impression.Select(ctaDescription);
            CtaButtonTitle = Impression.Select(ctaButtonTitle);
        }
        private void prepareSwipeGesturesOnboarding(IOnboardingStorage storage, IObservable <bool> tapToEditStepIsVisible)
        {
            var timeEntriesCount = ViewModel.TimeEntriesCount;

            var swipeRightCanBeShown =
                UIDevice.CurrentDevice.CheckSystemVersion(11, 0)
                    ? tapToEditStepIsVisible.Select(isVisible => !isVisible)
                    : Observable.Return(false);

            swipeRightStep = new SwipeRightOnboardingStep(swipeRightCanBeShown, timeEntriesCount)
                             .ToDismissable(nameof(SwipeRightOnboardingStep), storage);

            var swipeLeftCanBeShown = Observable.CombineLatest(
                tapToEditStepIsVisible,
                swipeRightStep.ShouldBeVisible,
                (tapToEditIsVisible, swipeRightIsVisble) => !tapToEditIsVisible && !swipeRightIsVisble);

            swipeLeftStep = new SwipeLeftOnboardingStep(swipeLeftCanBeShown, timeEntriesCount)
                            .ToDismissable(nameof(SwipeLeftOnboardingStep), storage);

            swipeLeftStep.DismissByTapping(SwipeLeftBubbleView);
            swipeLeftStep.ManageVisibilityOf(SwipeLeftBubbleView).DisposedBy(disposeBag);
            swipeLeftAnimationDisposable = swipeLeftStep.ManageSwipeActionAnimationOf(firstTimeEntryCell, Direction.Left);

            swipeRightStep.DismissByTapping(SwipeRightBubbleView);
            swipeRightStep.ManageVisibilityOf(SwipeRightBubbleView).DisposedBy(disposeBag);
            swipeRightAnimationDisposable = swipeRightStep.ManageSwipeActionAnimationOf(firstTimeEntryCell, Direction.Right);

            updateSwipeDismissGestures(firstTimeEntryCell);
        }
        protected SelectUserCalendarsViewModelBase(
            IUserPreferences userPreferences,
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            IAnalyticsService analyticsService,
            INavigationService navigationService,
            IRxActionFactory rxActionFactory)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            UserPreferences        = userPreferences;
            this.interactorFactory = interactorFactory;
            OnboardingStorage      = onboardingStorage;
            AnalyticsService       = analyticsService;

            Save           = rxActionFactory.FromAction(Done, doneEnabledSubject.AsObservable());
            SelectCalendar = rxActionFactory.FromAction <SelectableUserCalendarViewModel>(toggleCalendarSelection);

            Calendars = calendarsSubject.AsObservable().DistinctUntilChanged();
        }
Exemple #10
0
        public SignupViewModel(
            IApiFactory apiFactory,
            ILoginManager loginManager,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IApiErrorHandlingService apiErrorHandlingService)
        {
            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(apiErrorHandlingService, nameof(apiErrorHandlingService));

            this.apiFactory              = apiFactory;
            this.loginManager            = loginManager;
            this.analyticsService        = analyticsService;
            this.onboardingStorage       = onboardingStorage;
            this.navigationService       = navigationService;
            this.apiErrorHandlingService = apiErrorHandlingService;

            LoginCommand                    = new MvxAsyncCommand(login);
            GoogleSignupCommand             = new MvxCommand(googleSignup);
            PickCountryCommand              = new MvxAsyncCommand(pickCountry);
            SignupCommand                   = new MvxAsyncCommand(signup, () => SignupEnabled);
            TogglePasswordVisibilityCommand = new MvxCommand(togglePasswordVisibility);
        }
Exemple #11
0
        public MainViewModel(
            IScheduler scheduler,
            ITogglDataSource dataSource,
            ITimeService timeService,
            IUserPreferences userPreferences,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService)
        {
            Ensure.Argument.IsNotNull(scheduler, nameof(scheduler));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));

            this.scheduler         = scheduler;
            this.dataSource        = dataSource;
            this.timeService       = timeService;
            this.userPreferences   = userPreferences;
            this.interactorFactory = interactorFactory;
            this.navigationService = navigationService;
            this.onboardingStorage = onboardingStorage;

            RefreshCommand        = new MvxCommand(refresh);
            OpenReportsCommand    = new MvxAsyncCommand(openReports);
            OpenSettingsCommand   = new MvxAsyncCommand(openSettings);
            EditTimeEntryCommand  = new MvxAsyncCommand(editTimeEntry, () => CurrentTimeEntryId.HasValue);
            StopTimeEntryCommand  = new MvxAsyncCommand(stopTimeEntry, () => isStopButtonEnabled);
            StartTimeEntryCommand = new MvxAsyncCommand(startTimeEntry, () => CurrentTimeEntryId.HasValue == false);
        }
Exemple #12
0
        public LoginViewModel(
            ILoginManager loginManager,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IPasswordManagerService passwordManagerService,
            IApiErrorHandlingService apiErrorHandlingService,
            IAnalyticsService analyticsService)
        {
            Ensure.Argument.IsNotNull(loginManager, nameof(loginManager));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(passwordManagerService, nameof(passwordManagerService));
            Ensure.Argument.IsNotNull(apiErrorHandlingService, nameof(apiErrorHandlingService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));

            this.loginManager            = loginManager;
            this.onboardingStorage       = onboardingStorage;
            this.navigationService       = navigationService;
            this.passwordManagerService  = passwordManagerService;
            this.apiErrorHandlingService = apiErrorHandlingService;
            this.analyticsService        = analyticsService;

            BackCommand                     = new MvxCommand(back);
            NextCommand                     = new MvxCommand(next, () => NextIsEnabled);
            GoogleLoginCommand              = new MvxCommand(googleLogin);
            ForgotPasswordCommand           = new MvxCommand(forgotPassword);
            OpenPrivacyPolicyCommand        = new MvxCommand(openPrivacyPolicyCommand);
            OpenTermsOfServiceCommand       = new MvxCommand(openTermsOfServiceCommand);
            StartPasswordManagerCommand     = new MvxAsyncCommand(startPasswordManager, () => IsPasswordManagerAvailable);
            TogglePasswordVisibilityCommand = new MvxCommand(togglePasswordVisibility);
            ChangeSignUpToLoginCommand      = new MvxCommand(changeSignUpToLogin, () => IsSignUp);
        }
 internal FoundationMvvmCross(
     IApiFactory apiFactory,
     ITogglDatabase database,
     ITimeService timeService,
     IScheduler scheduler,
     IAnalyticsService analyticsService,
     IGoogleService googleService,
     IApplicationShortcutCreator shortcutCreator,
     IBackgroundService backgroundService,
     IOnboardingStorage onboardingStorage,
     IAccessRestrictionStorage accessRestrictionStorage,
     IMvxNavigationService navigationService,
     IApiErrorHandlingService apiErrorHandlingService)
 {
     Database                 = database;
     ApiFactory               = apiFactory;
     TimeService              = timeService;
     Scheduler                = scheduler;
     AnalyticsService         = analyticsService;
     GoogleService            = googleService;
     ShortcutCreator          = shortcutCreator;
     BackgroundService        = backgroundService;
     OnboardingStorage        = onboardingStorage;
     AccessRestrictionStorage = accessRestrictionStorage;
     NavigationService        = navigationService;
     ApiErrorHandlingService  = apiErrorHandlingService;
 }
        public static FoundationMvvmCross RegisterServices(this Foundation self,
                                                           IDialogService dialogService,
                                                           IBrowserService browserService,
                                                           IKeyValueStorage keyValueStorage,
                                                           IAccessRestrictionStorage accessRestrictionStorage,
                                                           IUserPreferences userPreferences,
                                                           IOnboardingStorage onboardingStorage,
                                                           IMvxNavigationService navigationService,
                                                           IPasswordManagerService passwordManagerService = null)
        {
            Ensure.Argument.IsNotNull(self, nameof(self));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(browserService, nameof(browserService));
            Ensure.Argument.IsNotNull(keyValueStorage, nameof(keyValueStorage));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));

            var timeService = self.TimeService;

            var apiErrorHandlingService = new ApiErrorHandlingService(navigationService, accessRestrictionStorage);

            Mvx.RegisterSingleton(self.BackgroundService);
            Mvx.RegisterSingleton(dialogService);
            Mvx.RegisterSingleton(self.Database);
            Mvx.RegisterSingleton(browserService);
            Mvx.RegisterSingleton(self.UserAgent);
            Mvx.RegisterSingleton(self.TimeService);
            Mvx.RegisterSingleton(self.Scheduler);
            Mvx.RegisterSingleton(self.ShortcutCreator);
            Mvx.RegisterSingleton(self.MailService);
            Mvx.RegisterSingleton(self.ShortcutCreator);
            Mvx.RegisterSingleton(self.AnalyticsService);
            Mvx.RegisterSingleton(self.PlatformConstants);
            Mvx.RegisterSingleton(self.Database.IdProvider);
            Mvx.RegisterSingleton(self.SuggestionProviderContainer);
            Mvx.RegisterSingleton(userPreferences);
            Mvx.RegisterSingleton(onboardingStorage);
            Mvx.RegisterSingleton(accessRestrictionStorage);
            Mvx.RegisterSingleton <IApiErrorHandlingService>(apiErrorHandlingService);
            Mvx.RegisterSingleton(passwordManagerService ?? new StubPasswordManagerService());

            Mvx.LazyConstructAndRegisterSingleton <IInteractorFactory, InteractorFactory>();

            return(new FoundationMvvmCross(
                       self.ApiFactory,
                       self.Database,
                       timeService,
                       self.Scheduler,
                       self.AnalyticsService,
                       self.GoogleService,
                       self.ShortcutCreator,
                       self.BackgroundService,
                       onboardingStorage,
                       accessRestrictionStorage,
                       navigationService,
                       apiErrorHandlingService));
        }
        public DisabledConfirmationButtonOnboardingStep(IOnboardingStorage onboardingStorage, IObservable <bool> isDescriptionEmpty)
        {
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(isDescriptionEmpty, nameof(isDescriptionEmpty));

            ShouldBeVisible = onboardingStorage.IsNewUser.CombineLatest(isDescriptionEmpty,
                                                                        (isNewUser, isEmpty) => isNewUser && isEmpty);
        }
Exemple #16
0
        public MainViewModel(
            ITogglDataSource dataSource,
            ITimeService timeService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders,
            ISchedulerProvider schedulerProvider)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            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(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            this.dataSource        = dataSource;
            this.timeService       = timeService;
            this.userPreferences   = userPreferences;
            this.analyticsService  = analyticsService;
            this.interactorFactory = interactorFactory;
            this.navigationService = navigationService;
            this.onboardingStorage = onboardingStorage;
            this.schedulerProvider = schedulerProvider;

            SuggestionsViewModel    = new SuggestionsViewModel(dataSource, interactorFactory, onboardingStorage, suggestionProviders);
            RatingViewModel         = new RatingViewModel(timeService, dataSource, ratingService, analyticsService, onboardingStorage, navigationService, this.schedulerProvider);
            TimeEntriesLogViewModel = new TimeEntriesLogViewModel(timeService, dataSource, interactorFactory, onboardingStorage, analyticsService, navigationService);
            timeEntriesViewModel    = new TimeEntriesViewModel(dataSource, interactorFactory);

            LogEmpty         = timeEntriesViewModel.Empty.AsDriver(this.schedulerProvider);
            TimeEntriesCount = timeEntriesViewModel.Count.AsDriver(this.schedulerProvider);

            ratingViewExperiment = new RatingViewExperiment(timeService, dataSource, onboardingStorage, remoteConfigService);

            RefreshCommand                   = new MvxCommand(Refresh);
            OpenReportsCommand               = new MvxAsyncCommand(openReports);
            OpenSettingsCommand              = new MvxAsyncCommand(openSettings);
            OpenSyncFailuresCommand          = new MvxAsyncCommand(openSyncFailures);
            EditTimeEntryCommand             = new MvxAsyncCommand(editTimeEntry, canExecuteEditTimeEntryCommand);
            StopTimeEntryCommand             = new MvxAsyncCommand(stopTimeEntry, () => isStopButtonEnabled);
            StartTimeEntryCommand            = new MvxAsyncCommand(startTimeEntry, () => CurrentTimeEntryId.HasValue == false);
            AlternativeStartTimeEntryCommand = new MvxAsyncCommand(alternativeStartTimeEntry, () => CurrentTimeEntryId.HasValue == false);

            ContinueTimeEntry = new InputAction <TimeEntryViewModel>(continueTimeEntry);
            DeleteTimeEntry   = new InputAction <TimeEntryViewModel>(deleteTimeEntry);
            SelectTimeEntry   = new InputAction <TimeEntryViewModel>(timeEntrySelected);
            RefreshAction     = new UIAction(refresh);
        }
Exemple #17
0
        public MainViewModel(
            ITogglDataSource dataSource,
            ITimeService timeService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders,
            IIntentDonationService intentDonationService,
            IAccessRestrictionStorage accessRestrictionStorage,
            ISchedulerProvider schedulerProvider,
            IStopwatchProvider stopwatchProvider,
            IRxActionFactory rxActionFactory)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            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(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.dataSource               = dataSource;
            this.userPreferences          = userPreferences;
            this.analyticsService         = analyticsService;
            this.interactorFactory        = interactorFactory;
            this.navigationService        = navigationService;
            this.onboardingStorage        = onboardingStorage;
            this.SchedulerProvider        = schedulerProvider;
            this.intentDonationService    = intentDonationService;
            this.accessRestrictionStorage = accessRestrictionStorage;
            this.stopwatchProvider        = stopwatchProvider;
            this.rxActionFactory          = rxActionFactory;

            TimeService = timeService;

            SuggestionsViewModel = new SuggestionsViewModel(dataSource, interactorFactory, onboardingStorage, suggestionProviders, schedulerProvider, rxActionFactory);
            RatingViewModel      = new RatingViewModel(timeService, dataSource, ratingService, analyticsService, onboardingStorage, navigationService, SchedulerProvider, rxActionFactory);
            TimeEntriesViewModel = new TimeEntriesViewModel(dataSource, interactorFactory, analyticsService, SchedulerProvider, rxActionFactory);

            LogEmpty         = TimeEntriesViewModel.Empty.AsDriver(SchedulerProvider);
            TimeEntriesCount = TimeEntriesViewModel.Count.AsDriver(SchedulerProvider);

            ratingViewExperiment = new RatingViewExperiment(timeService, dataSource, onboardingStorage, remoteConfigService);
        }
 public MockSelectUserCalendarsViewModel(
     IUserPreferences userPreferences,
     IInteractorFactory interactorFactory,
     IOnboardingStorage onboardingStorage,
     IAnalyticsService analyticsService,
     INavigationService navigationService,
     IRxActionFactory rxActionFactory)
     : base(userPreferences, interactorFactory, onboardingStorage, analyticsService, navigationService, rxActionFactory)
 {
 }
Exemple #19
0
        public EditTimeEntryOnboardingStep(IOnboardingStorage onboardingStorage, IObservable <bool> isTimeEntriesLogEmpty)
        {
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(isTimeEntriesLogEmpty, nameof(isTimeEntriesLogEmpty));

            ShouldBeVisible = onboardingStorage.UserSignedUpUsingTheApp.CombineLatest(
                onboardingStorage.HasTappedTimeEntry,
                isTimeEntriesLogEmpty,
                (signedUpUsingTheApp, hasTappedTimeEntry, isEmpty) => signedUpUsingTheApp && !hasTappedTimeEntry && !isEmpty);
        }
        public CategorizeTimeUsingProjectsOnboardingStep(IOnboardingStorage storage, IObservable <bool> hasProjectObservable)
        {
            Ensure.Argument.IsNotNull(storage, nameof(storage));
            Ensure.Argument.IsNotNull(hasProjectObservable, nameof(hasProjectObservable));

            ShouldBeVisible = storage.HasEditedTimeEntry.CombineLatest(
                storage.HasSelectedProject,
                hasProjectObservable,
                (hasEditedTimeEntry, hasSelectedProject, hasProject) => !hasEditedTimeEntry && !hasSelectedProject && !hasProject)
                              .DistinctUntilChanged();
        }
        public DismissableOnboardingStep(IOnboardingStep onboardingStep, string key, IOnboardingStorage storage)
        {
            Ensure.Argument.IsNotNull(onboardingStep, nameof(onboardingStep));
            Ensure.Argument.IsNotNullOrWhiteSpaceString(key, nameof(key));
            Ensure.Argument.IsNotNull(storage, nameof(storage));

            this.onboardingStep = onboardingStep;
            this.storage        = storage;

            Key = key;
        }
Exemple #22
0
        public StopTimeEntryOnboardingStep(IOnboardingStorage onboardingStorage, IObservable <bool> isTimeEntryRunning)
        {
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(isTimeEntryRunning, nameof(isTimeEntryRunning));

            ShouldBeVisible = onboardingStorage.IsNewUser
                              .CombineLatest(
                onboardingStorage.StopButtonWasTappedBefore,
                isTimeEntryRunning,
                (isNewUser, stopButtonWasTapped, isRunning) => isNewUser && !stopButtonWasTapped && isRunning)
                              .DistinctUntilChanged();
        }
        public PasteFromClipboardViewModel(
            IRxActionFactory rxActionFactory,
            IOnboardingStorage onboardingStorage,
            INavigationService navigationService) : base(navigationService)
        {
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.onboardingStorage = onboardingStorage;

            DoNotShowAgain = rxActionFactory.FromAction(doNotShowAgain);
        }
Exemple #24
0
        public EditTimeEntryOnboardingStep(IOnboardingStorage onboardingStorage, IObservable <bool> isTimeEntriesLogEmpty)
        {
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(isTimeEntriesLogEmpty, nameof(isTimeEntriesLogEmpty));

            ShouldBeVisible = onboardingStorage.UserSignedUpUsingTheApp.CombineLatest(
                onboardingStorage.HasTappedTimeEntry,
                onboardingStorage.NavigatedAwayFromMainViewAfterTappingStopButton,
                onboardingStorage.HasTimeEntryBeenContinued,
                isTimeEntriesLogEmpty,
                shouldBeVisible);
        }
        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);
        }
Exemple #26
0
        public MainViewModel(
            ITogglDataSource dataSource,
            ITimeService timeService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IFeedbackService feedbackService,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(ratingService, nameof(ratingService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(feedbackService, nameof(feedbackService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));

            this.dataSource        = dataSource;
            this.timeService       = timeService;
            this.userPreferences   = userPreferences;
            this.analyticsService  = analyticsService;
            this.interactorFactory = interactorFactory;
            this.navigationService = navigationService;
            this.onboardingStorage = onboardingStorage;

            SuggestionsViewModel    = new SuggestionsViewModel(dataSource, interactorFactory, onboardingStorage, suggestionProviders);
            RatingViewModel         = new RatingViewModel(timeService, dataSource, ratingService, feedbackService, analyticsService, onboardingStorage, navigationService);
            TimeEntriesLogViewModel = new TimeEntriesLogViewModel(timeService, dataSource, interactorFactory, onboardingStorage, analyticsService, navigationService);

            ratingViewExperiment = new RatingViewExperiment(timeService, dataSource, onboardingStorage, remoteConfigService);

            RefreshCommand                   = new MvxCommand(refresh);
            OpenReportsCommand               = new MvxAsyncCommand(openReports);
            OpenSettingsCommand              = new MvxAsyncCommand(openSettings);
            OpenSyncFailuresCommand          = new MvxAsyncCommand(openSyncFailures);
            EditTimeEntryCommand             = new MvxAsyncCommand(editTimeEntry, () => CurrentTimeEntryId.HasValue);
            StopTimeEntryCommand             = new MvxAsyncCommand(stopTimeEntry, () => isStopButtonEnabled);
            StartTimeEntryCommand            = new MvxAsyncCommand(startTimeEntry, () => CurrentTimeEntryId.HasValue == false);
            AlternativeStartTimeEntryCommand = new MvxAsyncCommand(alternativeStartTimeEntry, () => CurrentTimeEntryId.HasValue == false);
        }
        public MainTabBarViewModel(
            ITogglDataSource dataSource,
            ITimeService timeService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders,
            IDialogService dialogService,
            ISchedulerProvider schedulerProvider)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            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(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            mainViewModel = new MainViewModel(
                dataSource,
                timeService,
                ratingService,
                userPreferences,
                analyticsService,
                onboardingStorage,
                interactorFactory,
                navigationService,
                remoteConfigService,
                suggestionProviders,
                schedulerProvider);

            reportsViewModel = new ReportsViewModel(
                dataSource,
                timeService,
                navigationService,
                interactorFactory,
                analyticsService,
                dialogService);
        }
Exemple #28
0
        private void prepareSwipeGesturesOnboarding(IOnboardingStorage storage, IObservable <bool> tapToEditStepIsVisible)
        {
            timeEntriesCountSubject.OnNext(ViewModel.TimeEntriesCount);

            timeEntriesCountDisposable = ViewModel.WeakSubscribe(() => ViewModel.TimeEntriesCount, onTimeEntriesCountChanged);

            var swipeRightCanBeShown =
                UIDevice.CurrentDevice.CheckSystemVersion(11, 0)
                    ? tapToEditStepIsVisible.Select(isVisible => !isVisible)
                    : Observable.Return(false);

            swipeRightStep = new SwipeRightOnboardingStep(swipeRightCanBeShown, timeEntriesCountSubject.AsObservable())
                             .ToDismissable(nameof(SwipeRightOnboardingStep), storage);

            var swipeLeftCanBeShown = Observable.CombineLatest(
                tapToEditStepIsVisible,
                swipeRightStep.ShouldBeVisible,
                (tapToEditIsVisible, swipeRightIsVisble) => !tapToEditIsVisible && !swipeRightIsVisble);

            swipeLeftStep = new SwipeLeftOnboardingStep(swipeLeftCanBeShown, timeEntriesCountSubject.AsObservable())
                            .ToDismissable(nameof(SwipeLeftOnboardingStep), storage);

            swipeLeftStep.DismissByTapping(SwipeLeftBubbleView);
            swipeLeftOnboardingDisposable = swipeLeftStep.ManageVisibilityOf(SwipeLeftBubbleView);
            swipeLeftAnimationDisposable  = swipeLeftStep.ManageSwipeActionAnimationOf(firstTimeEntry, Direction.Left);

            swipeRightStep.DismissByTapping(SwipeRightBubbleView);
            swipeRightOnboardingDisposable = swipeRightStep.ManageVisibilityOf(SwipeRightBubbleView);
            swipeRightAnimationDisposable  = swipeRightStep.ManageSwipeActionAnimationOf(firstTimeEntry, Direction.Right);

            swipeToContinueWasUsedDisposable = Observable.FromEventPattern(source, nameof(MainTableViewSource.SwipeToContinueWasUsed))
                                               .VoidSubscribe(() =>
            {
                swipeRightStep.Dismiss();
                swipeToContinueWasUsedDisposable?.Dispose();
                swipeToContinueWasUsedDisposable = null;
            });

            swipeToDeleteWasUsedDisposable = Observable.FromEventPattern(source, nameof(MainTableViewSource.SwipeToDeleteWasUsed))
                                             .VoidSubscribe(() =>
            {
                swipeLeftStep.Dismiss();
                swipeToDeleteWasUsedDisposable?.Dispose();
                swipeToDeleteWasUsedDisposable = null;
            });

            updateSwipeDismissGestures(firstTimeEntry);
        }
Exemple #29
0
        public static IDisposable ManageDismissableTooltip(
            this IOnboardingStep step,
            IObservable <bool> componentIsVisible,
            PopupWindow tooltip,
            View anchor,
            Func <PopupWindow, View, PopupOffsets> popupOffsetsGenerator,
            IOnboardingStorage storage)
        {
            Ensure.Argument.IsNotNull(anchor, nameof(anchor));

            var dismissableStep = step.ToDismissable(step.GetType().FullName, storage);

            dismissableStep.DismissByTapping(tooltip, () => { });

            return(dismissableStep.ManageVisibilityOf(componentIsVisible, tooltip, anchor, popupOffsetsGenerator));
        }
        public AddProjectOrTagOnboardingStep(
            IOnboardingStorage onboardingStorage, ITogglDataSource dataSource)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));

            var hasTagObservable               = dataSource.Tags.GetAll().Select(tags => tags.Any());
            var hasProjectObservable           = dataSource.Projects.GetAll().Select(projects => projects.Any());
            var hasAddedProjectOrTagObservable = onboardingStorage.ProjectOrTagWasAddedBefore;

            ShouldBeVisible = hasAddedProjectOrTagObservable.CombineLatest(
                hasProjectObservable,
                hasTagObservable,
                (hasAddedProjectOrTag, hasProject, hasTag) => (hasProject || hasTag) && !hasAddedProjectOrTag
                );
        }