Ejemplo n.º 1
0
        void Connectviews()
        {
            goOnlineButton = (Button)FindViewById(Resource.Id.goOnlineButton);
            bnve           = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve);
#pragma warning disable CS0618 // Type or member is obsolete
            bnve.EnableItemShiftingMode(false);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
            bnve.EnableShiftingMode(false);
#pragma warning restore CS0618 // Type or member is obsolete

            goOnlineButton.Click        += GoOnlineButton_Click;
            bnve.NavigationItemSelected += Bnve_NavigationItemSelected;


            var img0 = bnve.GetIconAt(0);
            var txt0 = bnve.GetLargeLabelAt(0);
            img0.SetColorFilter(Color.Rgb(24, 191, 242));
            txt0.SetTextColor(Color.Rgb(24, 191, 242));

            viewpager = (ViewPager)FindViewById(Resource.Id.viewpager);
            viewpager.OffscreenPageLimit = 3;
            viewpager.BeginFakeDrag();

            SetupViewPager();

            homeFragment.CurrentLocation     += HomeFragment_CurrentLocation;
            homeFragment.TripActionArrived   += HomeFragment_TripActionArrived;
            homeFragment.callRider           += HomeFragment_callRider;
            homeFragment.Navigate            += HomeFragment_Navigate;
            homeFragment.TripActionStartTrip += HomeFragment_TripActionStartTrip;
            homeFragment.TripActionEndTrip   += HomeFragment_TripActionEndTripAsync;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes the shifting mode from the BottomNavigationViewEx.
        /// </summary>
        /// <param name="view">
        /// The BottomNavigationViewEx to remove the shifting mode from.
        /// </param>
        /// <returns>
        /// Returns the BottomNavigationViewEx so that multiple methods can be chained toegther.
        /// </returns>
        public static BottomNavigationViewEx RemoveShiftingMode(this BottomNavigationViewEx view)
        {
            // Get the menu view to access the items
            var menuView = view.GetChildAt(0) as BottomNavigationMenuView;

            // Expose and set the Java field
            menuView.Class.GetDeclaredField("mShiftingMode")
            .SetAccessible(true)
            .SetBooleanPipe(menuView, false)
            .SetAccessible(false)
            .Dispose();

            // Loop through the menu items
            for (int i = 0; i < menuView.ChildCount; i++)
            {
                // Get the menu item
                var item = menuView.GetChildAt(i) as BottomNavigationItemView;

                // Set Shifting mode and then set again to update the view
                item.SetShiftingMode(false);
                item.SetChecked(item.ItemData.IsChecked);
            }

            // Force change update
            menuView.UpdateMenuView();

            return(view);
        }
Ejemplo n.º 3
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.ViewGroup.RemoveFromParent();
                        pageRenderer.Dispose();
                    }
                }

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

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

            base.Dispose(disposing);
        }
Ejemplo n.º 4
0
 public void InitInterface()
 {
     bnve = (BottomNavigationViewEx)FindViewById(Resource.Id.activity_with_view_pager);
     bnve.EnableAnimation(false);
     bnve.EnableItemShiftingMode(false);
     //bnve.Click += Bnve_Click;
 }
        public static BottomNavigationViewEx SetupBottomBar(this ExtendedTabbedPageRenderer renderer,
                                                            global::Android.Widget.RelativeLayout rootLayout, BottomNavigationViewEx bottomNav, int barId)
        {
            if (bottomNav != null)
            {
                rootLayout.RemoveView(bottomNav);
                bottomNav.SetOnNavigationItemSelectedListener(null);
            }

            var barParams = new global::Android.Widget.RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ExtendedTabbedPageRenderer.BottomBarHeight.HasValue ?
                (int)rootLayout.Context.ToPixels(ExtendedTabbedPageRenderer.BottomBarHeight.Value) :
                ViewGroup.LayoutParams.WrapContent);

            barParams.AddRule(LayoutRules.AlignParentBottom);
            bottomNav = new BottomNavigationViewEx(rootLayout.Context)
            {
                LayoutParameters = barParams,
                Id = barId
            };
            if (ExtendedTabbedPageRenderer.BackgroundColor.HasValue)
            {
                bottomNav.SetBackgroundColor(ExtendedTabbedPageRenderer.BackgroundColor.Value);
            }

            bottomNav.SetOnNavigationItemSelectedListener(renderer);
            rootLayout.AddView(bottomNav, 1, barParams);

            return(bottomNav);
        }
