예제 #1
0
        public static IDisposable ManageVisibilityOf(
            this IOnboardingStep step,
            IObservable <bool> componentIsVisible,
            PopupWindow tooltip,
            View anchor,
            Func <PopupWindow, View, PopupOffsets> popupOffsetsGenerator)
        {
            Ensure.Argument.IsNotNull(anchor, nameof(anchor));

            void toggleVisibilityOnMainThread(bool shouldBeVisible)
            {
                if (shouldBeVisible)
                {
                    showPopupTooltip(tooltip, anchor, popupOffsetsGenerator);
                }
                else
                {
                    tooltip?.Dismiss();
                }
            }

            return(step.ShouldBeVisible
                   .CombineLatest(componentIsVisible, CommonFunctions.And)
                   .ObserveOn(AndroidDependencyContainer.Instance.SchedulerProvider.MainScheduler)
                   .combineWithWindowTokenAvailabilityFrom(anchor)
                   .Subscribe(toggleVisibilityOnMainThread));
        }
        public static IDisposable ManageDismissableTooltip(this IOnboardingStep step, UIView tooltip, IOnboardingStorage storage)
        {
            var dismissableStep = step.ToDismissable(step.GetType().FullName, storage);

            dismissableStep.DismissByTapping(tooltip);
            return(dismissableStep.ManageVisibilityOf(tooltip));
        }
        public static IDisposable ManageVisibilityOf(this IOnboardingStep step, UIView view)
        {
            view.Hidden = true;

            void toggleVisibilityOnMainThread(bool shouldBeVisible)
            {
                UIApplication.SharedApplication.InvokeOnMainThread(
                    () => toggleVisibility(shouldBeVisible));
            }

            void toggleVisibility(bool shouldBeVisible)
            {
                var isVisible = view.Hidden == false;

                if (isVisible == shouldBeVisible)
                {
                    return;
                }

                if (shouldBeVisible)
                {
                    view.Hidden    = false;
                    view.Alpha     = 0;
                    view.Transform = CGAffineTransform.MakeScale(0.01f, 0.01f);
                    AnimationExtensions.Animate(
                        Animation.Timings.LeaveTiming,
                        Animation.Curves.Bounce,
                        () =>
                    {
                        view.Alpha     = 1;
                        view.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    },
                        () =>
                    {
                        isVisible = true;
                    });
                }
                else
                {
                    view.Alpha     = 1;
                    view.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    AnimationExtensions.Animate(
                        Animation.Timings.LeaveTiming,
                        Animation.Curves.Bounce,
                        () =>
                    {
                        view.Alpha     = 0;
                        view.Transform = CGAffineTransform.MakeScale(0.01f, 0.01f);
                    },
                        () =>
                    {
                        view.Hidden = true;
                        isVisible   = false;
                    });
                }
            }

            return(step.ShouldBeVisible.Subscribe(toggleVisibilityOnMainThread));
        }
예제 #4
0
        public static IDisposable ManageDismissableTooltip(this IOnboardingStep step, PopupWindow tooltip, View anchor, Func <PopupWindow, View, PopupOffsets> popupOffsetsGenerator, IOnboardingStorage storage)
        {
            Ensure.Argument.IsNotNull(tooltip, nameof(tooltip));
            Ensure.Argument.IsNotNull(anchor, nameof(anchor));

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

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

            return(dismissableStep.ManageVisibilityOf(tooltip, anchor, popupOffsetsGenerator));
        }
        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;
        }
예제 #6
0
        public static IDisposable ManageDismissableTooltip(this IOnboardingStep step, PopupWindow tooltip, View anchor, Func <PopupWindow, View, PopupOffsets> popupOffsetsGenerator, IOnboardingStorage storage)
        {
            Ensure.Argument.IsNotNull(anchor, nameof(tooltip));
            Ensure.Argument.IsNotNull(anchor, nameof(anchor));

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

            void OnDismiss(object sender, EventArgs args)
            {
                tooltip.Dismiss();
                dismissableStep.Dismiss();
            }

            tooltip.ContentView.Click += OnDismiss;

            return(dismissableStep.ManageVisibilityOf(tooltip, anchor, popupOffsetsGenerator));
        }
