Exemple #1
0
        public void NavigateTo(MainMenuItemData menu, bool force, params object[] args)
        {
            if (!force && _currentPage == menu)
            {
                return;
            }

            if (menu.IsLoginRequired && AppModel.Instance.CurrentUser == null)
            {
                AppProvider.PopUpFactory.ShowMessage(AppResources.LoginFirstMessage, AppResources.Warning);
                return;
            }

            _currentPage = menu;

            if (CurrentPage != null)
            {
                PreviousPage = CurrentPage;
            }

            CurrentPage = (Page)Activator.CreateInstance(menu.TargetType, args);

            var navPage = new NavigationPage(CurrentPage);

            navPage.BarBackgroundColor = AppResources.MenuColor;
            navPage.BarTextColor       = AppResources.MenuTitleTextColor;
            Detail = navPage;

            IsPresented = false;
        }
Exemple #2
0
        private MainMenuButton GetMenuButton(MainMenuItemData data)
        {
            var button = new MainMenuButton(data);

            button.Select += OnMenuItemSelected;
            return(button);
        }
Exemple #3
0
 private void OnMenuItemSelected(MainMenuItemData item)
 {
     if (ItemSelected != null)
     {
         ItemSelected(item);
     }
 }
Exemple #4
0
        public MainMenuButton(MainMenuItemData data)
        {
            Data = data;
            var itemVerticalLayout = new StackLayout()
            {
                Orientation = StackOrientation.Vertical
            };

            if (Data.HasTopBorder)
            {
                itemVerticalLayout.Children.Add(GetBoxView(1, AppProvider.Screen.Width));
            }

            var menuItemContentView = new ContentView()
            {
                BackgroundColor = AppResources.MenuColor,
                Padding         = new Thickness(14, 0, 0, 0),
                HeightRequest   = 30,
                VerticalOptions = LayoutOptions.Center,
                Content         = new Label()
                {
                    Text = Data.Title,
                    HorizontalTextAlignment = TextAlignment.Start,
                    TextColor = Color.White,
                    FontSize  = 18
                }
            };

            TapGestureRecognizer gesture = new TapGestureRecognizer();

            gesture.Tapped += OnButtonClicked;
            menuItemContentView.GestureRecognizers.Add(gesture);

            itemVerticalLayout.Children.Add(menuItemContentView);

            if (Data.HasBottomBorder)
            {
                itemVerticalLayout.Children.Add(GetBoxView(1, AppProvider.Screen.Width));
            }

            Content = itemVerticalLayout;
        }
Exemple #5
0
 private void OnLogOut(MainMenuItemData obj)
 {
     UserController.Instance.Logout();
 }