Ejemplo n.º 6
0
        void ConnectViews()
        {
            goOnlineButton = (Button)FindViewById(Resource.Id.goOnlineButton);      // the go online button
            bnve           = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve);
            bnve.EnableItemShiftingMode(false);
            bnve.EnableShiftingMode(false);


            // ----- CHECK DRIVER APPROVAL STATUS ------
            string driverID = AppDataHelper.GetCurrentUser().Uid;

            FirebaseDatabase.Instance.Reference.Child("driverApplications/" + driverID)
            .AddValueEventListener(new DataValueEventListener());


            goOnlineButton.Click        += GoOnlineButton_Click;
            bnve.NavigationItemSelected += Bnve_NavigationItemSelected;

            BnveToAccentColor(0);

            viewPager = (ViewPager)FindViewById(Resource.Id.viewPager);
            viewPager.OffscreenPageLimit = 3;
            viewPager.BeginFakeDrag();

            SetupViewPager();


            homeFragment.CurrentLocation     += HomeFragment_CurrentLocation;
            homeFragment.TripActionArrived   += HomeFragment_TripActionArrived;
            homeFragment.CallRider           += HomeFragment_CallRider;
            homeFragment.Navigate            += HomeFragment_Navigate;
            homeFragment.TripActionStartTrip += HomeFragment_TripActionStartTrip;
            homeFragment.TripActionEndTrip   += HomeFragment_TripActionEndTrip;
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Element.ChildAdded        -= PagesChanged;
                Element.ChildRemoved      -= PagesChanged;
                Element.ChildrenReordered -= PagesChanged;

                if (_rootLayout != null)
                {
                    RemoveAllViews();
                    foreach (Page pageToRemove in Element.Children)
                    {
                        var pageRenderer = Platform.GetRenderer(pageToRemove);
                        if (pageRenderer != null)
                        {
                            pageRenderer.View.RemoveFromParent();
                            pageRenderer.Dispose();
                        }
                    }

                    if (_bottomNav != null)
                    {
                        _bottomNav.SetOnNavigationItemSelectedListener(null);
                        _bottomNav.Dispose();
                        _bottomNav = null;
                    }
                    _rootLayout.Dispose();
                    _rootLayout = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 8
0
        private void ConnectViews()
        {
            _goOnlineButton = FindViewById <Button>(Resource.Id.goOnlineButton);
            _bnve           = FindViewById <BottomNavigationViewEx>(Resource.Id.bnve);
            _bnve.EnableItemShiftingMode(false);
            _bnve.EnableShiftingMode(false);

            _goOnlineButton.Click        += GoOnlineButton_Click;
            _bnve.NavigationItemSelected += Bnve_NavigationItemSelected;


            var img0 = _bnve.GetIconAt(0);
            var txt0 = _bnve.GetLargeLabelAt(0);

            img0.SetColorFilter(Color.Rgb(24, 191, 242));
            txt0.SetTextColor(Color.Rgb(24, 191, 242));

            _viewpager = (ViewPager)FindViewById(Resource.Id.viewpager);
            _viewpager.OffscreenPageLimit = 3;
            _viewpager.BeginFakeDrag();

            SetupViewPager();

            _homeFragment.CurrentLocation     += HomeFragment_CurrentLocation;
            _homeFragment.TripActionArrived   += HomeFragment_TripActionArrived;
            _homeFragment.CallRider           += HomeFragment_CallRider;
            _homeFragment.Navigate            += HomeFragment_Navigate;
            _homeFragment.TripActionStartTrip += HomeFragment_TripActionStartTrip;
            _homeFragment.TripActionEndTrip   += HomeFragment_TripActionEndTrip;
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = base.OnCreateView(inflater, container, savedInstanceState);

            _bottomNavigationView = view.FindViewById <BottomNavigationViewEx>(Resource.Id.bottom_navigation_view);
            _bottomNavigationView?.SetOnNavigationItemSelectedListener(this);
            _bottomNavigationView?.SetOnNavigationItemReselectedListener(this);

            _bottomNavigationView?.Menu?.FindItem(Resource.Id.i_unchecked)?.SetChecked(true);
            var uncheckedItem = _bottomNavigationView?.FindViewById(Resource.Id.i_unchecked);

            if (uncheckedItem != null)
            {
                uncheckedItem.Visibility = ViewStates.Gone;
            }

            _bottomNavigationView?.EnableShiftingMode(false);

            var bindingSet = this.CreateBindingSet <BottomNavigationView, BottomNavigationViewModel>();

            bindingSet.Bind(this).For(h => h.CheckedItem).To(vm => vm.CheckedItem);
            bindingSet.Apply();

            if (savedInstanceState == null)
            {
            }

            return(view);
        }
Ejemplo n.º 10
0
        protected override async void OnElementChanged(ElementChangedEventArgs <BottomBarPage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                _element = e.NewElement;
                if (_bottomNavigationView == null)
                {
                    _rootLayout = new Android.Widget.RelativeLayout(Context)
                    {
                        LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                    };
                    AddView(_rootLayout);

                    _frameLayout = new FrameLayout(Context)
                    {
                        LayoutParameters = new ActionBar.LayoutParams(LayoutParams.MatchParent,
                                                                      LayoutParams.MatchParent, GravityFlags.Fill)
                    };
                    _rootLayout.AddView(_frameLayout);

                    _bottomNavigationView = new BottomNavigationViewEx(Context)
                    {
                        LayoutParameters =
                            new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.MatchParent,
                                                                           LayoutParams.WrapContent)
                    };
                    (_bottomNavigationView.LayoutParameters as Android.Widget.RelativeLayout.LayoutParams)?.AddRule(LayoutRules.AlignParentBottom);
                    _bottomNavigationView.SetOnNavigationItemSelectedListener(this);

                    if (_element.BarTextColor != default(Color))
                    {
                        _bottomNavigationView.ItemTextColor    = ColorStateList.ValueOf(_element.BarTextColor.ToAndroid());
                        _bottomNavigationView.ItemIconTintList = ColorStateList.ValueOf(_element.BarTextColor.ToAndroid());
                    }

                    if (_element.BarBackgroundColor != default(Color))
                    {
                        _bottomNavigationView.SetBackgroundColor(_element.BarBackgroundColor.ToAndroid());
                    }

                    foreach (var page in Element.Children)
                    {
                        await AddPage(page);
                    }

                    _rootLayout.AddView(_bottomNavigationView, 1);
                    _bottomNavigationView.EnableShiftingMode(false);
                    _bottomNavigationView.EnableItemShiftingMode(false);
                    ChangeCurrentPage(Element.Children[0]);
                    _element.ChildAdded   += Element_ChildAdded;
                    _element.ChildRemoved += Element_ChildRemoved;
                }
            }
        }
