コード例 #1
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);
        }
コード例 #2
0
        public static UIPanGestureRecognizer DismissBySwiping(this DismissableOnboardingStep step, TimeEntriesLogViewCell cell, Direction direction)
        {
            async void onGesture(UIPanGestureRecognizer recognizer)
            {
                var isOneTouch = recognizer.NumberOfTouches == 1;
                var isVisible  = await step.ShouldBeVisible.FirstAsync();

                var isInDesiredDirection = Sign(recognizer.VelocityInView(cell).X) == Sign((int)direction);

                if (isOneTouch && isVisible && isInDesiredDirection)
                {
                    step.Dismiss();
                }
            }

            var panGestureRecognizer = new UIPanGestureRecognizer(onGesture)
            {
                ShouldRecognizeSimultaneously = (a, b) => true
            };

            IDisposable visibilityDisposable = null;

            visibilityDisposable = step.ShouldBeVisible
                                   .Where(visible => visible == false)
                                   .ObserveOn(SynchronizationContext.Current)
                                   .Subscribe(_ =>
            {
                cell.RemoveGestureRecognizer(panGestureRecognizer);
                visibilityDisposable?.Dispose();
            });

            cell.AddGestureRecognizer(panGestureRecognizer);

            return(panGestureRecognizer);
        }
コード例 #3
0
ファイル: MainViewController.cs プロジェクト: l0gaw/mobileapp
        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);
        }
コード例 #4
0
        private void setupSwipeLeftOnboardingStep()
        {
            var shouldBeVisible = Observable.CombineLatest(
                editTimeEntryOnboardingStep.ShouldBeVisible,
                swipeRightOnboardingStep.ShouldBeVisible,
                (editTimeEntryVisible, swipeRightVisible) => !editTimeEntryVisible && !swipeRightVisible
                );

            var showSwipeLeftOnboardingStep = Observable.CombineLatest(
                shouldBeVisible,
                mainRecyclerViewChangesObservable,
                ViewModel.SyncProgressState,
                (shouldShowStep, unit, syncState) => shouldShowStep && syncState == SyncProgress.Synced);

            swipeLeftPopup = PopupWindowFactory.PopupWindowWithText(
                Context,
                Resource.Layout.TooltipWithRightTopArrow,
                Resource.Id.TooltipText,
                Resource.String.OnboardingSwipeLeft);

            swipeLeftOnboardingStep = new SwipeLeftOnboardingStep(shouldBeVisible, timeEntriesCountSubject.AsObservable())
                                      .ToDismissable(nameof(SwipeLeftOnboardingStep), ViewModel.OnboardingStorage);

            swipeLeftOnboardingStep.DismissByTapping(swipeLeftPopup, () =>
            {
                if (swipeLeftOnboardingAnimationStepDisposable != null)
                {
                    swipeLeftOnboardingAnimationStepDisposable.Dispose();
                    swipeLeftOnboardingAnimationStepDisposable = null;
                }
            });

            swipeToDeleteWasUsedDisposable = mainRecyclerAdapter.DeleteTimeEntrySubject
                                             .Subscribe(_ =>
            {
                swipeLeftOnboardingStep.Dismiss();
                swipeToDeleteWasUsedDisposable.Dispose();
                swipeToDeleteWasUsedDisposable = null;
            });

            showSwipeLeftOnboardingStep
            .Where(shouldShowStep => shouldShowStep)
            .Select(_ => findEarliestTimeEntryView())
            .DistinctUntilChanged()
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(updateSwipeLeftOnboardingStep)
            .DisposedBy(DisposeBag);
        }
コード例 #5
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);
        }
コード例 #6
0
        private void prepareOnboarding()
        {
            var storage = ViewModel.OnboardingStorage;

            var timelineIsEmpty = ViewModel.LogEmpty;

            new StartTimeEntryOnboardingStep(storage)
            .ManageDismissableTooltip(StartTimeEntryOnboardingBubbleView, storage)
            .DisposedBy(disposeBag);

            new StopTimeEntryOnboardingStep(storage, ViewModel.IsTimeEntryRunning)
            .ManageDismissableTooltip(StopTimeEntryOnboardingBubbleView, storage)
            .DisposedBy(disposeBag);

            tapToEditStep = new EditTimeEntryOnboardingStep(storage, timelineIsEmpty)
                            .ToDismissable(nameof(EditTimeEntryOnboardingStep), storage);

            tapToEditStep.DismissByTapping(TapToEditBubbleView);
            tapToEditStep.ManageVisibilityOf(TapToEditBubbleView).DisposedBy(disposeBag);
        }
