Ejemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && !this.disposed)
            {
                this.disposed = true;

                this.RemoveAllViews();

                foreach (Page pageToRemove in this.Element.Children)
                {
                    IVisualElementRenderer pageRenderer = Platform.GetRenderer(pageToRemove);

                    if (pageRenderer != null)
                    {
                        pageRenderer.ViewGroup.RemoveFromParent();
                        pageRenderer.Dispose();
                    }
                }

                if (this.bottomBar != null)
                {
                    this.bottomBar.SetOnTabClickListener(null);
                    this.bottomBar.Dispose();
                    this.bottomBar = null;
                }

                if (this.frameLayout != null)
                {
                    this.frameLayout.Dispose();
                    this.frameLayout = null;
                }
            }

            base.Dispose(disposing);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                BottomBarPage bottomBarPage = e.NewElement;

                if (_bottomBar == null)
                {
                    _pageController = PageController.Create(bottomBarPage);

                    // create a view which will act as container for Page's
                    _frameLayout = new FrameLayout(Forms.Context);
                    _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill);
                    AddView(_frameLayout, 0);

                    // create bottomBar control
                    _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null);
                    _bottomBar.NoTabletGoodness();
                    _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    _bottomBar.SetOnTabClickListener(this);

                    UpdateTabs();
                    UpdateBarBackgroundColor();
                    UpdateBarTextColor();
                }

                if (bottomBarPage.CurrentPage != null)
                {
                    SwitchContent(bottomBarPage.CurrentPage);
                }
            }
        }
Ejemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && !this._disposed)
     {
         this._disposed = true;
         this.RemoveAllViews();
         foreach (VisualElement child in (IEnumerable <Page>) this.Element.Children)
         {
             IVisualElementRenderer renderer = Xamarin.Forms.Platform.Android.Platform.GetRenderer(child);
             if (renderer != null)
             {
                 renderer.ViewGroup.RemoveFromParent();
                 renderer.Dispose();
             }
         }
         if (this._bottomBar != null)
         {
             this._bottomBar.SetOnTabClickListener((IOnTabClickListener)null);
             this._bottomBar.Dispose();
             this._bottomBar = (BottomNavigationBar.BottomBar)null;
         }
         if (this._frameLayout != null)
         {
             this._frameLayout.Dispose();
             this._frameLayout = (FrameLayout)null;
         }
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 4
0
        protected override void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                BottomBarPage bottomBarPage = e.NewElement;

                if (_bottomBar == null)
                {
                    _pageController = PageController.Create(bottomBarPage);

                    // create a view which will act as container for Page's
#pragma warning disable CS0618  // Type or member is obsolete
#pragma warning disable IDE0017 // Simplify object initialization
                    _frameLayout = new FrameLayout(Forms.Context);
#pragma warning restore IDE0017 // Simplify object initialization
#pragma warning restore CS0618  // Type or member is obsolete
                    _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill);
                    AddView(_frameLayout, 0);

                    // create bottomBar control
                    _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null);
                    _bottomBar.NoTabletGoodness();
                    if (bottomBarPage.FixedMode)
                    {
                        _bottomBar.UseFixedMode();
                    }

                    switch (bottomBarPage.BarTheme)
                    {
                    case BottomBarPage.BarThemeTypes.Light:
                        break;

                    case BottomBarPage.BarThemeTypes.DarkWithAlpha:
                        _bottomBar.UseDarkThemeWithAlpha(true);
                        break;

                    case BottomBarPage.BarThemeTypes.DarkWithoutAlpha:
                        _bottomBar.UseDarkThemeWithAlpha(false);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    _bottomBar.SetOnTabClickListener(this);

                    UpdateTabs();
                    UpdateBarBackgroundColor();
                    UpdateBarTextColor();
                }

                if (bottomBarPage.CurrentPage != null)
                {
                    SwitchContent(bottomBarPage.CurrentPage);
                }
            }
        }