Ejemplo n.º 11
0
        public static void SetupTabItems(this BottomTabbedRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var Element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.Clear();
            var mPresenterField = Java.Lang.Class.FromType(typeof(BottomNavigationMenuView)).GetDeclaredField("presenter");

            mPresenterField.Accessible = true;
            var mPresenter = (BottomNavigationPresenter)mPresenterField.Get(bottomNav.BottomNavigationMenuView);

            mPresenterField.Accessible = false;

            if (Element.Children.Count == 0)
            {
                return;
            }

            mPresenter.SetUpdateSuspended(true);
            var tabsCount = Math.Min(Element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = Element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = BottomTabbedRenderer.MenuItemIconSetter ?? BottomTabbedRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.IconImageSource as FileImageSource, renderer.LastSelectedIndex == i);
            }
            mPresenter.SetUpdateSuspended(false);
            mPresenter.UpdateMenuView(true);
            //Deprecated use {@link #setLabelVisibilityMode }
            bottomNav.EnableShiftingMode(false);     //enable It will has a shift animation if true. Otherwise all items are the same width.
            //Deprecated use {@link #setItemHorizontalTranslationEnabled(boolean)}
            bottomNav.EnableItemShiftingMode(false); //enable It will has a shift animation for item if true. Otherwise the item text always be shown.
            bottomNav.EnableAnimation(false);        //enable It means the text won't scale and icon won't move when active it in no item shifting mode if false.
            bottomNav.SetTextVisibility(BottomTabbedRenderer.VisibleTitle.HasValue ? BottomTabbedRenderer.VisibleTitle.Value : true);
            if (BottomTabbedRenderer.Typeface != null)
            {
                bottomNav.SetTypeface(BottomTabbedRenderer.Typeface);
            }
            if (BottomTabbedRenderer.IconSize.HasValue)
            {
                bottomNav.SetIconSize(BottomTabbedRenderer.IconSize.Value, BottomTabbedRenderer.IconSize.Value);
            }
            if (BottomTabbedRenderer.FontSize.HasValue)
            {
                bottomNav.SetTextSize(BottomTabbedRenderer.FontSize.Value);
            }

            bottomNav.TextAlignment = Android.Views.TextAlignment.Center;
        }
        public static void SetupTabItems(this BottomTabbedRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var Element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.Clear();
            var mPresenterField = Java.Lang.Class.FromType(typeof(BottomNavigationMenuView)).GetDeclaredField("presenter");

            mPresenterField.Accessible = true;
            var mPresenter = (BottomNavigationPresenter)mPresenterField.Get(bottomNav.BottomNavigationMenuView);

            mPresenterField.Accessible = false;

            if (Element.Children.Count == 0)
            {
                return;
            }

            mPresenter.SetUpdateSuspended(true);
            var tabsCount = Math.Min(Element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = Element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = BottomTabbedRenderer.MenuItemIconSetter ?? BottomTabbedRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.Icon, renderer.LastSelectedIndex == i);
            }
            mPresenter.SetUpdateSuspended(false);
            mPresenter.UpdateMenuView(true);

            bottomNav.EnableShiftingMode(false);     //remove shifting mode
            bottomNav.EnableItemShiftingMode(false); //remove shifting mode
            bottomNav.EnableAnimation(false);        //remove animation
            bottomNav.SetTextVisibility(BottomTabbedRenderer.VisibleTitle.HasValue ? BottomTabbedRenderer.VisibleTitle.Value : true);
            if (BottomTabbedRenderer.Typeface != null)
            {
                bottomNav.SetTypeface(BottomTabbedRenderer.Typeface);
            }
            if (BottomTabbedRenderer.IconSize.HasValue)
            {
                bottomNav.SetIconSize(BottomTabbedRenderer.IconSize.Value, BottomTabbedRenderer.IconSize.Value);
            }
            if (BottomTabbedRenderer.FontSize.HasValue)
            {
                bottomNav.SetTextSize(BottomTabbedRenderer.FontSize.Value);
            }

            bottomNav.TextAlignment = Android.Views.TextAlignment.Center;
        }
        public static void SetupTabItems(this ExtendedTabbedPageRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.ClearAll();

            var tabsCount = Math.Min(element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = ExtendedTabbedPageRenderer.MenuItemIconSetter ?? ExtendedTabbedPageRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.Icon, renderer.LastSelectedIndex == i);
            }

            if (element.Children.Count > 0)
            {
                bottomNav.EnableShiftingMode(false);
                bottomNav.EnableItemShiftingMode(false);
                bottomNav.EnableAnimation(false);
                bottomNav.SetTextVisibility(false);
                bottomNav.SetBackgroundResource(Resource.Drawable.bottom_nav_bg);
                bottomNav.SetIconSize(24, 24);
                bottomNav.SetIconsMarginTop(32);

                if (element.Children.Count > 3)
                {
                    bottomNav.SetIconSizeAt(3, 29, 29);
                    bottomNav.SetIconMarginTop(3, 28);
                }

                var stateList = new global::Android.Content.Res.ColorStateList(
                    new int[][] {
                    new int[] { global::Android.Resource.Attribute.StateChecked },
                    new int[] { global::Android.Resource.Attribute.StateEnabled }
                },
                    new int[] {
                    element.TintColor.ToAndroid(),      // Selected
                    Color.FromHex("A1A1A1").ToAndroid() // Normal
                });

                bottomNav.ItemIconTintList = stateList;
            }
        }