コード例 #7
0
        private void prepareOnboarding()
        {
            var storage = ViewModel.OnboardingStorage;

            isRunningSubject.OnNext(ViewModel.CurrentTimeEntryId.HasValue);
            isEmptySubject.OnNext(ViewModel.IsLogEmpty);

            isEmptyDisposable = ViewModel.WeakSubscribe(() => ViewModel.IsLogEmpty, onEmptyChanged);

            startButtonOnboardingDisposable = new StartTimeEntryOnboardingStep(storage)
                                              .ManageDismissableTooltip(StartTimeEntryOnboardingBubbleView, storage);

            stopButtonOnboardingDisposable = new StopTimeEntryOnboardingStep(storage, isRunningSubject.AsObservable())
                                             .ManageDismissableTooltip(StopTimeEntryOnboardingBubbleView, storage);

            tapToEditStep = new EditTimeEntryOnboardingStep(storage, isEmptySubject.AsObservable())
                            .ToDismissable(nameof(EditTimeEntryOnboardingStep), storage);

            tapToEditStep.DismissByTapping(TapToEditBubbleView);
            tapToEditDisposable = tapToEditStep.ManageVisibilityOf(TapToEditBubbleView);

            prepareSwipeGesturesOnboarding(storage, tapToEditStep.ShouldBeVisible);

            scrollDisposable = tapToEditStep.ShouldBeVisible
                               .CombineLatest(
                swipeLeftStep.ShouldBeVisible,
                swipeRightStep.ShouldBeVisible,
                (tapToEdit, swipeLeft, swipeRight) => tapToEdit || swipeLeft || swipeRight)
                               .ObserveOn(SynchronizationContext.Current)
                               .Subscribe(onScrollableTooltipsVisibilityChanged);

            firstTimeEntryDisposable = source.FirstTimeEntry
                                       .Where(nextFirstTimeEntry => nextFirstTimeEntry != firstTimeEntry)
                                       .ObserveOn(SynchronizationContext.Current)
                                       .Subscribe(onFirstTimeEntryChanged);

            ViewModel.NavigationService.AfterNavigate += onNavigate;
        }
コード例 #8
0
ファイル: MainViewController.cs プロジェクト: xleon/mobileapp
        private void prepareOnboarding()
        {
            var storage = ViewModel.OnboardingStorage;

            var timelineIsEmpty = Observable.CombineLatest(
                tableViewSource.FirstCell.Select(cell => cell == null),
                ViewModel.LogEmpty,
                CommonFunctions.Or);

            new StartTimeEntryOnboardingStep(storage)
            .ManageDismissableTooltip(StartTimeEntryOnboardingBubbleView, storage)
            .DisposedBy(disposeBag);

            new StopTimeEntryOnboardingStep(storage, ViewModel.IsTimeEntryRunning)
            .ManageDismissableTooltip(StopTimeEntryOnboardingBubbleView, storage)
            .DisposedBy(disposeBag);

            tapToEditStep = new EditTimeEntryOnboardingStep(storage, timelineIsEmpty)
                            .ToDismissable(nameof(EditTimeEntryOnboardingStep), storage);

            tapToEditStep.DismissByTapping(TapToEditBubbleView);
            tapToEditStep.ManageVisibilityOf(TapToEditBubbleView).DisposedBy(disposeBag);
        }
コード例 #9
0
ファイル: MainViewController.cs プロジェクト: l0gaw/mobileapp
        private void prepareOnboarding()
        {
            var storage = ViewModel.OnboardingStorage;

            var timelineIsEmpty = ViewModel.LogEmpty;

            new StartTimeEntryOnboardingStep(storage)
            .ManageDismissableTooltip(StartTimeEntryOnboardingBubbleView, storage)
            .DisposedBy(disposeBag);

            new StopTimeEntryOnboardingStep(storage, ViewModel.IsTimeEntryRunning)
            .ManageDismissableTooltip(StopTimeEntryOnboardingBubbleView, storage)
            .DisposedBy(disposeBag);

            tapToEditStep = new EditTimeEntryOnboardingStep(storage, timelineIsEmpty)
                            .ToDismissable(nameof(EditTimeEntryOnboardingStep), storage);

            tapToEditStep.DismissByTapping(TapToEditBubbleView);
            tapToEditStep.ManageVisibilityOf(TapToEditBubbleView).DisposedBy(disposeBag);

            prepareSwipeGesturesOnboarding(storage, tapToEditStep.ShouldBeVisible);

            ViewModel.NavigationService.AfterNavigate += onNavigate;
        }
コード例 #10
0
 protected void PrepareDismissableStep()
 => DismissableStep = new DismissableOnboardingStep(
     OnboardingStep, Key, OnboardingStorage);
コード例 #11
0
 public DismissableOnboardingStepTest()
 {
     DismissableStep = new DismissableOnboardingStep(
         OnboardingStep, Key, OnboardingStorage
         );
 }