public BackgroundPage()
 {
     InitializeComponent();
     BackgroundImage = MediaResoursesHelper.GetMediaPath(CommonData.BGSource);
     _viewModel      = App.Container.Resolve(typeof(BackgroundPageViewModel), "backgroundPageViewModel") as BackgroundPageViewModel;
     _viewModel.Msg  = defaultMsg;
     BindingContext  = _viewModel;
 }
        public FactsPage(TypeOfFact factType)
        {
            InitializeComponent();
            _factType       = factType;
            _viewModel      = App.Container.Resolve(typeof(FactsViewModel), "factsViewModel") as FactsViewModel;
            BindingContext  = _viewModel;
            Title           = _viewModel.GetTitle(_factType);
            BackgroundImage = CommonData.IsNightMode ? MediaResoursesHelper.GetMediaPath("bg_dark.jpg") : MediaResoursesHelper.GetMediaPath(CommonData.BGSource);

            _viewModel.IsLoading = true;
            Task.Run(() => { InitialFirstFacts(); });
        }
Example #3
0
 public LikeButton()
 {
     WidthRequest    = weight;
     HeightRequest   = weight;
     VerticalOptions = LayoutOptions.Center;
     Source          = CommonData.IsNightMode ? MediaResoursesHelper.GetMediaPath("like_dark_icon.png") : MediaResoursesHelper.GetMediaPath("like_light_icon.png");
     GestureRecognizers.Add(
         new TapGestureRecognizer
     {
         Command = new Command(async() =>
         {
             MessagingCenter.Send <LikeButton>(this, MessagingCenterConstants.LikeButtonPushed);
             await this.ScaleTo(0.95, 100);
             await this.ScaleTo(1, 100);
         })
     });
 }
        private void SetChoosenBG(string name)
        {
            var frames = MainWrapper.Children.Where(x => x is BGPrevFrame);

            _viewModel.BGName = name;
            _viewModel.Msg    = defaultMsg;
            Device.BeginInvokeOnMainThread(() =>
            {
                foreach (BGPrevFrame frame in frames)
                {
                    frame.BackgroundColor = frame.BGName == name
                        ? Color.FromHex("#6f43bd")
                        : Color.Transparent;
                }
                BackgroundImage = MediaResoursesHelper.GetMediaPath(name);
            });
        }
Example #5
0
        public NextButton_Left()
        {
            Source          = CommonData.IsNightMode ? MediaResoursesHelper.GetMediaPath("next_dark_icon.png") : MediaResoursesHelper.GetMediaPath("next_light_icon.png");
            WidthRequest    = weight;
            HeightRequest   = weight;
            Rotation        = 180;
            VerticalOptions = LayoutOptions.Center;

            GestureRecognizers.Add(
                new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    MessagingCenter.Send <NextButton_Left>(this, MessagingCenterConstants.NextButtonPushed);
                    await this.ScaleTo(0.95, 100);
                    await this.ScaleTo(1, 100);
                })
            });
        }
        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);
        }