Ejemplo n.º 14
0
        void ConnectViews()
        {
            //Setting up the bottom navigation bar
            bnve = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve);

            //makes words to be showing in the nav bar
            bnve.EnableItemShiftingMode(false);
            bnve.EnableShiftingMode(false);
            bnve.NavigationItemSelected += Bnve_NavigationItemSelected;

            BnveToAccentColor(0);

            viewpager = (ViewPager)FindViewById(Resource.Id.viewpager);
            viewpager.OffscreenPageLimit = 4;
            viewpager.BeginFakeDrag();

            SetupViewPager();
        }
Ejemplo n.º 15
0
        void connectViews()
        {
            bnve = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve);
            bnve.EnableItemShiftingMode(false);
            bnve.EnableShiftingMode(false);

            bnve.NavigationItemSelected += Bnve_NavigationItemSelected;

            BnveToAccentColor(0);

            viewPager = (ViewPager)FindViewById(Resource.Id.viewpager);
            viewPager.OffscreenPageLimit = 3;
            viewPager.BeginFakeDrag();

            SetupViewpager();

            // App Toolbar appmainToolbar
            appmainToolbar          = (Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Id.appmainToolbar);
            appmainToolbarRiderinfo = (Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Id.appmainToolbarRiderinfo);

            // buttons
            Online  = (Button)FindViewById(Resource.Id.Onlinebtn);
            Offline = (Button)FindViewById(Resource.Id.Offlinebtn);

            Online.Click  += Online_Click;
            Offline.Click += Offline_Click;

            //Text View
            ridernameInHidenDelog = (TextView)FindViewById(Resource.Id.ridernameInHidenDelog);
            cancel_Trip           = (TextView)FindViewById(Resource.Id.cancel_Trip);
            cancel_Trip.Click    += Cancel_Trip_Click;

            //Imgaes
            CallRider        = (ImageView)FindViewById(Resource.Id.CallRider);
            CallRider.Click += CallRider_Click;

            RiderLocation        = (ImageView)FindViewById(Resource.Id.RiderLocation);
            RiderLocation.Click += RiderLocation_Click;

            StartTrip = (Button)FindViewById(Resource.Id.StartTrip);

            GoToRider        = (Button)FindViewById(Resource.Id.GoToRider);
            GoToRider.Click += GoToRider_Click;
        }
