示例#1
0
        public void ShowBar(Action flashBarCallback, bool immediate = false, string withMessage = null, int withMessageId = -1)
        {
            if (withMessage != null)
            {
                this.message     = withMessage;
                messageView.Text = message;
            }
            if (withMessageId != -1)
            {
                this.message     = barView.Resources.GetString(withMessageId);
                messageView.Text = message;
            }

            this.flashBarCallback = flashBarCallback;
            hideHandler.RemoveCallbacks(hideRunnable);
            hideHandler.PostDelayed(hideRunnable, DefaultHideTime);

            barView.Visibility = ViewStates.Visible;
            if (immediate)
            {
                barView.Alpha = 1;
            }
            else
            {
                barAnimator.Cancel();
                barAnimator.Alpha(1);
                barAnimator.SetDuration(barView.Resources.GetInteger(Android.Resource.Integer.ConfigShortAnimTime));
                barAnimator.SetListener(null);
            }
        }
示例#2
0
        public void ShowUndoBar(bool immediate, string message, object undoToken)
        {
            mUndoToken        = undoToken;
            mUndoMessage      = message;
            mMessageView.Text = mUndoMessage;


            mBarView.Visibility = ViewStates.Visible;
            if (immediate)
            {
                mBarView.Alpha = 1;
            }
            else
            {
                mBarAnimator.Cancel();
                mBarAnimator
                .Alpha(1)
                .SetDuration(mBarView.Resources.GetInteger(Android.Resource.Integer.ConfigShortAnimTime))
                .SetListener(null);
            }

            t          = new System.Timers.Timer(mBarView.Resources.GetInteger(Resource.Integer.undobar_hide_delay));
            t.Elapsed += HandleTimeoutElapsed;
            t.Start();
        }
示例#3
0
            public void ShowBar(string message)
            {
                messageView.Text = message;

                barView.Visibility = ViewStates.Visible;

                barAnimator.Cancel();
                barAnimator.Alpha(1);
                barAnimator.SetDuration(300);
                barAnimator.SetListener(null);
            }
示例#4
0
        Task <bool> SwitchContentAsync(Page view, bool animated, bool removed = false)
        {
            Context.HideKeyboard(this);

            IVisualElementRenderer rendererToAdd = Platform.GetRenderer(view);
            bool existing = rendererToAdd != null;

            if (!existing)
            {
                Platform.SetRenderer(view, rendererToAdd = Platform.CreateRenderer(view));
            }

            Page pageToRemove = _current;
            IVisualElementRenderer rendererToRemove  = pageToRemove == null ? null : Platform.GetRenderer(pageToRemove);
            PageContainer          containerToRemove = rendererToRemove == null ? null : (PageContainer)rendererToRemove.ViewGroup.Parent;
            PageContainer          containerToAdd    = (PageContainer)rendererToAdd.ViewGroup.Parent ?? new PageContainer(Context, rendererToAdd);

            containerToAdd.SetWindowBackground();

            _current = view;

            ((Platform)Element.Platform).NavAnimationInProgress = true;

            var tcs = new TaskCompletionSource <bool>();

            if (animated)
            {
                if (s_currentAnimation != null)
                {
                    s_currentAnimation.Cancel();
                }

                if (removed)
                {
                    // animate out
                    if (containerToAdd.Parent != this)
                    {
                        AddView(containerToAdd, Element.LogicalChildren.IndexOf(rendererToAdd.Element));
                    }
                    else
                    {
                        ((Page)rendererToAdd.Element).SendAppearing();
                    }
                    containerToAdd.Visibility = ViewStates.Visible;

                    if (containerToRemove != null)
                    {
                        Action <AndroidAnimation.Animator> done = a =>
                        {
                            containerToRemove.Visibility = ViewStates.Gone;
                            containerToRemove.Alpha      = 1;
                            containerToRemove.ScaleX     = 1;
                            containerToRemove.ScaleY     = 1;
                            RemoveView(containerToRemove);

                            tcs.TrySetResult(true);
                            ((Platform)Element.Platform).NavAnimationInProgress = false;

                            VisualElement removedElement = rendererToRemove.Element;
                            rendererToRemove.Dispose();
                            if (removedElement != null)
                            {
                                Platform.SetRenderer(removedElement, null);
                            }
                        };

                        // should always happen
                        s_currentAnimation = containerToRemove.Animate().Alpha(0).ScaleX(0.8f).ScaleY(0.8f).SetDuration(250).SetListener(new GenericAnimatorListener {
                            OnEnd = a =>
                            {
                                s_currentAnimation = null;
                                done(a);
                            },
                            OnCancel = done
                        });
                    }
                }
                else
                {
                    bool containerAlreadyAdded = containerToAdd.Parent == this;
                    // animate in
                    if (!containerAlreadyAdded)
                    {
                        AddView(containerToAdd);
                    }
                    else
                    {
                        ((Page)rendererToAdd.Element).SendAppearing();
                    }

                    if (existing)
                    {
                        Element.ForceLayout();
                    }

                    containerToAdd.Alpha      = 0;
                    containerToAdd.ScaleX     = containerToAdd.ScaleY = 0.8f;
                    containerToAdd.Visibility = ViewStates.Visible;
                    s_currentAnimation        = containerToAdd.Animate().Alpha(1).ScaleX(1).ScaleY(1).SetDuration(250).SetListener(new GenericAnimatorListener {
                        OnEnd = a =>
                        {
                            if (containerToRemove != null && containerToRemove.Handle != IntPtr.Zero)
                            {
                                containerToRemove.Visibility = ViewStates.Gone;
                                if (pageToRemove != null)
                                {
                                    pageToRemove.SendDisappearing();
                                }
                            }
                            s_currentAnimation = null;
                            tcs.TrySetResult(true);
                            ((Platform)Element.Platform).NavAnimationInProgress = false;
                        }
                    });
                }
            }
            else
            {
                // just do it fast
                if (containerToRemove != null)
                {
                    if (removed)
                    {
                        RemoveView(containerToRemove);
                    }
                    else
                    {
                        containerToRemove.Visibility = ViewStates.Gone;
                    }
                }

                if (containerToAdd.Parent != this)
                {
                    AddView(containerToAdd);
                }
                else
                {
                    ((Page)rendererToAdd.Element).SendAppearing();
                }

                if (containerToRemove != null && !removed)
                {
                    pageToRemove.SendDisappearing();
                }

                if (existing)
                {
                    Element.ForceLayout();
                }

                containerToAdd.Visibility = ViewStates.Visible;
                tcs.SetResult(true);
                ((Platform)Element.Platform).NavAnimationInProgress = false;
            }

            return(tcs.Task);
        }