Esempio n. 1
0
        public ShellApplication()
        {
            RootPage.Instance.DeviceBackButtonPressed += OnDeviceBackButtonPressed;

            // Create popup layout for popups
            Popup.PopupLayout = new PopupLayout();

            _flyoutMenu = new FlyoutMenu();
            _flyoutMenu.IsMainMenuOpenChanging += (object sender, bool isOpen) =>
            {
                IsMainMenuOpen = isOpen;
                IsMainMenuOpenChanging?.Invoke(sender, isOpen);
            };
            _flyoutMenu.IsMainMenuOpenChanged += (object sender, bool isOpen) =>
            {
                IsMainMenuOpenChanged?.Invoke(sender, isOpen);
            };

            _flyoutMenu.IsSubMenuOpenChanged += (object sender, bool isOpen) =>
            {
                IsSubMenuOpenChanged?.Invoke(sender, isOpen);
            };
            _flyoutMenu.IsSubMenuOpenChanging += (object sender, bool isOpen) =>
            {
                IsSubMenuOpen = isOpen;
                IsSubMenuOpenChanging?.Invoke(sender, isOpen);
            };

            // Content

            _navigationPage     = new NavigationPage();
            _flyoutMenu.Content = _navigationPage;
            _navigationPage.MenuButtonTapped += (s, a) =>
            {
                _flyoutMenu.IsMainMenuOpen = true;
            };

            // MainMenu

            _mainMenuNavigationPage = new NavigationPage();
            _mainMenuNavigationPage.HasPagesChanged += (object s, bool hasPages) =>
            {
                if (hasPages)
                {
                    _flyoutMenu.MainMenu = _mainMenuNavigationPage;
                }
                else
                {
                    _flyoutMenu.MainMenu = null;
                }
            };

            // SubMenu

            _subMenuNavigationPage = new NavigationPage();
            _subMenuNavigationPage.HasPagesChanged += (object s, bool hasPages) =>
            {
                if (hasPages)
                {
                    _flyoutMenu.SubMenu = _subMenuNavigationPage;
                }
                else
                {
                    _flyoutMenu.SubMenu = null;
                }
            };

            // Modal

            _modalNavigationPage           = new NavigationPage();
            _modalNavigationPage.IsVisible = false;

            _modalNavigationPage.HasPagesChanged += (object s, bool hasPages) =>
            {
                _modalNavigationPage.IsVisible = hasPages;
            };

            // Titlebar

            _titleBarSeparator = new BoxView();
            _titleBarSeparator.VerticalOptions = LayoutOptions.Start;
            _titleBarSeparator.HeightRequest   = TitleBarSeparatorThickness;
            _titleBarSeparator.BackgroundColor = TitleBarSeparatorColor;

            // Add navigation page and popup layout to root page content
            StackLayout m_rootLayout = new StackLayout();

            m_rootLayout.Orientation = StackOrientations.Depth;
            m_rootLayout.Children.Add(_flyoutMenu);
            m_rootLayout.Children.Add(_modalNavigationPage);
            m_rootLayout.Children.Add(Popup.PopupLayout);
            m_rootLayout.Children.Add(_titleBarSeparator);

            // Add to content
            RootPage.Instance.Content = m_rootLayout;
            MainPage = RootPage.Instance;
        }
Esempio n. 2
0
 private void OnIsMainMenuOpenChanging(object sender, bool e)
 {
     IsMainMenuOpenChanging?.Invoke(sender, e);
 }