Esempio n. 1
0
        void ApplyBarItemColors(EToolbarItem item, BarItemColorType type, EColor color)
        {
            if (color.IsDefault)
            {
                ClearBarItemColors(item, type);
            }
            else
            {
                switch (type)
                {
                case BarItemColorType.Background:
                    item.SetBackgroundColor(color);
                    break;

                case BarItemColorType.Text:
                    item.SetTextColor(color);
                    break;

                case BarItemColorType.SelectedTab:
                    item.SetSelectedTabColor(color);
                    break;

                case BarItemColorType.UnselectedTab:
                    item.SetUnselectedTabColor(color);
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
0
        void RemoveToolbarItem(ShellSection section)
        {
            if (_sectionToitem.ContainsKey(section))
            {
                var del = _sectionToitem[section];
                _toolbarItemList.Remove(del);
                _itemToSection.Remove(del);
                _sectionToitem.Remove(section);
                del.Delete();

                if (_moreToolbarItem != null)
                {
                    ShellSection move = _more.RemoveFirst();
                    InsertToolbarItem(move);
                }
            }
            else
            {
                _more.RemoveItem(section);
            }

            if (_more.Count == 1)
            {
                _toolbarItemList.Remove(_moreToolbarItem);
                _moreToolbarItem.Delete();
                _moreToolbarItem = null;

                ShellSection move = _more.RemoveFirst();
                InsertToolbarItem(move);
            }
        }
        void ClearBarItemColors(EToolbarItem item, BarItemColorType type)
        {
            switch (type)
            {
            case BarItemColorType.Background:
                item.DeletePartColor("bg");
                break;

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

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

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

            default:
                break;
            }
        }
Esempio n. 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());
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
 public static void DeleteSelectedTabColor(this EToolbarItem item)
 {
     if (string.IsNullOrEmpty(item.Icon))
     {
         item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextSelected);
     }
     else
     {
         item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconSelected);
         item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.IconSelected);
     }
     item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Underline);
 }
Esempio n. 10
0
        void FillToolbarAndContents()
        {
            int index = 0;

            //add items to toolbar
            foreach (Page child in Element.Children)
            {
                EToolbarItem toolbarItem = AddToolbarItem(child, index++);

                if (Element.CurrentPage == child)
                {
                    //select item on the toolbar and fill content
                    toolbarItem.IsSelected = true;
                }
            }
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        EToolbar GetBreadCrumbsBar()
        {
            EToolbar toolbar = new EToolbar(Forms.NativeParent)
            {
                ItemAlignment = 0,
                Homogeneous   = false,
                ShrinkMode    = ToolbarShrinkMode.Scroll
            };

            toolbar.SetNavigationBarStyle();

            foreach (var p in Element.Navigation.NavigationStack)
            {
                string breadCrumb = p.OnThisPlatform().GetBreadCrumb();
                if (!string.IsNullOrEmpty(breadCrumb))
                {
                    EToolbarItem toolbarItem = toolbar.Append(breadCrumb);
                    toolbarItem.Selected += (s, e) =>
                    {
                        var copyOfStack = Element.Navigation.NavigationStack.Reverse().Skip(1);
                        foreach (var lp in copyOfStack)
                        {
                            if (lp == p)
                            {
                                break;
                            }
                            Element.Navigation.RemovePage(lp);
                        }
                        if (Element.Navigation.NavigationStack.Last() != p)
                        {
                            Element.Navigation.PopAsync();
                        }
                    };
                }
            }

            return(toolbar);
        }
Esempio n. 14
0
        void ClearBarItemColors(EToolbarItem item, BarItemColorType type)
        {
            switch (type)
            {
            case BarItemColorType.Background:
                item.DeleteBackgroundColor();
                break;

            case BarItemColorType.Text:
                item.DeleteTextColor();
                break;

            case BarItemColorType.SelectedTab:
                item.DeleteSelectedTabColor();
                break;

            case BarItemColorType.UnselectedTab:
                item.DeleteUnselectedTabColor();
                break;

            default:
                break;
            }
        }
Esempio n. 15
0
 public static void DeleteUnderlineColor(this EToolbarItem item)
 {
     item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Underline);
 }
Esempio n. 16
0
 public static void DeleteBackgroundColor(this EToolbarItem item)
 {
     item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Background);
 }
Esempio n. 17
0
 public static void SetUnderlineColor(this EToolbarItem item, EColor color)
 {
     item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Underline, color);
 }
Esempio n. 18
0
 public static void SetBackgroundColor(this EToolbarItem item, EColor color)
 {
     item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Background, color);
 }
Esempio n. 19
0
 public static void SetIconPart(this EToolbarItem item, EvasObject content, bool preserveOldContent = false)
 {
     item.SetPartContent(ThemeConstants.ToolbarItem.Parts.Icon, content, preserveOldContent);
 }
        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;
                }
            }
        }
Esempio n. 21
0
 /// <summary>
 /// Inserts a new item which just contains label into the toolbar object before item <paramref name="before"/>.
 /// </summary>
 /// <param name="before">The toolbar item to insert before.</param>
 /// <param name="label">The label of the item.</param>
 /// <returns>The new <see cref="ToolbarItem"/> which is inserted into the toolbar.</returns>
 /// <seealso cref="InsertBefore(ToolbarItem, string, string)"/>
 /// <since_tizen> preview </since_tizen>
 public ToolbarItem InsertBefore(ToolbarItem before, string label)
 {
     return(InsertBefore(before, label, string.Empty));
 }