Ejemplo n.º 5
0
        protected override void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                BottomBarPage bottomBarPage = e.NewElement;

                if (this.bottomBar == null)
                {
                    this.pageController = PageController.Create(bottomBarPage);

                    // create a view which will act as container for Page's
                    this.frameLayout = new FrameLayout(Forms.Context)
                    {
                        LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill)
                    };
                    this.AddView(this.frameLayout, 0);

                    // create bottomBar control
                    this.bottomBar = BottomNavigationBar.BottomBar.Attach(this.frameLayout, null);
                    this.bottomBar.NoTabletGoodness();
                    if (bottomBarPage.FixedMode)
                    {
                        this.bottomBar.UseFixedMode();
                    }

                    switch (bottomBarPage.BarTheme)
                    {
                    case BottomBarPage.BarThemeTypes.Light:
                        break;

                    case BottomBarPage.BarThemeTypes.DarkWithAlpha:
                        this.bottomBar.UseDarkThemeWithAlpha(true);
                        break;

                    case BottomBarPage.BarThemeTypes.DarkWithoutAlpha:
                        this.bottomBar.UseDarkThemeWithAlpha(false);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    this.bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    this.bottomBar.SetOnTabClickListener(this);

                    this.UpdateTabs();
                    this.UpdateBarBackgroundColor();
                    this.UpdateBarTextColor();
                }

                if (bottomBarPage.CurrentPage != null)
                {
                    this.SwitchContent(bottomBarPage.CurrentPage);
                }
            }
        }
Ejemplo n.º 6
0
        protected override void OnElementChanged(ElementChangedEventArgs <HomePage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                HomePage bottomBarPage = e.NewElement;

                if (_bottomBar == null)
                {
                    _pageController = PageController.Create(bottomBarPage);

                    _frameLayout = new FrameLayout(MainActivity.ApplicationContext)
                    {
                        LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent,
                                                                        LayoutParams.MatchParent, GravityFlags.Fill)
                    };
                    AddView(_frameLayout, 0);

                    _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null);
                    _bottomBar.NoTopOffset();
                    _bottomBar.NoTabletGoodness();

                    if (bottomBarPage.FixedMode)
                    {
                        _bottomBar.UseFixedMode();
                    }

                    switch (bottomBarPage.BarTheme)
                    {
                    case BarThemeTypes.Light:
                        break;

                    case BarThemeTypes.DarkWithAlpha:
                        _bottomBar.UseDarkThemeWithAlpha(true);
                        break;

                    case BarThemeTypes.DarkWithoutAlpha:
                        _bottomBar.UseDarkThemeWithAlpha(false);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    _bottomBar.SetOnTabClickListener(this);

                    UpdateTabs();
                    UpdateBarBackgroundColor();
                    UpdateBarTextColor();
                }

                if (bottomBarPage.CurrentPage != null)
                {
                    SwitchContent(bottomBarPage.CurrentPage);
                }
            }
        }
