Пример #1
0
        /// <summary>
        /// Cloned in CoreTableSource
        /// </summary>
        public virtual void AnimateTabBar(bool?show, bool suspendTrackingDuringAnimation = false, bool force = false)
        {
            CoreUtility.ExecuteMethod("AnimateTabBar", delegate()
            {
                if (this.AutoHideControllerInstance != null)
                {
                    if (!this.AutoHideControllerInstance.IsControllerVisible)
                    {
                        return;
                    }
                }
                if (!force && (this.SuspendTabBarTracking || this.DisableTabBarTracking))
                {
                    return;
                }
                UITabBar tabBar = this.AutoHideTabBarController.TabBar;

                if (!OriginalTabBarFrame.HasValue)
                {
                    OriginalTabBarFrame = tabBar.Frame;
                }

                tabBar.Layer.RemoveAnimation(DRAG_ANIMATION_NAME);

                if (show.HasValue)
                {
                    if (suspendTrackingDuringAnimation)
                    {
                        this.SuspendTabBarTracking = true;
                    }
                    CATransaction.Begin();
                    CATransaction.CompletionBlock = new Action(delegate()
                    {
                        if (suspendTrackingDuringAnimation) // only ours
                        {
                            this.SuspendTabBarTracking = false;
                        }
                        this.BeginInvokeOnMainThread(delegate()
                        {
                            CoreUtility.ExecuteMethod("DraggingStarted.CompletionBlock", delegate()
                            {
                                if (AutoHideTabBarShouldBeHidden)
                                {
                                    tabBar.Frame = new CGRect(tabBar.Frame.X, this.AutoHideTabBarController.View.Frame.Height, tabBar.Frame.Width, tabBar.Frame.Height);
                                }
                                else
                                {
                                    tabBar.Frame = OriginalTabBarFrame.GetValueOrDefault();
                                }
                                tabBar.Layer.RemoveAnimation(DRAG_ANIMATION_NAME);
                            });
                        });
                    });


                    if (!show.Value)
                    {
                        // content going up
                        AutoHideTabBarShouldBeHidden = true;

                        AnimationBuilder
                        .Begin(tabBar.Layer, DRAG_ANIMATION_NAME)
                        .MoveTo(new CGPoint(tabBar.Layer.Frame.X, this.AutoHideTabBarController.View.Frame.Height), 0f, 0.3f)
                        .Commit();
                    }
                    else if (show.Value)
                    {
                        // content going down
                        AutoHideTabBarShouldBeHidden = false;

                        AnimationBuilder
                        .Begin(tabBar.Layer, DRAG_ANIMATION_NAME)
                        .MoveTo(OriginalTabBarFrame.Value.Location, 0f, 0.3f)
                        .Commit();
                    }

                    CATransaction.Commit();
                }
            });
        }