コード例 #1
0
        private void AddTapGestures()
        {
            // for nav bar
            // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            var tapGestureRecognizer1 = new TapGestureRecognizer();

            tapGestureRecognizer1.Tapped += async(s, e) => {
                await Navigation.PushAsync(new GreetingPage());
            };
            AboutMeButton.GestureRecognizers.Add(tapGestureRecognizer1);

            var tapGestureRecognizer2 = new TapGestureRecognizer();

            tapGestureRecognizer2.Tapped += async(s, e) => {
                await Navigation.PushAsync(new ListViewPage());
            };
            ListViewButton.GestureRecognizers.Add(tapGestureRecognizer2);

            var tapGestureRecognizer3 = new TapGestureRecognizer();

            tapGestureRecognizer3.Tapped += async(s, e) => {
                if (App.User.photoURIs.Count < 1)
                {
                    await GooglePhotoService.GetPhotos();
                }
                await Navigation.PushAsync(new MonthlyViewPage());
            };
            MyPhotosButton.GestureRecognizers.Add(tapGestureRecognizer3);
            // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        }
コード例 #2
0
        private void AddTapGestures()
        {
            var tapGestureRecognizer1 = new TapGestureRecognizer();

            tapGestureRecognizer1.Tapped += async(s, e) => {
                ReloadImage.GestureRecognizers.RemoveAt(0);
                ReloadImage.Source = "redoGray.png";
                await RefreshPage();

                ReloadImage.Source = "redo.png";
                ReloadImage.GestureRecognizers.Add(tapGestureRecognizer1);
            };
            ReloadImage.GestureRecognizers.Add(tapGestureRecognizer1);

            var tapGestureRecognizer2 = new TapGestureRecognizer();

            tapGestureRecognizer2.Tapped += async(s, e) => {
                await Navigation.PushAsync(new GreetingPage());
            };
            AboutMeButton.GestureRecognizers.Add(tapGestureRecognizer2);

            var tapGestureRecognizer3 = new TapGestureRecognizer();

            tapGestureRecognizer3.Tapped += async(s, e) => {
                if (App.User.photoURIs.Count < 1)
                {
                    await GooglePhotoService.GetPhotos();
                }
                await Navigation.PushAsync(new MonthlyViewPage());
            };
            MyPhotosButton.GestureRecognizers.Add(tapGestureRecognizer3);

            var tapGestureRecognizer4 = new TapGestureRecognizer();

            tapGestureRecognizer4.Tapped += async(s, e) => {
                await Navigation.PushAsync(new GoalsRoutinesTemplate());
            };
            MyDayButton.GestureRecognizers.Add(tapGestureRecognizer4);
        }
コード例 #3
0
        private async void SetupUI()
        {
            Grid   controlGrid  = new Grid();
            int    rowLength    = 3;
            double gridItemSize = (Application.Current.MainPage.Width / rowLength) - (1.2 * rowLength);

            controlGrid.RowDefinitions.Add(new RowDefinition {
                Height = gridItemSize
            });
            for (int i = 0; i < rowLength; i++)
            {
                controlGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = gridItemSize
                });
            }
            var photoCount = 0;

            try
            {
                foreach (List <string> list in App.User.photoURIs)
                {
                    string photoURI     = list[0];
                    string date         = list[1];
                    string description  = list[2];
                    string creationTime = list[3];
                    string id           = list[4];
                    string note         = list[5];

                    CachedImage webImage = new CachedImage
                    {
                        Source          = Xamarin.Forms.ImageSource.FromUri(new Uri(photoURI)),
                        Transformations = new List <ITransformation>()
                        {
                            new CropTransformation(),
                        },
                    };

                    var tapGestureRecognizer = new TapGestureRecognizer();
                    tapGestureRecognizer.Tapped += async(s, e) => {
                        await Navigation.PushAsync(new PhotoDisplayPage(webImage, date, description, id, creationTime, note));
                    };
                    webImage.GestureRecognizers.Add(tapGestureRecognizer);
                    var indicator = new ActivityIndicator
                    {
                        Color         = Color.Gray,
                        WidthRequest  = gridItemSize,
                        HeightRequest = gridItemSize,
                    };
                    indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
                    indicator.BindingContext = webImage;

                    controlGrid.Children.Add(indicator, photoCount % rowLength, photoCount / rowLength);
                    controlGrid.Children.Add(webImage, photoCount % rowLength, photoCount / rowLength);
                    photoCount++;
                }
            }
            catch (NullReferenceException e)
            {
                var googleService = new GoogleService();
                if (await googleService.RefreshToken())
                {
                    Console.WriteLine("RefreshToken Done!");
                    App.User.photoURIs = await GooglePhotoService.GetPhotos();
                }
            }

            //update calendar
            DateTime localDate    = DateTime.Now;
            Calendar myCal        = CultureInfo.InvariantCulture.Calendar;
            var      currentYear  = myCal.GetYear(localDate);
            var      currentMonth = myCal.GetMonth(localDate);
            var      currentDay   = myCal.GetDayOfWeek(localDate);

            Year           = currentYear;
            Month          = currentMonth;
            yearLabel.Text = Year + "";
            setMonthLabel(Month);
            SetCalendar(currentYear, currentMonth);

            //add navigation bar
            photoScrollView.HeightRequest = Application.Current.MainPage.Height - CalendarContent.Height - NavBar.Height;

            if (App.User.photoURIs != null)
            {
                photoScrollView.Content = controlGrid;
            }
            else
            {
                Label noPhotosLabel = new Label()
                {
                    Text              = "No photos to Show",
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    TextColor         = Color.DimGray
                };
                photoScrollView.Content = noPhotosLabel;
            }
            AddTapGestures();
        }