Ejemplo n.º 16
0
        public static BottomNavigationViewEx SetupBottomBar(this BottomTabbedRenderer renderer, Android.Widget.RelativeLayout rootLayout, BottomNavigationViewEx bottomNav, int barId)
        {
            if (bottomNav != null)
            {
                rootLayout.RemoveView(bottomNav);
                bottomNav.SetOnNavigationItemSelectedListener(null);
            }

            var barParams = new Android.Widget.RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                BottomTabbedRenderer.BottomBarHeight.HasValue ? (int)rootLayout.Context.ToPixels(BottomTabbedRenderer.BottomBarHeight.Value) : ViewGroup.LayoutParams.WrapContent);

            //Add alignment rules to close to the lower edge of the parent contro
            barParams.AddRule(LayoutRules.AlignParentBottom);
            bottomNav = new BottomNavigationViewEx(rootLayout.Context)
            {
                LayoutParameters = barParams,
                Id = barId
            };
            if (BottomTabbedRenderer.BackgroundColor.HasValue)
            {
                bottomNav.SetBackgroundColor(BottomTabbedRenderer.BackgroundColor.Value);
            }
            if (BottomTabbedRenderer.ItemIconTintList != null)
            {
                bottomNav.ItemIconTintList = BottomTabbedRenderer.ItemIconTintList;
            }
            if (BottomTabbedRenderer.ItemTextColor != null)
            {
                bottomNav.ItemTextColor = BottomTabbedRenderer.ItemTextColor;
            }
            if (BottomTabbedRenderer.ItemBackgroundResource.HasValue)
            {
                bottomNav.ItemBackgroundResource = BottomTabbedRenderer.ItemBackgroundResource.Value;
            }
            //The listening callback method "setOnNavigationItemSelectedListener()", which defaults to the first entry being the first item selected, can be set by
            //"navigation.getMenu().getItem(index).setChecked(true);"
            bottomNav.SetOnNavigationItemSelectedListener(renderer);
            rootLayout.AddView(bottomNav, 1, barParams);

            return(bottomNav);
        }
