Example #1
0
        public MainPage()
        {
            InitializeComponent();

            menuList = new List <MasterPageItem>
            {
                new MasterPageItem {
                    Title = "Сонник", Icon = "dreamBook_menuIcon.png", TargetType = typeof(MeansSearchPage)
                },
                new MasterPageItem {
                    Title = "Закладки", Icon = "dreamBook_menuIcon.png", TargetType = typeof(MeansSearchPage)
                },
                new MasterPageItem {
                    Title = "Календарь", Icon = "dreamBook_menuIcon.png", TargetType = typeof(StatisticPage)
                }
            };

            navigationDrawerList.ItemsSource = menuList;
            Detail = NaviagationService.CreateNavigationPage(typeof(WelcomePage));
            if (Device.OS != TargetPlatform.Android)
            {
                Icon = "Assets/burger.png";
            }
            MasterBehavior = MasterBehavior.Popover;
        }
Example #2
0
        private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var  item = (MasterPageItem)e.SelectedItem;
            Type page = item.TargetType;

            Detail      = NaviagationService.CreateNavigationPage(page);
            IsPresented = false;
        }
        public MainPage()
        {
            InitializeComponent();

            Detail = NaviagationService.CreateNavigationPage(new FactsPage(TypeOfFact.All));
            if (Device.OS != TargetPlatform.Android)
            {
                Icon = MediaResoursesHelper.GetMediaPath("burger.png");
            }
            MasterBehavior = MasterBehavior.Popover;
            _viewModel     = App.Container.Resolve(typeof(MasterPageViewModel), "masterPageViewModel") as MasterPageViewModel;
            BindingContext = _viewModel;
            SetMenuPanel();
            IsPresentedChanged += (sender, args) => { SetMenuPanel(); };
            var logoImage = new Image
            {
                Source            = MediaResoursesHelper.GetMediaPath("Logo.png"),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                WidthRequest      = 150
            };

            AllFactsTitle = new Label
            {
                TextColor          = Color.White,
                FontSize           = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                GestureRecognizers = { new TapGestureRecognizer {
                                           Command = new Command(() =>
                        {
                            Task.Run(async() =>
                            {
                                await AllFactsTitle.FadeTo(0.5);
                                await AllFactsTitle.FadeTo(1);
                            });
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                Detail      = NaviagationService.CreateNavigationPage(new FactsPage(TypeOfFact.All));
                                IsPresented = false;
                            });
                        })
                                       } }
            };
            ReadedFactsTitle = new Label
            {
                TextColor          = Color.White,
                FontSize           = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                GestureRecognizers = { new TapGestureRecognizer {
                                           Command = new Command(() =>
                        {
                            Task.Run(async() =>
                            {
                                await ReadedFactsTitle.FadeTo(0.5);
                                await ReadedFactsTitle.FadeTo(1);
                            });
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                Detail      = NaviagationService.CreateNavigationPage(new FactsPage(TypeOfFact.Readed));
                                IsPresented = false;
                            });
                        })
                                       } }
            };
            FavoriteFactsTitle = new Label
            {
                TextColor          = Color.White,
                FontSize           = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                GestureRecognizers = { new TapGestureRecognizer {
                                           Command = new Command(() =>
                        {
                            Task.Run(async() =>
                            {
                                await FavoriteFactsTitle.FadeTo(0.5);
                                await FavoriteFactsTitle.FadeTo(1);
                            });
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                Detail      = NaviagationService.CreateNavigationPage(new FactsPage(TypeOfFact.Favorite));
                                IsPresented = false;
                            });
                        })
                                       } }
            };
            NightModeTitle = new Label
            {
                TextColor          = Color.White,
                FontSize           = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                Margin             = new Thickness(0, 30, 0, 0),
                GestureRecognizers = { new TapGestureRecognizer {
                                           Command = new Command(() =>
                        {
                            Task.Run(async() =>
                            {
                                await NightModeTitle.FadeTo(0.5);
                                await NightModeTitle.FadeTo(1);
                            });
                            CommonData.IsNightMode = !CommonData.IsNightMode;
                            SetMenuPanel();
                            Task.Run(() =>
                            {
                                _viewModel.SaveSettings();
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    Detail      = NaviagationService.CreateNavigationPage(new FactsPage(TypeOfFact.All));
                                    IsPresented = false;
                                });
                            });
                        })
                                       } }
            };

            BackgroundTitle = new Label
            {
                TextColor          = Color.White,
                FontSize           = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                Text               = "Set background",
                GestureRecognizers = { new TapGestureRecognizer {
                                           Command = new Command(() =>
                        {
                            Task.Run(async() =>
                            {
                                await BackgroundTitle.FadeTo(0.5);
                                await BackgroundTitle.FadeTo(1);
                            });
                            Task.Run(() =>
                            {
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    Detail      = NaviagationService.CreateNavigationPage(new BackgroundPage());
                                    IsPresented = false;
                                });
                            });
                        })
                                       } }
            };

            AllFactsTitle.SetBinding(Label.TextProperty, "AllFactsTitle");
            ReadedFactsTitle.SetBinding(Label.TextProperty, "ReadedFactsTitle");
            FavoriteFactsTitle.SetBinding(Label.TextProperty, "FavoriteFactsTitle");
            NightModeTitle.SetBinding(Label.TextProperty, "NightModeTitle");
            BackgroundTitle.SetBinding(Label.IsVisibleProperty, "BackgroundTitleIsVisible");

            Wrapper.Children.Add(logoImage);
            Wrapper.Children.Add(AllFactsTitle);
            Wrapper.Children.Add(ReadedFactsTitle);
            Wrapper.Children.Add(FavoriteFactsTitle);
            Wrapper.Children.Add(NightModeTitle);
            Wrapper.Children.Add(BackgroundTitle);
        }
 private void SetToolbar(FactFrame fact)
 {
     NaviagationService.SetToolbarItems(fact, ToolbarItems, FavoriteAction, async() => { await ShareAction(); });
 }