Exemplo n.º 1
0
 public static EToolbar SetTVTabBarWithTitleStyle(this EToolbar toolbar)
 {
     if (DeviceInfo.Idiom != DeviceIdiom.TV)
     {
         Log.Error($"TabBarWithTitleStyle is only supported on DeviceIdiom.TV : {0}", DeviceInfo.Idiom);
         return(toolbar);
     }
     toolbar.Style = ThemeConstants.Toolbar.Styles.TV.TabbarWithTitle;
     return(toolbar);
 }
Exemplo n.º 2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         Element.PagesChanged -= OnElementPagesChanged;
         if (_outterLayout != null)
         {
             _outterLayout.Unrealize();
             _outterLayout = null;
         }
         if (_toolbar != null)
         {
             _toolbar.Selected      -= OnToolbarItemSelected;
             _scroller.PageScrolled -= OnItemPageScrolled;
             _toolbar.Unrealize();
             _toolbar = null;
         }
     }
     base.Dispose(disposing);
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public static EToolbar SetNavigationBarStyle(this EToolbar toolbar)
 {
     toolbar.Style = ThemeConstants.Toolbar.Styles.NavigationBar;
     return(toolbar);
 }
Exemplo n.º 5
0
        protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e)
        {
            if (_toolbar == null)
            {
                //Create box that holds toolbar and selected content
                _outterLayout = new Box(Forms.NativeParent)
                {
                    AlignmentX   = -1,
                    AlignmentY   = -1,
                    WeightX      = 1,
                    WeightY      = 1,
                    IsHorizontal = false,
                };
                _outterLayout.Show();

                //Create toolbar that is placed inside the _outterLayout
                _toolbar = new EToolbar(Forms.NativeParent)
                {
                    AlignmentX    = -1,
                    WeightX       = 1,
                    SelectionMode = ToolbarSelectionMode.Always,
                };

                if (DeviceInfo.Idiom == DeviceIdiom.Phone)
                {
                    //Set ShrinkMode to Expand as defauly only for Mobile profile
                    _toolbar.ShrinkMode = ToolbarShrinkMode.Expand;
                }
                else if (DeviceInfo.Idiom == DeviceIdiom.TV)
                {
                    //According to TV UX Guideline, toolbar style should be set to "tabbar_with_title" in case of TabbedPage only for TV profile.
                    _toolbar.SetTVTabBarWithTitleStyle();
                }

                _toolbar.Show();
                //Add callback for Toolbar item selection
                _toolbar.Selected += OnToolbarItemSelected;
                _outterLayout.PackEnd(_toolbar);

                _scroller = new Scroller(_outterLayout)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                    HorizontalPageScrollLimit = 1,
                    ScrollBlock = ScrollBlock.Vertical,
                    HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible
                };
                _scroller.SetPageSize(1.0, 1.0);
                _scroller.PageScrolled += OnItemPageScrolled;

                _innerBox = new Box(Forms.NativeParent)
                {
                    AlignmentX   = -1,
                    AlignmentY   = -1,
                    WeightX      = 1,
                    WeightY      = 1,
                    IsHorizontal = true,
                };

                _innerBox.SetLayoutCallback(OnInnerLayoutUpdate);

                _scroller.SetContent(_innerBox);
                _scroller.Show();

                _outterLayout.PackEnd(_scroller);

                SetNativeView(_outterLayout);
                UpdateTitle();
            }

            if (e.OldElement != null)
            {
                e.OldElement.PagesChanged -= OnElementPagesChanged;
                _isInitialized             = false;
            }
            if (e.NewElement != null)
            {
                e.NewElement.PagesChanged += OnElementPagesChanged;
            }

            base.OnElementChanged(e);
        }