Ejemplo n.º 17
0
        public void InitInterface()
        {
            bnve = FindViewById <BottomNavigationViewEx>(Resource.Id.bnve);
            // disable all animation
            bnve.EnableAnimation(false);
            bnve.EnableShiftingMode(false);
            bnve.EnableItemShiftingMode(false);


            bnve.Post(() =>
            {
                //add badgeview at second icon
                badgeView1 = AddBadgeViewAt(0, "20", BadgeView.ShapeOval);
                badgeView2 = AddBadgeViewAt(1, "99", BadgeView.ShapeOval);
                badgeView3 = AddBadgeViewAt(2, "20", BadgeView.ShapeOval);
                badgeView4 = AddBadgeViewAt(3, "2", BadgeView.ShapeOval);
                badgeView5 = AddBadgeViewAt(4, "2", BadgeView.ShapeOval);
            });

            bnve.NavigationItemReselected += Bnve_NavigationItemReselected;
        }
        public static BottomNavigationViewEx SetupBottomBar(this BottomTabbedRenderer renderer, Android.Widget.RelativeLayout rootLayout, BottomNavigationViewEx bottomNav, int barId)
        {
            if (bottomNav != null)
            {
                rootLayout.RemoveView(bottomNav);
                bottomNav.SetOnNavigationItemSelectedListener(null);
            }

            var barParams = new Android.Widget.RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                BottomTabbedRenderer.BottomBarHeight.HasValue ? (int)rootLayout.Context.ToPixels(BottomTabbedRenderer.BottomBarHeight.Value) : ViewGroup.LayoutParams.WrapContent);

            barParams.AddRule(LayoutRules.AlignParentBottom);
            bottomNav = new BottomNavigationViewEx(rootLayout.Context)
            {
                LayoutParameters = barParams,
                Id = barId
            };
            if (BottomTabbedRenderer.BackgroundColor.HasValue)
            {
                bottomNav.SetBackgroundColor(BottomTabbedRenderer.BackgroundColor.Value);
            }
            if (BottomTabbedRenderer.ItemIconTintList != null)
            {
                bottomNav.ItemIconTintList = BottomTabbedRenderer.ItemIconTintList;
            }
            if (BottomTabbedRenderer.ItemTextColor != null)
            {
                bottomNav.ItemTextColor = BottomTabbedRenderer.ItemTextColor;
            }
            if (BottomTabbedRenderer.ItemBackgroundResource.HasValue)
            {
                bottomNav.ItemBackgroundResource = BottomTabbedRenderer.ItemBackgroundResource.Value;
            }

            bottomNav.SetOnNavigationItemSelectedListener(renderer);
            rootLayout.AddView(bottomNav, 1, barParams);

            return(bottomNav);
        }
        public static void SetupTabItems(this BottomTabbedRenderer renderer, BottomNavigationViewEx bottomNav)
        {
            var Element = renderer.Element;
            var menu    = (BottomNavigationMenu)bottomNav.Menu;

            menu.ClearAll();

            var tabsCount = Math.Min(Element.Children.Count, bottomNav.MaxItemCount);

            for (int i = 0; i < tabsCount; i++)
            {
                var page     = Element.Children[i];
                var menuItem = menu.Add(0, i, 0, page.Title);
                var setter   = BottomTabbedRenderer.MenuItemIconSetter ?? BottomTabbedRenderer.DefaultMenuItemIconSetter;
                setter.Invoke(menuItem, page.Icon, renderer.LastSelectedIndex == i);
            }
            if (Element.Children.Count > 0)
            {
                bottomNav.EnableShiftingMode(false);     //remove shifting mode
                bottomNav.EnableItemShiftingMode(false); //remove shifting mode
                bottomNav.EnableAnimation(false);        //remove animation
                bottomNav.SetTextVisibility(BottomTabbedRenderer.VisibleTitle.HasValue ? BottomTabbedRenderer.VisibleTitle.Value : true);
                if (BottomTabbedRenderer.Typeface != null)
                {
                    bottomNav.SetTypeface(BottomTabbedRenderer.Typeface);
                }
                if (BottomTabbedRenderer.IconSize.HasValue)
                {
                    bottomNav.SetIconSize(BottomTabbedRenderer.IconSize.Value, BottomTabbedRenderer.IconSize.Value);
                }
                if (BottomTabbedRenderer.FontSize.HasValue)
                {
                    bottomNav.SetTextSize(BottomTabbedRenderer.FontSize.Value);
                }

                bottomNav.TextAlignment = Android.Views.TextAlignment.Center;
            }
        }
