public ShellSectionNavigation(IFlyoutController flyoutController, ShellSection section) : base(Forms.NativeParent)
        {
            _section = section;
            _section.PropertyChanged += OnSectionPropertyChanged;
            _rootPage = ((IShellContentController)_section.CurrentItem).GetOrCreateContent();

            _navBar = new ShellNavBar(flyoutController, this);
            _navBar.Show();

            var renderer = CreateShellSection(section);

            renderer.Control.Show();
            _navigationStack.AddLast(renderer.Control);
            _pageToNative[_rootPage]        = renderer.Control;
            _nativeToPage[renderer.Control] = _rootPage;

            IShellSectionController controller = _section as IShellSectionController;

            controller.NavigationRequested += OnNavigationRequested;
            controller.AddDisplayedPageObserver(this, UpdateDisplayedPage);

            PackEnd(_navBar);
            PackEnd(renderer.Control);
            LayoutUpdated += OnLayoutUpdated;
            ((IShellController)_section.Parent.Parent).AddAppearanceObserver(this, _section);
        }
Ejemplo n.º 2
0
        void InitializeComponent()
        {
            SetAlignment(-1, -1);
            SetWeight(1, 1);
            SetLayoutCallback(OnLayout);

            _viewStack = new SimpleViewStack(Forms.NativeParent);
            if (Device.Idiom == TargetIdiom.Phone)
            {
                _viewStack.BackgroundColor = ElmSharp.Color.White;
            }
            _viewStack.Show();
            PackEnd(_viewStack);

            _navBar = new ShellNavBar();
            _navBar.Show();
            PackEnd(_navBar);

            IShellSectionController controller = ShellSection;

            controller.NavigationRequested += OnNavigationRequested;
            controller.AddDisplayedPageObserver(this, UpdateDisplayedPage);
            ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection);
            ((IShellController)Shell.Current).AddFlyoutBehaviorObserver(_navBar);

            _shellSectionRenderer = CreateShellSectionRenderer(ShellSection);
            _shellSectionRenderer.NativeView.Show();
            _viewStack.Push(_shellSectionRenderer.NativeView);

            Device.BeginInvokeOnMainThread(() =>
            {
                (_shellSectionRenderer.NativeView as Widget)?.SetFocus(true);
            });
        }
Ejemplo n.º 3
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                (Shell.Current as IShellController).RemoveAppearanceObserver(this);
                (Shell.Current as IShellController).RemoveFlyoutBehaviorObserver(_navBar);
                if (ShellSection != null)
                {
                    IShellSectionController controller = ShellSection;
                    controller.NavigationRequested -= OnNavigationRequested;
                    controller.RemoveDisplayedPageObserver(this);
                }
                if (_currentPage != null)
                {
                    _currentPage.PropertyChanged -= OnPagePropertyChanged;
                }
                if (_navBar != null)
                {
                    _navBar.Dispose();
                    _navBar = null;
                }
                Unrealize();
            }
            _disposed = true;
        }
Ejemplo n.º 4
0
 public static double GetDefaultTitleFontSize(this ShellNavBar navBar)
 {
     if (s_shellNavBarTitleFontSize > 0)
     {
         return(s_shellNavBarTitleFontSize);
     }
     return(s_shellNavBarTitleFontSize = CalculateDoubleScaledSizeInLargeScreen(23));
 }
Ejemplo n.º 5
0
 public static double GetDefaultMargin(this ShellNavBar navBar)
 {
     if (s_shellNavBarDefaultMargin > 0)
     {
         return(s_shellNavBarDefaultMargin);
     }
     return(s_shellNavBarDefaultMargin = CalculateDoubleScaledSizeInLargeScreen(10));
 }
Ejemplo n.º 6
0
 public static double GetDefaultMenuSize(this ShellNavBar navBar)
 {
     if (s_shellNavBarDefaultMenuSize > 0)
     {
         return(s_shellNavBarDefaultMenuSize);
     }
     return(s_shellNavBarDefaultMenuSize = CalculateDoubleScaledSizeInLargeScreen(Device.Idiom == TargetIdiom.TV ? 70 : 40));
 }
Ejemplo n.º 7
0
 public static double GetDefaultHeight(this ShellNavBar navBar)
 {
     if (s_shellNavBarDefaultHeight > 0)
     {
         return(s_shellNavBarDefaultHeight);
     }
     return(s_shellNavBarDefaultHeight = CalculateDoubleScaledSizeInLargeScreen(70));
 }
Ejemplo n.º 8
0
 public static double GetDefaultMenuSize(this ShellNavBar navBar)
 {
     if (s_shellNavBarDefaultMenuSize > 0)
     {
         return(s_shellNavBarDefaultMenuSize);
     }
     return(s_shellNavBarDefaultMenuSize = CalculateDoubleScaledSizeInLargeScreen(40));
 }