void TabLayout.IOnTabSelectedListener.OnTabSelected(TabLayout.Tab tab)
        {
            if (tab == null)
            {
                return;
            }

            switch (tab.Text)
            {
            case "Home":
                tab.SetIcon(Resource.Drawable.home);
                break;

            case "Stats":
                tab.SetIcon(Resource.Drawable.statistics);
                break;

            case "Beheer":
                tab.SetIcon(Resource.Drawable.manage);
                break;

            case "Logs":
                tab.SetIcon(Resource.Drawable.logs);
                break;
            }
        }
Exemplo n.º 2
0
        void TabLayout.IOnTabSelectedListener.OnTabReselected(TabLayout.Tab tab)
        {
            System.Diagnostics.Debug.WriteLine("Tab Reselected");

            var mainPage = Application.Current.MainPage as MainPage;

            var currentNavigationPage = mainPage.CurrentPage as NavigationPage;

            if (currentNavigationPage.RootPage is PhrasesPage)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    if (currentNavigationPage.Title.Equals("Play"))
                    {
                        currentNavigationPage.Title = "Pause";
                        tab.SetIcon(IdFromTitle("ionicons_2_0_1_pause_outline_22", ResourceManager.DrawableClass));
                    }
                    else
                    {
                        currentNavigationPage.Title = "Play";
                        tab.SetIcon(IdFromTitle("ionicons_2_0_1_play_outline_25", ResourceManager.DrawableClass));
                    }
                });
            }
        }
 void UpdateTab(string currentTabText, TabLayout.Tab tab, NavigationPage currentNavigationPage)
 {
     if (currentTabText.Equals("Puzzle"))
     {
         tab.SetIcon(IdFromTitle("Settings", ResourceManager.DrawableClass));
         currentNavigationPage.Title = "Settings";
     }
     else
     {
         tab.SetIcon(IdFromTitle("Puzzle", ResourceManager.DrawableClass));
         currentNavigationPage.Title = "Puzzle";
     }
 }
        private void SetSelectedTabIcon(TabLayout.Tab tab, string icon, bool selected)
        {
            if (string.IsNullOrEmpty(icon))
            {
                return;
            }

            if (selected)
            {
                var selectedResource = IdFromTitle(string.Format("{0}_selected", icon), ResourceManager.DrawableClass);
                if (selectedResource != 0)
                {
                    tab.SetIcon(selectedResource);
                    return;
                }
            }

            var resource = IdFromTitle(icon, ResourceManager.DrawableClass);

            tab.SetIcon(resource);
        }
Exemplo n.º 5
0
 void TabLayout.IOnTabSelectedListener.OnTabReselected(TabLayout.Tab tab)
 {
     // To have the logic only on he tab on position 1
     if (tab == null || tab.Position != 1)
     {
         return;
     }
     if (tab.Text == "Play")
     {
         tab.SetText("Pause");
         tab.SetIcon(Resource.Drawable.ionicons_2_0_1_pause_outline_25);
         App.pauseCard = false;
     }
     else
     {
         tab.SetText("Play");
         tab.SetIcon(Resource.Drawable.ionicons_2_0_1_play_outline_25);
         App.pauseCard = true;
     }
     SetTintColor(tab, GetTabColor());
 }
Exemplo n.º 6
0
        /// <inheritdoc />
        protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
        {
            var iconize = Iconize.FindIconForKey(icon.File);

            if (!(iconize is null))
            {
                var drawable = new IconDrawable(Context, icon).SizeDp(20);
                DrawableCompat.SetTintList(drawable, GetItemIconTintColorState());
                tab.SetIcon(drawable);
                return;
            }

            base.SetTabIcon(tab, icon);
        }
Exemplo n.º 7
0
        void SetIconColorFilter(TabLayout.Tab tab, bool selected)
        {
            var icon = tab.Icon;

            if (icon == null)
            {
                return;
            }

            var colors = GetItemIconTintColorState();

            if (colors == null)
            {
                ADrawableCompat.SetTintList(icon, null);
            }
            else
            {
                int[] _stateSet = null;

                if (selected)
                {
                    _stateSet = GetSelectedStateSet();
                }
                else
                {
                    _stateSet = GetEmptyStateSet();
                }

                if (colors.GetColorForState(_stateSet, _defaultAndroidColor) == _defaultARGBColor)
                {
                    ADrawableCompat.SetTintList(icon, null);
                }
                else
                {
                    var wrappedIcon = ADrawableCompat.Wrap(icon);
                    if (wrappedIcon != icon)
                    {
                        icon = wrappedIcon;
                        tab.SetIcon(wrappedIcon);
                    }

                    icon.Mutate();
                    icon.SetState(_stateSet);
                    ADrawableCompat.SetTintList(icon, colors);
                }
            }
            icon.InvalidateSelf();
        }
Exemplo n.º 8
0
        private void SetTab(TabLayout.Tab tab, string name)
        {
            try {
                int id = Resources.GetIdentifier(name, "drawable", Context.PackageName);
                tab.SetIcon(null);

                LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                linearLayoutParams.SetMargins(0, -48, 0, 0);

                ImageView img = new ImageView(Context);
                img.LayoutParameters = linearLayoutParams;
                img.SetPadding(0, 0, 0, 48);
                img.SetImageResource(id);

                tab.SetCustomView(img);
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 9
0
        void UpdateTabIcons()
        {
            TabLayout tabs = _tabLayout;

            if (tabs.TabCount != Element.Children.Count)
            {
                return;
            }

            for (var i = 0; i < Element.Children.Count; i++)
            {
                Page            child = Element.Children[i];
                FileImageSource icon  = child.Icon;
                if (string.IsNullOrEmpty(icon))
                {
                    continue;
                }

                TabLayout.Tab tab = tabs.GetTabAt(i);
                tab.SetIcon(ResourceManager.IdFromTitle(icon, ResourceManager.DrawableClass));
            }
        }
Exemplo n.º 10
0
 protected virtual void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
 {
     tab.SetIcon(ResourceManager.IdFromTitle(icon, ResourceManager.DrawableClass));
 }
Exemplo n.º 11
0
 protected virtual void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
 {
     tab.SetIcon(GetIconDrawable(icon));
     this.SetIconColorFilter(tab);
 }
Exemplo n.º 12
0
 protected virtual void SetTabIconImageSource(TabLayout.Tab tab, Drawable icon)
 {
     tab.SetIcon(icon);
     SetIconColorFilter(tab);
 }
Exemplo n.º 13
0
 void SetCurrentTabIcon(TabLayout.Tab tab, string icon)
 {
     tab.SetIcon(IdFromTitle(icon, ResourceManager.DrawableClass));
 }
Exemplo n.º 14
0
 void SetTabIcon(TabLayout.Tab tab, Drawable icon)
 {
     tab.SetIcon(icon);
     SetIconColorFilter(tab);
 }