예제 #7
0
        private static IDisposable ManageVisibilityOf(this IOnboardingStep step, PopupWindow popupWindowTooltip, View anchor, Func <PopupWindow, View, PopupOffsets> popupOffsetsGenerator)
        {
            void toggleVisibilityOnMainThread(bool shouldBeVisible)
            {
                if (shouldBeVisible)
                {
                    showPopupTooltip(popupWindowTooltip, anchor, popupOffsetsGenerator);
                }
                else
                {
                    popupWindowTooltip.Dismiss();
                }
            }

            return(step.ShouldBeVisible
                   .combineWithWindowTokenAvailabilityFrom(anchor)
                   .Subscribe(toggleVisibilityOnMainThread));
        }
        public DismissableOnboardingStep(IOnboardingStep onboardingStep, string key, IOnboardingStorage onboardingStorage)
        {
            Ensure.Argument.IsNotNull(onboardingStep, nameof(onboardingStep));
            Ensure.Argument.IsNotNullOrWhiteSpaceString(key, nameof(key));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));

            this.onboardingStorage = onboardingStorage;

            Key = key;

            wasDismissedSubject = new BehaviorSubject <bool>(
                onboardingStorage.WasDismissed(this)
                );

            ShouldBeVisible = onboardingStep
                              .ShouldBeVisible
                              .CombineLatest(
                wasDismissedSubject.AsObservable(),
                (shouldBeVisible, wasDismissed) => shouldBeVisible && !wasDismissed);
        }
예제 #9
0
        public static IDisposable ManageVisibilityOf(this IOnboardingStep step, PopupWindow tooltip, View anchor, Func <PopupWindow, View, PopupOffsets> popupOffsetsGenerator)
        {
            Ensure.Argument.IsNotNull(tooltip, nameof(tooltip));
            Ensure.Argument.IsNotNull(anchor, nameof(anchor));

            void toggleVisibilityOnMainThread(bool shouldBeVisible)
            {
                if (shouldBeVisible)
                {
                    showPopupTooltip(tooltip, anchor, popupOffsetsGenerator);
                }
                else
                {
                    tooltip.Dismiss();
                }
            }

            return(step.ShouldBeVisible
                   .ObserveOn(SynchronizationContext.Current)
                   .combineWithWindowTokenAvailabilityFrom(anchor)
                   .Subscribe(toggleVisibilityOnMainThread));
        }
        public static IDisposable ManageSwipeActionAnimationOf(this IOnboardingStep step, TimeEntriesLogViewCell cell, Direction direction)
        {
            IDisposable animation = null;

            void toggleVisibility(bool shouldBeVisible)
            {
                var isVisible = animation != null;

                if (isVisible == shouldBeVisible)
                {
                    return;
                }

                if (shouldBeVisible)
                {
                    animation = cell.RevealSwipeActionAnimation(direction);
                }
                else
                {
                    cell.Layer.RemoveAnimation(direction.ToString());
                    animation?.Dispose();
                    animation = null;
                }
            }

            var subscriptionDisposable = step.ShouldBeVisible.Subscribe(toggleVisibility);

            return(Disposable.Create(() =>
            {
                cell?.Layer.RemoveAllAnimations();

                animation?.Dispose();
                animation = null;

                subscriptionDisposable?.Dispose();
                subscriptionDisposable = null;
            }));
        }
예제 #11
0
        public static IDisposable ManageSwipeActionAnimationOf(this IOnboardingStep step, RecyclerView recyclerView, MainLogCellViewHolder viewHolder, AnimationSide side)
        {
            Ensure.Argument.IsNotNull(viewHolder, nameof(viewHolder));

            void toggleVisibilityOnMainThread(bool shouldBeVisible)
            {
                if (shouldBeVisible && !viewHolder.IsAnimating)
                {
                    viewHolder.StartAnimating(side);
                    recyclerView.ScrollBy(0, 1);
                }
            }

            var subscriptionDisposable = step.ShouldBeVisible
                                         .ObserveOn(SynchronizationContext.Current)
                                         .Subscribe(toggleVisibilityOnMainThread);

            return(Disposable.Create(() =>
            {
                viewHolder.StopAnimating();
                subscriptionDisposable?.Dispose();
                subscriptionDisposable = null;
            }));
        }
 public static DismissableOnboardingStep ToDismissable(this IOnboardingStep step, string key, IOnboardingStorage onboardingStorage)
 => new DismissableOnboardingStep(step, key, onboardingStorage);