Ejemplo n.º 7
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;

                RemoveAllViews();

                foreach (Page pageToRemove in Element.Children)
                {
                    IVisualElementRenderer pageRenderer = Platform.GetRenderer(pageToRemove);

                    if (pageRenderer != null)
                    {
                        pageRenderer.View.RemoveFromParent();
                        try
                        {
                            pageRenderer.Dispose();
                        }
                        catch (Exception ex)
                        {
                            ;
                        }
                    }

                    pageToRemove.PropertyChanged -= OnPagePropertyChanged;
                    // pageToRemove.ClearValue (Platform.RendererProperty);
                }

                if (_badges != null)
                {
                    _badges.Clear();
                    _badges = null;
                }

                if (_bottomBar != null)
                {
                    _bottomBar.SetOnTabClickListener(null);
                    _bottomBar.Dispose();
                    _bottomBar = null;
                }

                if (_frameLayout != null)
                {
                    _frameLayout.Dispose();
                    _frameLayout = null;
                }

                /*if (Element != null) {
                 *      PageController.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
                 * }*/
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 8
0
        protected override void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement == null)
            {
                return;
            }
            BottomBarPage newElement = e.NewElement;

            if (this._bottomBar == null)
            {
                this._pageController = PageController.Create((Page)newElement);
                this._frameLayout    = new FrameLayout(Xamarin.Forms.Forms.Context)
                {
                    LayoutParameters = (ViewGroup.LayoutParams) new FrameLayout.LayoutParams(-1, -1, GravityFlags.Fill)
                };
                this.AddView((Android.Views.View) this._frameLayout, 0);
                this._bottomBar = BottomNavigationBar.BottomBar.Attach((Android.Views.View) this._frameLayout, (Bundle)null);
                this._bottomBar.NoTabletGoodness();
                if (newElement.FixedMode)
                {
                    this._bottomBar.UseFixedMode();
                }
                switch (newElement.BarTheme)
                {
                case BottomBarPage.BarThemeTypes.Light:
                    this._bottomBar.LayoutParameters = new ViewGroup.LayoutParams(-1, -1);
                    this._bottomBar.SetOnTabClickListener((IOnTabClickListener)this);
                    this.UpdateTabs();
                    this.UpdateBarBackgroundColor();
                    this.UpdateBarTextColor();
                    _bottomBar.SelectTabAtPosition(Element.Children.IndexOf(Element.CurrentPage), true);
                    break;

                case BottomBarPage.BarThemeTypes.DarkWithAlpha:
                    this._bottomBar.UseDarkThemeWithAlpha(true);
                    goto case BottomBarPage.BarThemeTypes.Light;

                case BottomBarPage.BarThemeTypes.DarkWithoutAlpha:
                    this._bottomBar.UseDarkThemeWithAlpha(false);
                    goto case BottomBarPage.BarThemeTypes.Light;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            if (newElement.CurrentPage == null)
            {
                return;
            }
            this.SwitchContent(newElement.CurrentPage);
        }
Ejemplo n.º 9
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;

                RemoveAllViews();

                foreach (Page pageToRemove in Element.Children)
                {
                    IVisualElementRenderer pageRenderer = Platform.GetRenderer(pageToRemove);

                    if (pageRenderer != null)
                    {
#pragma warning disable CS0618 // Type or member is obsolete
                        pageRenderer.ViewGroup.RemoveFromParent();
#pragma warning restore CS0618 // Type or member is obsolete
                        pageRenderer.Dispose();
                    }

                    pageToRemove.PropertyChanged -= OnPagePropertyChanged;
                    // pageToRemove.ClearValue (Platform.RendererProperty);
                }

                if (_badges != null)
                {
                    _badges.Clear();
                    _badges = null;
                }

                if (_bottomBar != null)
                {
                    _bottomBar.SetOnTabClickListener(null);
                    _bottomBar.Dispose();
                    _bottomBar = null;
                }

                if (_frameLayout != null)
                {
                    _frameLayout.Dispose();
                    _frameLayout = null;
                }

                /*if (Element != null) {
                 *      PageController.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
                 * }*/
            }

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;

                RemoveAllViews();

                foreach (Page pageToRemove in Element.Children)
                {
                    IVisualElementRenderer pageRenderer = Platform.GetRenderer(pageToRemove);

                    if (pageRenderer != null)
                    {
                        pageRenderer.ViewGroup.RemoveFromParent();
                        pageRenderer.Dispose();
                    }

                    pageToRemove.PropertyChanged -= OnPagePropertyChanged;
                    // pageToRemove.ClearValue (Platform.RendererProperty);
                }

                if (_badges != null)
                {
                    _badges.Clear();
                    _badges = null;
                }

                if (_bottomBar != null)
                {
                    _bottomBar.SetOnTabClickListener(null);
                    _bottomBar.Dispose();
                    _bottomBar = null;
                }

                if (_frameLayout != null)
                {
                    _frameLayout.Dispose();
                    _frameLayout = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 11
0
        protected override void OnElementChanged(ElementChangedEventArgs <ElementsLaboratory.Controls.BottomBarPage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                ElementsLaboratory.Controls.BottomBarPage bottomBarPage = e.NewElement;

                TypedValue tv = new TypedValue();
                Context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true);
                int actionBarHeightInPixels = Resources.GetDimensionPixelSize(tv.ResourceId);

                Resources      resources = Context.Resources;
                DisplayMetrics metrics   = resources.DisplayMetrics;
                float          dp        = actionBarHeightInPixels / (metrics.Xdpi / (float)Android.Util.DisplayMetricsDensity.Default);
                AppResources.Instance.ActionBarHeight = dp;

                if (_bottomBar == null)
                {
                    _pageController = Utils.PageController.Create(bottomBarPage);

                    // create a view which will act as container for Page's
                    _frameLayout = new FrameLayout(this.Context);
                    _frameLayout.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, GravityFlags.Fill);
                    AddView(_frameLayout, 0);

                    // create bottomBar control
                    _bottomBar = BottomNavigationBar.BottomBar.Attach(_frameLayout, null);
                    _bottomBar.NoTabletGoodness();
                    if (bottomBarPage.FixedMode)
                    {
                        _bottomBar.UseFixedMode();
                    }

                    switch (bottomBarPage.BarTheme)
                    {
                    case ElementsLaboratory.Controls.BottomBarPage.BarThemeTypes.Light:
                        break;

                    case ElementsLaboratory.Controls.BottomBarPage.BarThemeTypes.DarkWithAlpha:
                        _bottomBar.UseDarkThemeWithAlpha(true);
                        break;

                    case ElementsLaboratory.Controls.BottomBarPage.BarThemeTypes.DarkWithoutAlpha:
                        _bottomBar.UseDarkThemeWithAlpha(false);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    _bottomBar.SetOnTabClickListener(this);

                    UpdateTabs();
                    UpdateBarBackgroundColor();
                    UpdateBarTextColor();
                }

                if (bottomBarPage.CurrentPage != null)
                {
                    SwitchContent(bottomBarPage.CurrentPage);
                }
            }
        }