コード例 #1
0
        void InitializeTabsItem(EToolbarItem item, string resource)
        {
            //The source of icon resources is https://materialdesignicons.com/
            ImageSource src = ImageSource.FromResource(resource, typeof(ShellItemRenderer).GetTypeInfo().Assembly);

            Native.Image icon = new Native.Image(System.Maui.Maui.NativeParent);
            var          task = icon.LoadFromImageSourceAsync(src);

            item.SetPartContent("elm.swallow.icon", icon);
            item.SetPartColor("bg", _backgroudColor);
            item.SetPartColor("underline", EColor.Transparent);
        }
コード例 #2
0
ファイル: ThemeManager.cs プロジェクト: zhamppx97/maui
 public static void SetSelectedTabColor(this EToolbarItem item, EColor color)
 {
     if (string.IsNullOrEmpty(item.Icon))
     {
         item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextSelected, color);
     }
     else
     {
         item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconSelected, color);
         item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.IconSelected, color);
     }
     item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Underline, color);
 }
コード例 #3
0
        void FillToolbarItems()
        {
            var logicalChildren = (Element as IElementController).LogicalChildren;

            foreach (Page child in logicalChildren)
            {
                var childRenderer = Platform.GetRenderer(child);
                if (childRenderer != null)
                {
                    childRenderer.NativeView.Hide();
                }

                EToolbarItem toolbarItem = _tpage.Append(child.Title, string.IsNullOrEmpty(child.Icon) ? null : ResourcePath.GetPath(child.Icon));
                toolbarItem.SetPartColor("bg", Element.BarBackgroundColor.ToNative());

                _itemToItemPage.Add(toolbarItem, child);
                if (Element.CurrentPage == child)
                {
                    toolbarItem.IsSelected = true;
                    OnCurrentPageChanged(null, null);
                }

                child.PropertyChanged += OnPageTitleChanged;
            }
        }
コード例 #4
0
        void InsertToolbarItem(ShellSection section)
        {
            if (_toolbarItemList.Count < 5)
            {
                EToolbarItem item = null;
                if (_moreToolbarItem == null)
                {
                    item = _tabs.Append(section.Title, GetIconPath(section.Icon));
                }
                else
                {
                    item = _tabs.InsertBefore(_moreToolbarItem, section.Title, GetIconPath(section.Icon));
                }

                if (item != null)
                {
                    item.SetPartColor("bg", _backgroudColor);
                    item.SetPartColor("underline", EColor.Transparent);

                    _toolbarItemList.AddLast(item);
                    _itemToSection.Add(item, section);
                    _sectionToitem.Add(section, item);
                }
            }
            else if (_moreToolbarItem == null && _toolbarItemList.Count == 5)
            {
                var last        = _toolbarItemList.Last() as EToolbarItem;
                var lastSection = _itemToSection[last];

                _toolbarItemList.RemoveLast();
                _itemToSection.Remove(last);
                _sectionToitem.Remove(lastSection);
                last.Delete();

                _moreToolbarItem = CreateTabsItem("More");
                _toolbarItemList.AddLast(_moreToolbarItem);
                InitializeTabsItem(_moreToolbarItem, _dotsIcon);

                _more.AddItem(lastSection);
                _more.AddItem(section);
            }
            else
            {
                _more.AddItem(section);
            }
        }
コード例 #5
0
        /// <summary>
        /// To update the background color of A tabbar
        /// </summary>
        void UpdateBarBackgroundColor()
        {
            var logicalChildren = (Element as IElementController).LogicalChildren;

            foreach (KeyValuePair <EToolbarItem, Page> pair in _itemToItemPage)
            {
                EToolbarItem toolbarItem = pair.Key;
                toolbarItem.SetPartColor("bg", Element.BarBackgroundColor.ToNative());
            }
        }
コード例 #6
0
        void CreateMoreToolbarItem()
        {
            if (_moreToolbarItem != null)
            {
                return;
            }

            //The source of icon resources is https://materialdesignicons.com/
            ImageSource src = ImageSource.FromResource("Xamarin.Forms.Platform.Tizen.Resource.dots_horizontal.png", typeof(ShellItemRenderer).GetTypeInfo().Assembly);

            Native.Image icon = new Native.Image(Forms.NativeParent);
            var          task = icon.LoadFromImageSourceAsync(src);

            _moreToolbarItem = _toolbar.Append("More", null);
            _moreToolbarItem.SetPartContent("elm.swallow.icon", icon);
            _moreToolbarItem.SetPartColor("bg", _backgroudColor);
            _moreToolbarItem.SetPartColor("underline", EColor.Transparent);
            _toolbarItemList.AddLast(_moreToolbarItem);
        }
コード例 #7
0
        EToolbarItem InsertToolbarItem(ShellContent content)
        {
            EToolbarItem item = _tabs.Append(content.Title, null);

            item.SetPartColor("bg", _backgroundColor);

            _toolbarItemList.AddLast(item);
            _itemToContent.Add(item, content);
            _contentToItem.Add(content, item);

            return(item);
        }
コード例 #8
0
ファイル: ThemeManager.cs プロジェクト: zhamppx97/maui
 public static void SetUnderlineColor(this EToolbarItem item, EColor color)
 {
     item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Underline, color);
 }
コード例 #9
0
ファイル: ThemeManager.cs プロジェクト: zhamppx97/maui
 public static void SetBackgroundColor(this EToolbarItem item, EColor color)
 {
     item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Background, color);
 }
コード例 #10
0
        void ApplyBarItemColors(EToolbarItem item, BarItemColorType type, EColor color)
        {
            if (color.IsDefault)
            {
                ClearBarItemColors(item, type);
            }
            else
            {
                switch (type)
                {
                case BarItemColorType.Background:
                    item.SetPartColor("bg", color);
                    break;

                case BarItemColorType.Text:
                    if (string.IsNullOrEmpty(item.Icon))
                    {
                        item.SetPartColor("text", color);
                        item.SetPartColor("text_pressed", color);
                        item.SetPartColor("text_selected", color);
                    }
                    else
                    {
                        item.SetPartColor("text_under_icon", color);
                        item.SetPartColor("text_under_icon_pressed", color);
                        item.SetPartColor("text_under_icon_selected", color);
                    }
                    item.SetPartColor("underline", color);
                    break;

                case BarItemColorType.SelectedTab:
                    if (string.IsNullOrEmpty(item.Icon))
                    {
                        item.SetPartColor("text_selected", color);
                    }
                    else
                    {
                        item.SetPartColor("text_under_icon_selected", color);
                        item.SetPartColor("icon_selected", color);
                    }
                    item.SetPartColor("underline", color);
                    break;

                case BarItemColorType.UnselectedTab:
                    if (string.IsNullOrEmpty(item.Icon))
                    {
                        item.SetPartColor("text", color);
                        item.SetPartColor("text_pressed", color);
                    }
                    else
                    {
                        item.SetPartColor("text_under_icon", color);
                        item.SetPartColor("text_under_icon_pressed", color);
                        item.SetPartColor("icon", color);
                        item.SetPartColor("icon_pressed", color);
                    }
                    break;

                default:
                    break;
                }
            }
        }