Ejemplo n.º 20
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && Element != null)
            {
                Element.ChildAdded        -= PagesChanged;
                Element.ChildRemoved      -= PagesChanged;
                Element.ChildrenReordered -= PagesChanged;

                if (rootLayout != null)
                {
                    //TODO Cleanup
                    RemoveAllViews();
                    foreach (Page pageToRemove in Element.Children)
                    {
                        IVisualElementRenderer pageRenderer = Platform.GetRenderer(pageToRemove);

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

                    if (bottomNav != null)
                    {
                        bottomNav.SetOnNavigationItemSelectedListener(null);
                        bottomNav.Dispose();
                        bottomNav = null;
                    }
                    rootLayout.Dispose();
                    rootLayout = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 21
0
        protected override void OnElementChanged(ElementChangedEventArgs <BottomTabbedPage> e)
        {
            base.OnElementChanged(e);

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

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

                    _rootLayout = new LinearLayout(Context)
                    {
                        LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                    };
                    AddView(_rootLayout);

                    // create a view which will act as container for Page's
                    _frameLayout = new FrameLayout(Context)
                    {
                        LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                    };
                    _rootLayout.AddView(_frameLayout);

                    _bottomBar = new BottomNavigationViewEx(Context)
                    {
                        LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                    };

                    _rootLayout.AddView(_bottomBar);
                    _bottomBar.SetOnNavigationItemSelectedListener(this);

                    if (BackgroundColor.HasValue)
                    {
                        _bottomBar.SetBackgroundColor(BackgroundColor.Value);
                    }

                    if (ItemIconTintList != null)
                    {
                        _bottomBar.ItemIconTintList = ItemIconTintList;
                    }
                    if (ItemTextColor != null)
                    {
                        _bottomBar.ItemTextColor = ItemTextColor;
                    }
                    if (ItemBackgroundResource.HasValue)
                    {
                        _bottomBar.ItemBackgroundResource = ItemBackgroundResource.Value;
                    }
                    // Resource.Drawable.bnv_selector

                    _menu = (BottomNavigationMenu)_bottomBar.Menu;

                    UpdateTabs();
                }

                if (bottomBarPage.CurrentPage != null)
                {
                    SwitchContent(bottomBarPage.CurrentPage);
                }
            }
        }
 internal void SetupBottomBar()
 {
     _bottomNav = this.SetupBottomBar(_rootLayout, _bottomNav, _barId);
 }
Ejemplo n.º 23
0
        public void initInterface()
        {
            bnve_normal                          = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_normal);
            bnve_no_animation                    = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation);
            bnve_no_shifting_mode                = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_shifting_mode);
            bnve_no_item_shifting_mode           = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_item_shifting_mode);
            bnve_no_text                         = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_text);
            bnve_no_icon                         = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_icon);
            bnve_no_animation_shifting_mode      = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode);
            bnve_no_animation_item_shifting_mode = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_item_shifting_mode);
            bnve_no_animation_shifting_mode_item_shifting_mode      = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode_item_shifting_mode);
            bnve_no_shifting_mode_item_shifting_mode_text           = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_shifting_mode_item_shifting_mode_text);
            bnve_no_animation_shifting_mode_item_shifting_mode_text = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode_item_shifting_mode_text);
            bnve_no_shifting_mode_item_shifting_mode_and_icon       = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_shifting_mode_item_shifting_mode_and_icon);
            bnve_no_item_shifting_mode_icon = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_item_shifting_mode_icon);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_no_animation_shifting_mode_item_shifting_mode_icon);
            bnve_with_padding     = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_with_padding);
            bnve_center_icon_only = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_center_icon_only);
            bnve_smaller_text     = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_smaller_text);
            bnve_bigger_icon      = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_bigger_icon);
            bnve_custom_typeface  = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_custom_typeface);
            bnve_icon_selector    = (BottomNavigationViewEx)FindViewById(Resource.Id.bnve_icon_selector);

            //no animation
            bnve_no_animation.EnableAnimation(false);

            //no shifting mode
            bnve_no_shifting_mode.EnableShiftingMode(false);

            //no item shifting mode
            bnve_no_item_shifting_mode.EnableItemShiftingMode(false);

            //bnve no text
            bnve_no_text.SetTextVisibility(false);

            //bnve no icon
            bnve_no_icon.SetIconVisibility(false);

            //bnve no animation shifting mode
            bnve_no_animation_shifting_mode.EnableAnimation(false);
            bnve_no_animation_shifting_mode.EnableShiftingMode(false);

            //bnve_no_animation_item_shifting_mode
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableItemShiftingMode(false);

            //bnve_no_animation_shifting_mode_item_shifting_mode
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode.EnableItemShiftingMode(false);

            //bnve_no_shifting_mode_item_shifting_mode_text
            bnve_no_shifting_mode_item_shifting_mode_text.EnableItemShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_text.EnableShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_text.SetTextVisibility(false);

            //bnve_no_animation_shifting_mode_item_shifting_mode_text
            bnve_no_animation_shifting_mode_item_shifting_mode_text.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_text.EnableShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_text.EnableItemShiftingMode(false);

            //bnve_no_shifting_mode_item_shifting_mode_and_icon
            bnve_no_shifting_mode_item_shifting_mode_and_icon.EnableItemShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_and_icon.EnableShiftingMode(false);
            bnve_no_shifting_mode_item_shifting_mode_and_icon.SetIconVisibility(false);

            //bnve_no_item_shifting_mode_icon
            bnve_no_item_shifting_mode_icon.EnableItemShiftingMode(false);
            bnve_no_item_shifting_mode_icon.SetIconVisibility(false);

            //bnve_no_animation_shifting_mode_item_shifting_mode_icon
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.EnableAnimation(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.EnableItemShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.EnableShiftingMode(false);
            bnve_no_animation_shifting_mode_item_shifting_mode_icon.SetIconVisibility(false);

            //bnve_with_padding
            bnve_with_padding.SetPadding(8, 8, 8, 8);

            //bnve_center_icon_only

            //bnve_smaller_text
            bnve_smaller_text.SetTextSize(10);

            //bnve_bigger_icon
            bnve_bigger_icon.SetIconSize(48, 48);
            bnve_bigger_icon.SetTextVisibility(false);

            //bnve_custom_typeface
            Android.Graphics.Typeface typeface = Android.Graphics.Typeface.CreateFromAsset(this.Assets, "fonts/JOKERMAN.TTF");
            bnve_custom_typeface.SetTypeface(typeface);

            //bnve_icon_selector
        }