Ejemplo n.º 1
0
        public ProfileImageViewPage(PersonFullWebModel person)
        {
            /// ok
            ///
            Button buttonOk = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "OK"
            };

            buttonOk.Clicked += buttonOk_Clicked;
            var panelOk = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                //BackgroundColor = Config.ColorDarkGrayBackground,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Children          =
                {
                    buttonOk,
                }
            };

            /// Images
            ///

            imageLarge = new Image()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
            };

            /// content
            ///
            Title                = person.Name;
            this.Padding         = new Thickness(0);
            this.BackgroundColor = Config.ColorGrayBackground;
            var grid = new Grid()
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            grid.Children.Add(imageLarge, 0, 0);
            this.Content = grid;

            imageLarge.Source = App.ImagesService.GetImageSource(person.Picture, BackgroundEnum.Background1, true);
        }
Ejemplo n.º 2
0
        public InfoPage()
        {
            Title = "Internal Info";

            string label1Text = "Mode: " + (Config.IsProduction ? "production" : "debug") + "\r\n";

            label1Text += "Tablet: " + (Config.IsTablet ? "tablet" : "phone") + "\r\n";
            label1Text += "OSVersion: " + Config.OSVersion + "  (major= " + Config.OSVersionMajor.ToString() + ")\r\n";
            label1Text += "Version: " + SnookerBybMobileVersions.Current.ToString() + "\r\n";
            label1Text += "Web api: " + App.WebService.WebApiUrl;
            this.label1 = new BybLabel()
            {
                Text = label1Text,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                TextColor         = Color.Black,
            };

            this.label2 = new BybLabel()
            {
                Text = "",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                TextColor         = Color.Black,
            };

            Button buttonClose = new BybButton()
            {
                WidthRequest      = 100,
                Text              = "Close",
                Style             = (Style)App.Current.Resources["LargeButtonStyle"],
                HorizontalOptions = LayoutOptions.Center,
            };

            buttonClose.Clicked += (s1, e1) => {
                App.Navigator.NavPage.Navigation.PopModalAsync();
            };

            this.Content = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                BackgroundColor   = Config.ColorGrayBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Spacing           = 10,
                Padding           = new Thickness(20),
                Children          =
                {
                    this.label1,
                    this.label2,
                    buttonClose,
                }
            };
        }
Ejemplo n.º 3
0
        public virtual void Fill(List <T> list)
        {
            this.List           = list;
            this.ListShown      = null;
            this.buttonShowMore = null;

            this.Children.Clear();
            this.Children.Add(this.panelTop);

            if (list == null)
            {
                this.labelFailedToLoad = new BybLabel()
                {
                    TextColor               = IsDarkBackground ? Config.ColorTextOnBackground : Config.ColorBlackTextOnWhite,
                    HeightRequest           = 60,
                    HorizontalOptions       = LayoutOptions.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    Text = this.TextForFailedToLoad,
                };
                this.Children.Add(this.labelFailedToLoad);
                return;
            }

            if (list.Count() == 0)
            {
                this.labelEmpty = new BybLabel()
                {
                    TextColor               = IsDarkBackground ? Config.ColorTextOnBackground : Config.ColorBlackTextOnWhite,
                    HeightRequest           = 60,
                    HorizontalOptions       = LayoutOptions.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    Text = this.TextForEmpty,
                };
                this.Children.Add(this.labelEmpty);
                return;
            }

            this.ListShown = List.Take(MaxCountToShowByDefault).ToList();

            foreach (var item in this.ListShown)
            {
                this.Children.Add(this.createViewForSingleItem(item));
            }

            this.addOrRemoveButtonShowMore();
        }
Ejemplo n.º 4
0
        void addPocketedBall(int ballScore)
        {
            Color color       = Config.BallColors[ballScore];
            Color borderColor = color;

            if (ballScore == 7)
            {
                borderColor = Color.Gray;
            }
            Color textColor = Color.White;

            if (ballScore == 2)
            {
                textColor = Color.Black;
            }

            var ball = new BybButton
            {
                Text                 = "",
                BackgroundColor      = color,
                BorderColor          = borderColor,
                FontFamily           = Config.FontFamily,
                FontSize             = Config.LargerFontSize,
                TextColor            = textColor,
                BorderWidth          = 1,
                BorderRadius         = (int)(Config.SmallBallSize / 2),
                HeightRequest        = Config.SmallBallSize,
                MinimumHeightRequest = Config.SmallBallSize,
                WidthRequest         = Config.SmallBallSize,
                MinimumWidthRequest  = Config.SmallBallSize,
                VerticalOptions      = LayoutOptions.Center
            };

            panelPocketedBallsInner.Children.Add(ball);

            this.updateDeleteButton();
            this.updateFoulBox();
            this.pronounceScore();
        }
Ejemplo n.º 5
0
        void addOrRemoveButtonShowMore()
        {
            if (this.buttonShowMore != null)
            {
                this.Children.Remove(buttonShowMore);
                this.buttonShowMore = null;
            }

            if (this.ListShown == null || this.List == null || this.ListShown.Count >= this.List.Count)
            {
                return;
            }

            this.buttonShowMore = new BybButton()
            {
                Text              = TextForShowMore,
                Style             = (Style)App.Current.Resources["SimpleButtonStyle"],
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest     = 50,
                TextColor         = IsDarkBackground ? Color.White : Config.ColorBlackTextOnWhite,
            };
            buttonShowMore.Clicked += buttonShowMore_Clicked;
            this.Children.Add(this.buttonShowMore);
        }
Ejemplo n.º 6
0
        public NewsfeedControl()
        {
            this.Spacing         = 0;
            this.BackgroundColor = Config.ColorGrayBackground;
            this.Padding         = new Thickness(0);

            /// community selector
            ///
            this.communitySelectorControl = new CommunitySelectorControl();
            this.communitySelectorControl.SelectionChanged += communitySelectorControl_SelectionChanged;
            this.Children.Add(new StackLayout()
            {
                Padding         = new Thickness(0, 5, 0, 10),
                HeightRequest   = Config.LargeButtonsHeight,// 40,
                Spacing         = 1,
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Config.ColorGrayBackground,
                Children        =
                {
                    communitySelectorControl,
                }
            });

            /// buttons
            ///
            Button buttonPost = new BybButton()
            {
                Text = "Post", Style = (Style)App.Current.Resources["BlackButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand
            };
            Button buttonGameHost = new BybButton()
            {
                Text = "New event", Style = (Style)App.Current.Resources["BlackButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonPost.Clicked += (s1, e1) =>
            {
                if (this.CurrentCommunity == null || this.CurrentCommunity.Country == null)
                {
                    App.Navigator.DisplayAlertRegular("You don't have enough contributions to post on the Planet Earth level. Select a smaller community to post.");
                    return;
                }

                if (App.Navigator.GetOpenedPage(typeof(NewPostPage)) != null)
                {
                    return;
                }

                NewPostPage dlg = new NewPostPage(this.CurrentCommunity.Country, this.CurrentCommunity.MetroID);
                App.Navigator.NavPage.Navigation.PushModalAsync(dlg);
                dlg.Disappearing += (s2, e2) =>
                {
                    this.reloadAsync(!dlg.Posted);
                };
            };
            buttonGameHost.Clicked += (s1, e1) =>
            {
                if (App.Navigator.GetOpenedPage(typeof(NewGameHostPage)) != null)
                {
                    return;
                }

                NewGameHostPage dlg = new NewGameHostPage();
                App.Navigator.NavPage.Navigation.PushModalAsync(dlg);
                dlg.Disappearing += (s2, e2) =>
                {
                    this.reloadAsync(!dlg.GameHostCreated);
                };
            };
            this.Children.Add(new StackLayout()
            {
                Spacing           = 1,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(10, 0, 10, 0),
                Children          =
                {
                    buttonGameHost,
                    buttonPost,
                }
            });

            this.list = new ListOfNewsfeedItemsControl();
            this.list.NeedsARefresh += () =>
            {
                this.reloadAsync(false);
            };
            this.Children.Add(list);
        }
Ejemplo n.º 7
0
        public EditProfilePage(bool showCancelButton, bool showSecurityPanel)
        {
            this.showCancelButton = showCancelButton;

            // name panel
            entryName = new BybStandardEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                TextColor         = Config.ColorBlackTextOnWhite,
                Placeholder       = "(required)",
            };
            entryName.Completed += (s1, e1) => { entrySnookerAbout.Focus(); };
            var panelName = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Name", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    entryName,
                }
            };

            // about panel
            entrySnookerAbout = new BybStandardEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                TextColor         = Config.ColorBlackTextOnWhite,
                Placeholder       = "(optional)",
            };
            entrySnookerAbout.Completed += (s1, e1) =>
            {
                if (this.athlete.MetroID <= 0)
                {
                    buttonFind_Clicked(s1, e1);
                }
            };
            var panelAbout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "About", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    entrySnookerAbout,
                }
            };

            // ask the phone
            this.buttonFind = new BybButton()
            {
                Text = "Ask the " + (Config.IsTablet ? "tablet" : "phone"),
                HorizontalOptions = LayoutOptions.Center,
                Style             = (Style)App.Current.Resources["SimpleButtonStyle"],
            };
            buttonFind.Clicked += buttonFind_Clicked;
            labelStatus         = new BybLabel()
            {
                VerticalTextAlignment = TextAlignment.Center, TextColor = Config.ColorBlackTextOnWhite
            };

            // country panel
            Image imageCountry = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };

            this.pickerCountry = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Title             = "Select country"
            };
            this.pickerCountry.SelectedIndexChanged += pickerCountry_SelectedIndexChanged;
            var panelCountry = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Country", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    this.pickerCountry,
                    imageCountry,
                }
            };

            panelCountry.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pickerCountry.Focus(); })
            });

            // metro panel
            Image imageMetro = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };

            this.pickerMetro = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Title             = "Select city"
            };
            this.pickerMetro.SelectedIndexChanged   += pickerMetro_SelectedIndexChanged;
            this.pickerCountry.SelectedIndexChanged += pickerCountry_SelectedIndexChanged;
            var panelMetro = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "City", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    this.pickerMetro,
                    imageMetro,
                }
            };

            // pin panel
            this.labelPin = new BybLabel()
            {
                Text                    = "Set your PIN code",
                TextColor               = Color.Black,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Image imagePin = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelPin = new StackLayout
            {
                IsVisible         = showSecurityPanel,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "PIN", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelPin,
                    imagePin,
                }
            };

            panelPin.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pinClicked(); })
            });

            // password panel
            Label labelPassword = new BybLabel()
            {
                Text                    = "Tap to reset",
                TextColor               = Color.Black,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Image imagePassword = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelPassword = new StackLayout
            {
                IsVisible         = showSecurityPanel,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Password", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelPassword,
                    imagePassword,
                }
            };

            panelPassword.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.passwordClicked(); })
            });

            // e-mail panel
            labelEmail = new BybLabel()
            {
                Text                    = "E-mail",
                TextColor               = Color.Black,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Image imageEmail = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelEmail = new StackLayout
            {
                IsVisible         = showSecurityPanel,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "E-mail", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelEmail,
                    imageEmail,
                }
            };

            panelEmail.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.emailClicked(); })
            });

            // ok, cancel
            Button buttonOk = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "OK"
            };
            Button buttonCancel = new BybButton {
                Style = (Style)App.Current.Resources["BlackButtonStyle"], Text = "Cancel"
            };

            buttonOk.Clicked     += buttonOk_Clicked;
            buttonCancel.Clicked += buttonCancel_Clicked;
            if (showCancelButton == false)
            {
                buttonCancel.IsVisible = false;
            }

            var stackLayout = new StackLayout
            {
                Padding  = new Thickness(0),
                Spacing  = 0,
                Children =
                {
                    new BybTitle(showCancelButton ? "Edit Profile" : "Your Profile")
                    {
                        VerticalOptions = LayoutOptions.Start
                    },

                    new StackLayout
                    {
                        Padding     = new Thickness(15, 15, 15, 0),
                        Spacing     = 0,
                        Orientation = StackOrientation.Vertical,
                        Children    =
                        {
                            panelName,
                            panelAbout,

                            new BoxView()
                            {
                                HeightRequest = 10,BackgroundColor              = Config.ColorGrayBackground
                            },
                            new StackLayout
                            {
                                Orientation = StackOrientation.Horizontal,
                                Spacing     = 10,
                                Children    =
                                {
                                    //buttonEditLocation,
                                    buttonFind,
                                    labelStatus
                                }
                            },

                            panelCountry,
                            panelMetro,

                            new BoxView()
                            {
                                HeightRequest = 10,BackgroundColor              = Config.ColorGrayBackground
                            },
                            panelPin,
                            panelPassword,
                            panelEmail,
                        }
                    },

                    new BoxView()
                    {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"], VerticalOptions = LayoutOptions.FillAndExpand
                    },

                    //new BoxView() { Style = (Style)App.Current.Resources["BoxViewPadding1Style"] },
                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        //BackgroundColor = Config.ColorDarkGrayBackground,
                        HorizontalOptions = LayoutOptions.Fill,
                        HeightRequest     = Config.OkCancelButtonsHeight,
                        Padding           = Config.OkCancelButtonsPadding,
                        Spacing           = 1,
                        Children          =
                        {
                            buttonCancel,
                            buttonOk,
                        }
                    }
                }
            };

            this.Padding         = new Thickness(0);
            this.BackgroundColor = Config.ColorGrayBackground;
            this.Content         = stackLayout;

            this.fillCountriesPicker();
        }
Ejemplo n.º 8
0
        public ProfilePersonControl()
        {
            this.Padding           = new Thickness(0);
            this.BackgroundColor   = Config.ColorBackground;
            this.ColumnSpacing     = 0;
            this.RowSpacing        = 0;
            this.VerticalOptions   = LayoutOptions.FillAndExpand;
            this.HorizontalOptions = LayoutOptions.FillAndExpand;

            /// info panel
            ///
            this.infoControl = new ProfilePersonInfoControl()
            {
                Padding = new Thickness(0, 0, 0, 15), HorizontalOptions = LayoutOptions.FillAndExpand
            };
            this.infoControl.ClickedOnBestBreak += (s, e) =>
            {
                this.State = ProfilePersonStateEnum.Breaks;
                this.listOfBreaksControl.Sort(SnookerBreakSortEnum.ByPoints);
            };
            this.infoControl.ClickedOnBestFrame += (s, e) =>
            {
                this.State = ProfilePersonStateEnum.Matches;
                this.listOfMatchesControl.Sort(SnookerMatchSortEnum.ByBestFrame);
            };
            this.infoControl.ClickedOnContributions += (s, e) =>
            {
                App.Navigator.DisplayAlertRegular("Verifying snooker venues is an example of a contribution.");
            };
            this.infoControl.ClickedOnAbout += (s, e) =>
            {
                if (IsMyAthlete == true)
                {
                    App.Navigator.OpenProfileEditPage(true, true);
                }
            };

            /// panel "Me"
            ///
            Button buttonEditProfile = new BybButton()
            {
                Text = "Edit profile", Style = (Style)App.Current.Resources["BlackButtonStyle"], FontFamily = Config.FontFamily, TextColor = Config.ColorTextOnBackground
            };

            buttonEditProfile.Clicked += buttonEditProfile_Clicked;
            this.buttonSync            = new BybButton()
            {
                Text = "Sync now", Style = (Style)App.Current.Resources["BlackButtonStyle"], FontFamily = Config.FontFamily, TextColor = Config.ColorTextOnBackground
            };
            this.buttonSync.Clicked += buttonSync_Clicked;
            this.panelMe             = new Grid()
            {
                Padding        = new Thickness(10, 0, 10, 10),
                ColumnSpacing  = Config.SpaceBetweenButtons,
                RowSpacing     = 0,
                RowDefinitions = new RowDefinitionCollection()
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };
            this.panelMe.Children.Add(buttonSync, 0, 0);
            this.panelMe.Children.Add(buttonEditProfile, 1, 0);

            /// panel "Not me"
            ///
            this.panelNotMe = new Grid()
            {
                BackgroundColor = Config.ColorBackground,
                Padding         = new Thickness(0, 0, 0, 10),
                ColumnSpacing   = 0,
                RowSpacing      = 0,
                RowDefinitions  = new RowDefinitionCollection()
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition {
                        Width = new GridLength(10, GridUnitType.Absolute)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Absolute)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Absolute)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(10, GridUnitType.Absolute)
                    },
                }
            };
            this.buttonSendFriendRequest = new BybButton()
            {
                Text = "Friend", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            this.buttonSendFriendRequest.Clicked += buttonSendFriendRequest_Clicked;
            this.buttonInvite = new BybButton()
            {
                Text = "Invite", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            this.buttonInvite.Clicked += buttonInvite_Clicked;
            this.buttonMessage         = new BybButton()
            {
                Text = "Message", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            this.buttonMessage.Clicked += buttonMessage_Clicked;
            this.labelFriendship        = new BybLabel()
            {
                Text = "-", TextColor = Config.ColorTextOnBackgroundGrayed, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center
            };
            this.labelFriendship.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    this.labelFriendship_Tapped();
                }),
                NumberOfTapsRequired = 1
            });
            this.panelNotMe.Children.Add(this.buttonMessage, 1, 0);
            this.panelNotMe.Children.Add(this.buttonInvite, 3, 0);
            this.panelNotMe.Children.Add(this.labelFriendship, 5, 0);
            this.panelNotMe.Children.Add(this.buttonSendFriendRequest, 5, 0);

            /// Tabs: Breaks / matches / opponents
            ///

            this.buttonBreaks = new BybButtonWithNumber("Breaks")
            {
                HeightRequest = 55
            };
            buttonBreaks.Clicked += (s, e) => { this.State = ProfilePersonStateEnum.Breaks; };
            this.buttonMatches    = new BybButtonWithNumber("Matches")
            {
                HeightRequest = 55
            };
            buttonMatches.Clicked += (s, e) => { this.State = ProfilePersonStateEnum.Matches; };
            this.buttonOpponents   = new BybButtonWithNumber("Opponents")
            {
                HeightRequest = 55
            };
            buttonOpponents.Clicked += (s, e) => { this.State = ProfilePersonStateEnum.Opponents; };
            this.buttonVenues        = new BybButtonWithNumber("Venues")
            {
                HeightRequest = 55
            };
            buttonVenues.Clicked += (s, e) => { this.State = ProfilePersonStateEnum.Venues; };

            Grid gridWithButtons = new Grid()
            {
                BackgroundColor = Config.ColorBackgroundWhite,//Config.ColorGrayBackground,
                Padding         = new Thickness(0, 0, 0, 0),
                ColumnSpacing   = 0,
                RowSpacing      = 0,
                RowDefinitions  = new RowDefinitionCollection()
                {
                    new RowDefinition {
                        Height = new GridLength(55, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            gridWithButtons.Children.Add(buttonBreaks, 0, 0);
            gridWithButtons.Children.Add(buttonMatches, 1, 0);
            gridWithButtons.Children.Add(buttonOpponents, 2, 0);
            gridWithButtons.Children.Add(buttonVenues, 3, 0);

            StackLayout panelContent = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Config.ColorGrayBackground,
            };

            // breaks
            this.listOfBreaksControl = new ListOfSnookerBreaksControl()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                IsVisible         = true
            };
            this.listOfBreaksControl.UserWantsToEditRes   += ctrl_UserWantsToEditBreak;
            this.listOfBreaksControl.UserWantsToDeleteRes += ctrl_UserWantsToDeleteBreak;
            panelContent.Children.Add(this.listOfBreaksControl);

            // matches
            this.listOfMatchesControl = new ListOfSnookerMatchesControl()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                IsVisible         = false
            };
            this.listOfMatchesControl.UserWantsToDeleteScore += ctrl_UserWantsToDeleteScore;
            this.listOfMatchesControl.UserWantsToEditScore   += ctrl_UserWantsToEditScore;
            this.listOfMatchesControl.UserWantsToViewScore   += ctrl_UserWantsToViewScore;
            panelContent.Children.Add(this.listOfMatchesControl);

            // friends
            this.listOfOpponents = new ListOfOpponentsControl()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                IsVisible         = false
            };
            panelContent.Children.Add(this.listOfOpponents);

            // venues
            this.listOfVenues = new ListOfVenuesPlayedControl()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                IsVisible         = false
            };
            panelContent.Children.Add(this.listOfVenues);


            /// Grid
            ///
            this.RowDefinitions = new RowDefinitionCollection()
            {
                new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Auto)
                },
                new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Auto)
                },
                new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Auto)
                },
                new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                },
            };
            this.ColumnDefinitions = new ColumnDefinitionCollection()
            {
                new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Star)
                }
            };
            this.Children.Add(this.infoControl, 0, 0);
            this.Children.Add(this.panelMe, 0, 1);
            this.Children.Add(this.panelNotMe, 0, 1);
            this.Children.Add(gridWithButtons, 0, 2);
            this.Children.Add(panelContent, 0, 3);

            this.State = ProfilePersonStateEnum.Breaks;
        }
Ejemplo n.º 9
0
        protected override View createViewForSingleItem(SnookerBreak snookerBreak)
        {
            // score
            Label labelPoints = new BybLabel
            {
                Text                    = snookerBreak.Points.ToString(),
                TextColor               = Config.ColorBlackTextOnWhite,
                FontSize                = Config.LargerFontSize,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center
            };
            Label labelBalls = new BybLabel
            {
                Text                    = snookerBreak.NumberOfBallsDisplay,
                TextColor               = Config.ColorBlackTextOnWhite,
                FontSize                = Config.LargerFontSize,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center
            };

            // balls
            StackLayout stackForBalls = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 1,
                Padding     = new Thickness(0)
            };
            ScrollView scrollViewForBalls = new ScrollView()
            {
                Orientation = ScrollOrientation.Horizontal,
                Padding     = new Thickness(0),
                Content     = stackForBalls
            };

            if (true)
            {
                List <int> balls = snookerBreak.GetBallsEvenWhenUnknown();
                for (int iBall = 0; iBall < balls.Count; ++iBall)
                {
                    int   ball  = balls[iBall];
                    Color color = Config.BallColors[ball];
                    var   btn   = new BybButton
                    {
                        Text                 = "",
                        BackgroundColor      = color,
                        BorderColor          = Color.Transparent,
                        TextColor            = Color.White,
                        BorderWidth          = 1,
                        BorderRadius         = (int)(Config.ExtraSmallBallSize / 2),
                        HeightRequest        = Config.ExtraSmallBallSize,
                        MinimumHeightRequest = Config.ExtraSmallBallSize,
                        WidthRequest         = Config.ExtraSmallBallSize,
                        MinimumWidthRequest  = Config.ExtraSmallBallSize,
                        VerticalOptions      = LayoutOptions.Center
                    };
                    if (snookerBreak.NumberOfBalls == 0)
                    {
                        btn.Opacity = (balls.Count - iBall) / ((double)balls.Count + 1);
                    }
                    stackForBalls.Children.Add(btn);
                }
            }

            // date
            FormattedString formattedString = new FormattedString();

            formattedString.Spans.Add(new Span()
            {
                Text = DateTimeHelper.DateToString(snookerBreak.Date), ForegroundColor = Config.ColorBlackTextOnWhite,
            });
            if (snookerBreak.OpponentConfirmation == OpponentConfirmationEnum.Confirmed)
            {
                //formattedString.Spans.Add(new Span() { Text = "  confirmed", ForegroundColor = Config.ColorGrayTextOnWhite });
            }
            else if (snookerBreak.OpponentConfirmation == OpponentConfirmationEnum.Declined)
            {
                formattedString.Spans.Add(new Span()
                {
                    Text = "  (declined)", ForegroundColor = Config.ColorTextOnBackgroundGrayed
                });
            }
            else
            {
                formattedString.Spans.Add(new Span()
                {
                    Text = "  (unconfirmed)", ForegroundColor = Config.ColorTextOnBackgroundGrayed
                });
            }
            Label labelDate = new BybLabel()
            {
                HorizontalOptions     = LayoutOptions.Start,
                FormattedText         = formattedString,
                VerticalTextAlignment = TextAlignment.Center
            };

            // person name / opponent name
            int    personID;
            string personName;

            if (this.Type == ListTypeEnum.FVO)
            {
                personID   = snookerBreak.AthleteID;
                personName = (string.IsNullOrEmpty(snookerBreak.AthleteName) ? "-" : snookerBreak.AthleteName) +
                             " vs. " + (string.IsNullOrEmpty(snookerBreak.OpponentName) ? "-" : snookerBreak.OpponentName);
            }
            else if (this.Type == ListTypeEnum.Venue)
            {
                personID   = snookerBreak.AthleteID;
                personName = string.IsNullOrEmpty(snookerBreak.AthleteName) ? "-" : (snookerBreak.AthleteName);
            }
            else
            {
                personID   = snookerBreak.OpponentAthleteID;
                personName = string.IsNullOrEmpty(snookerBreak.OpponentName) ? "-" : ("vs. " + snookerBreak.OpponentName);
            }
            Label labelPerson = new BybLabel()
            {
                Text = personName,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor             = Config.ColorGrayTextOnWhite
            };

            if (personID > 0)
            {
                labelPerson.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = new Command(async() =>
                    {
                        await App.Navigator.GoToPersonProfile(personID);
                    }),
                    NumberOfTapsRequired = 1
                });
            }

            // venue
            string venueName = snookerBreak.VenueName;

            if (string.IsNullOrEmpty(venueName))
            {
                venueName = "-";
            }
            Label labelVenueName = new BybLabel()
            {
                Text = venueName,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.EndAndExpand,
                HorizontalTextAlignment = TextAlignment.End,
                TextColor = Config.ColorGrayTextOnWhite,
                IsVisible = Type != ListTypeEnum.Venue && Type != ListTypeEnum.FVO
            };

            if (snookerBreak.VenueID > 0)
            {
                labelVenueName.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = new Command(async() =>
                    {
                        await App.Navigator.GoToVenueProfile(snookerBreak.VenueID);
                    }),
                    NumberOfTapsRequired = 1
                });
            }

            var panel1 = new StackLayout
            {
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Color.White,
                Padding         = new Thickness(0, 10, 0, 5),
                Children        =
                {
                    new StackLayout
                    {
                        Padding           = new Thickness(10, 0, 0, 0),
                        Orientation       = StackOrientation.Vertical,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.Start,
                        Children          =
                        {
                            labelDate,
                            scrollViewForBalls
                        }
                    },
                    new StackLayout
                    {
                        Orientation         = StackOrientation.Vertical,
                        Padding             = new Thickness(0, 0, 0, 0),
                        WidthRequest        = Config.IsTablet ? 80 : 40,
                        MinimumWidthRequest = Config.IsTablet ? 80 : 40,
                        HorizontalOptions   = LayoutOptions.Center,
                        VerticalOptions     = LayoutOptions.Start,
                        Spacing             = 2,
                        Children            =
                        {
                            new BybLabel {
                                Text = "Balls", TextColor = Config.ColorGrayTextOnWhite, HorizontalOptions = LayoutOptions.Center
                            },
                            labelBalls
                        }
                    },
                    new StackLayout
                    {
                        Orientation         = StackOrientation.Vertical,
                        Padding             = new Thickness(0, 0, 10, 0),
                        WidthRequest        = Config.IsTablet ? 80 : 40,
                        MinimumWidthRequest = Config.IsTablet ? 80 : 40,
                        HorizontalOptions   = LayoutOptions.Center,
                        VerticalOptions     = LayoutOptions.Start,
                        Spacing             = 2,
                        Children            =
                        {
                            new BybLabel {
                                Text = "Points", TextColor = Config.ColorGrayTextOnWhite, HorizontalOptions = LayoutOptions.Center
                            },
                            labelPoints
                        }
                    }
                }
            };

            if (this.Type == ListTypeEnum.PrimaryAthlete)
            {
                var recognizer = new TapGestureRecognizer
                {
                    Command = new Command(() => { this.showMenu(snookerBreak); }),
                    NumberOfTapsRequired = 1
                };
                panel1.GestureRecognizers.Add(recognizer);
            }

            var panel = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 1,
                Children    =
                {
                    panel1,
                    new StackLayout
                    {
                        Orientation     = StackOrientation.Horizontal,
                        BackgroundColor = Color.White,
                        Padding         = new Thickness(10,                 5, 10, 5),
                        Children        =
                        {
                            labelPerson,
                            labelVenueName,
                        }
                    }
                }
            };

            return(panel);
        }
Ejemplo n.º 10
0
        public NewPostPage(Country country, int metroID)
        {
            this.country = country;
            this.metroID = metroID;

            this.BackgroundColor = Color.White;

            // label
            this.labelWhere = new BybLabel()
            {
                Text      = "",
                TextColor = Config.ColorBlackTextOnWhite,
            };
            if (metroID == 0)
            {
                this.labelWhere.Text = country.Name;
            }
            else
            {
                MetroWebModel metro = App.Cache.Metroes.Get(metroID);
                if (metro != null)
                {
                    this.labelWhere.Text = metro.Name;
                }
                else
                {
                    this.labelWhere.Text = "Metro #" + metroID;
                }
            }

            // entry
            this.editorText = new BybEditor()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 50,
            };

            // ok, cancel
            Button buttonOk = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "OK"
            };
            Button buttonCancel = new BybButton {
                Text = "Cancel", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };

            buttonOk.Clicked     += buttonOk_Clicked;
            buttonCancel.Clicked += buttonCancel_Clicked;

            var stackLayout = new StackLayout
            {
                Spacing = 5,
                Padding = new Thickness(0),

                Children =
                {
                    new BybTitle("Make a Public Post")
                    {
                        VerticalOptions = LayoutOptions.Start
                    },

                    new StackLayout
                    {
                        Padding  = new Thickness(10, 10, 10, 0),
                        Children =
                        {
                            new StackLayout
                            {
                                Orientation = StackOrientation.Horizontal,
                                Spacing     = 10,
                                Children    =
                                {
                                    new BybLabel {
                                        Text = "Post to:", TextColor = Config.ColorGrayTextOnWhite, VerticalTextAlignment = TextAlignment.Center
                                    },
                                    labelWhere,
                                }
                            },
                            new BybLabel         {
                                Text = "Text to post:", TextColor = Config.ColorGrayTextOnWhite, VerticalTextAlignment = TextAlignment.Center
                            },
                            new Frame
                            {
                                HasShadow       = false,
                                BackgroundColor = Config.ColorGrayBackground,
                                Padding         = new Thickness(5, 5, 5, 5),
                                Content         = editorText,
                            }
                        }
                    },

                    new BoxView()
                    {
                        HeightRequest = 1, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Transparent
                    },

                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        //BackgroundColor = Config.ColorBackground,
                        HorizontalOptions = LayoutOptions.Fill,
                        HeightRequest     = Config.OkCancelButtonsHeight,
                        Padding           = new Thickness(Config.OkCancelButtonsPadding),
                        Spacing           = 1,
                        Children          =
                        {
                            buttonCancel,
                            buttonOk,
                        }
                    }
                }
            };

            this.Content = stackLayout;
            this.Padding = new Thickness(0, 0, 0, 0);
        }
Ejemplo n.º 11
0
        void addPocketedBall(int ballScore)
        {
            // update ballsOnTable
            localBallsOnTable.ballPocketed(ballScore);
            updateBallsOnTable_ballsChanged();

            if ((this.framePointsEntryA.Number != null) &&
                (this.framePointsEntryB.Number != null))
            {
                if (this.swipePanel.getIsOpponentBreak())
                {
                    this.framePointsEntryB.Number += ballScore;
                }
                else
                {
                    this.framePointsEntryA.Number += ballScore;
                }
            }
            updatePointsDiff();

            Color color       = Config.BallColors[ballScore];
            Color borderColor = color;

            if (ballScore == 7)
            {
                borderColor = Color.Gray;
            }
            Color textColor = Color.White;

            if (ballScore == 2)
            {
                textColor = Color.Black;
            }

            var ball = new BybButton
            {
                IsEnabled            = false,
                Text                 = "",
                BackgroundColor      = color,
                BorderColor          = borderColor,
                FontFamily           = Config.FontFamily,
                FontSize             = Config.LargerFontSize,
                TextColor            = textColor,
                BorderWidth          = 1,
                BorderRadius         = (int)(Config.SmallBallSize / 2),
                HeightRequest        = Config.SmallBallSize,
                MinimumHeightRequest = Config.SmallBallSize,
                WidthRequest         = Config.SmallBallSize,
                MinimumWidthRequest  = Config.SmallBallSize,
                VerticalOptions      = LayoutOptions.Center
            };

            if (this.panelPocketedBalls1.Children.Count() < maxNumberOfBallsPerLine)
            {
                this.panelPocketedBalls1.Children.Add(ball);
            }
            else if (this.panelPocketedBalls2.Children.Count() < maxNumberOfBallsPerLine)
            {
                this.panelPocketedBalls2.Children.Add(ball);
            }
            else
            {
                this.panelPocketedBalls3.Children.Add(ball);
            }

            this.updateControls();
        }
Ejemplo n.º 12
0
        //Switch switchFriendRequest;

        public SendMessagePage(PersonFullWebModel person)
        {
            this.person = person;

            // ok, cancel
            Button buttonOk = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "Send"
            };

            buttonOk.Clicked += buttonOk_Clicked;
            Button buttonCancel = new BybButton {
                Style = (Style)App.Current.Resources["BlackButtonStyle"], Text = "Cancel"
            };

            buttonCancel.Clicked += buttonCancel_Clicked;
            var panelOkCancel = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                //BackgroundColor = Config.ColorDarkGrayBackground,
                HorizontalOptions = LayoutOptions.Fill,
                Padding           = new Thickness(0, Config.OkCancelButtonsPadding, 0, Config.OkCancelButtonsPadding),
                Spacing           = 1,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Children          =
                {
                    buttonCancel,
                    buttonOk,
                }
            };

            editorNote = new BybEditor()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 40
            };
            switchShareMyEmail           = new BybSwitch();
            switchShareMyEmail.IsToggled = true;
            //switchFriendRequest = new Switch();
            //switchFriendRequest.IsToggled = person.IsFriend == false && person.IsFriendRequestSent == false;

            // content
            Content = new StackLayout {
                Orientation     = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding         = new Thickness(15),
                Spacing         = 5,
                Children        =
                {
                    new BybLabel()
                    {
                        Text = "Your message to '" + this.person.Name + "':"
                    },
                    new Frame
                    {
                        HasShadow         = false,
                        BackgroundColor   = Config.ColorGrayBackground,
                        Padding           = new Thickness(5, 5, 5, 5),
                        Content           = editorNote,
                        HeightRequest     = 60,
                        HorizontalOptions = LayoutOptions.FillAndExpand,

//                                Padding = new Thickness(0),
//                                HorizontalOptions = LayoutOptions.FillAndExpand,
//                                HeightRequest = 60,
//                                Content = editorNote
                    },
                    new BybLabel()
                    {
                        Text      = "'" + this.person.Name + "' will receive an email with the message and will be able to open your Byb profile from the email.",
                        TextColor = Config.ColorGrayTextOnWhite,
                    },
//                        new StackLayout
//                        {
//                            Orientation = StackOrientation.Horizontal,
//                            Children =
//                            {
//                                new BybLabel { Text = "Share your email address?", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand },
//                                this.switchShareMyEmail
//                            }
//                        },
                    //new BoxView() { VerticalOptions = LayoutOptions.FillAndExpand },
                    new BoxView()
                    {
                        HeightRequest = 1, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Transparent
                    },
                    panelOkCancel
                }
            };
            Padding = new Thickness(0);
            Title   = "Send a Message";
            this.BackgroundColor = Config.ColorBackgroundWhite;
        }
Ejemplo n.º 13
0
        public FVORegisterControl()
        {
            editorName = new BybStandardEntry()
            {
                Placeholder       = "Your name",
                Keyboard          = Keyboard.Text,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 40,
            };
            editorEmail = new BybStandardEntry()
            {
                Placeholder       = "Your e-mail address",
                Keyboard          = Keyboard.Email,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 40,
            };
            //editorPin = new BybPinEntry()
            //{
            //    Placeholder = "Access pin (4 numbers)",
            //    HorizontalOptions = LayoutOptions.FillAndExpand,
            //    HeightRequest = 40,
            //};

            editorName.Completed += (s1, e1) => {
                editorEmail.Focus();
            };
            //         editorEmail.Completed += (s1, e1) => {
            //             editorPin.Focus();
            //};

            Button buttonOk = new BybButton()
            {
                Text  = "Register",
                Style = (Style)App.Current.Resources["LargeButtonStyle"]
            };

            buttonOk.Clicked += buttonOk_Clicked;
            Button buttonCancel = new BybButton()
            {
                Text  = "Cancel",
                Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };

            buttonCancel.Clicked += buttonCancel_Clicked;
            var panelOkCancel = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(0),
                Spacing           = 1,
                Children          =
                {
                    buttonCancel,
                    buttonOk,
                }
            };

            this.Children.Add(new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                Padding           = new Thickness(10, 10, 10, 10),
                Children          =
                {
                    editorName,
                    editorEmail,
                    //editorPin,
                    panelOkCancel,
                    new BoxView()
                    {
                        HeightRequest = 10
                    },
                    new BybLabel()
                    {
                        Text = "Register here or\r\ndownload 'Snooker Byb app' on your device.\r\n\r\nOnly register once, your account will work everywhere on Planet Earth.",
                        HorizontalOptions       = LayoutOptions.Center,
                        TextColor               = Config.ColorTextOnBackgroundGrayed,
                        HorizontalTextAlignment = TextAlignment.Center,
                    },
                    new BoxView()
                    {
                        HeightRequest = 10
                    },
                }
            });
            this.BackgroundColor = Config.ColorBackground;
        }
Ejemplo n.º 14
0
        void openPopup()
        {
            this.closePopup();

            if (this.PageTopLevelLayout == null)
            {
                return;
            }

            this.absoluteLayout = new AbsoluteLayout()
            {
                HeightRequest = 1000,
                WidthRequest  = 1000,
            };
            if (PageTopLevelLayout as Grid != null)
            {
                ((Grid)PageTopLevelLayout).Children.Add(this.absoluteLayout);
            }
            else if (PageTopLevelLayout as StackLayout != null)
            {
                ((StackLayout)PageTopLevelLayout).Children.Add(this.absoluteLayout);
            }
            else if ((PageTopLevelLayout as AbsoluteLayout != null))
            {
                ((AbsoluteLayout)PageTopLevelLayout).Children.Add(this.absoluteLayout);
            }

            // a cover to cover the whole screen
            Grid panelCover = new Grid()
            {
                Opacity         = 0.5,
                BackgroundColor = Color.Black,
                WidthRequest    = 1000,
                HeightRequest   = 1000,
            };

            panelCover.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { closePopup(); })
            });
            absoluteLayout.Children.Add(panelCover, new Point(0, 0));

            // the popup
            this.switcher = new Switch()
            {
                IsToggled       = App.UserPreferences.IsVoiceOn,
                VerticalOptions = LayoutOptions.Center,
            };
            switcher.Toggled += switcher_Toggled;
            Button buttonConfigure = new BybButton()
            {
                Text          = "Configure ",
                Style         = (Style)App.Current.Resources["SimpleButtonStyle"],
                HeightRequest = 40,
            };

            buttonConfigure.Clicked += (s1, e1) => { openVoiceConfigPage(); };
            Button buttonClose = new BybButton()
            {
                Text          = "OK",
                Style         = (Style)App.Current.Resources["SimpleButtonStyle"],
                HeightRequest = 40,
            };

            buttonClose.Clicked += (s1, e1) => { closePopup(); };
            absoluteLayout.Children.Add(new Frame
            {
                BackgroundColor = Config.ColorGrayBackground,
                Padding         = new Thickness(0),
                Content         = new StackLayout()
                {
                    Orientation  = StackOrientation.Vertical,
                    Padding      = new Thickness(20),
                    WidthRequest = popupWidth,
                    Children     =
                    {
                        new StackLayout()
                        {
                            Orientation       = StackOrientation.Horizontal,
                            Spacing           = 10,
                            HeightRequest     = 40,
                            HorizontalOptions = LayoutOptions.Center,
                            Children          =
                            {
                                new BybLabel
                                {
                                    Text            = "Voice",
                                    TextColor       = Color.Black,
                                    VerticalOptions = LayoutOptions.Center,
                                },
                                switcher,
                            }
                        },
                        new BybLabel
                        {
                            Text          = "Remember to turn the volume on.",
                            TextColor     = Config.ColorGrayTextOnWhite,
                            HeightRequest = 40,
                        },
                        buttonConfigure,
                        buttonClose,
                    }
                }
            }, new Point(PageTopLevelLayout.Width - popupWidth - 30, 30));
        }
Ejemplo n.º 15
0
        protected override View createViewForSingleItem(GameHostWebModel gameHost)
        {
            try
            {
                bool youAreHosting = gameHost.HostPersonID == myAthleteID;
                bool youAreInvited = gameHost.IsInvited(myAthleteID);

                // host person
                FormattedString formattedStringPerson = new FormattedString();
                formattedStringPerson.Spans.Add(new Span()
                {
                    Text            = gameHost.HostPersonName,
                    ForegroundColor = Config.ColorBlackTextOnWhite,
                    FontAttributes  = this.TreatAsASingleItem ? FontAttributes.None : FontAttributes.Bold,
                    FontFamily      = Config.FontFamily,
                    FontSize        = Config.DefaultFontSize
                });

                //formattedStringPerson.Spans.Add(new Span() { Text = " wants to play", ForegroundColor = Config.ColorGrayTextOnWhite, FontAttributes = FontAttributes.None, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize });
                Label labelPersonHost = new BybLabel()
                {
                    FormattedText     = formattedStringPerson,
                    HorizontalOptions = LayoutOptions.Start,
                    FontAttributes    = this.TreatAsASingleItem ? FontAttributes.None : FontAttributes.Bold,
                    FontFamily        = Config.FontFamily,
                    TextColor         = Config.ColorBlackTextOnWhite,
                };

                // when
                FormattedString formattedStringWhen = new FormattedString();
                formattedStringWhen.Spans.Add(new Span()
                {
                    Text            = "on ",
                    ForegroundColor = Config.ColorGrayTextOnWhite,
                });
                formattedStringWhen.Spans.Add(new Span()
                {
                    Text            = DateTimeHelper.DateAndTimeToString(gameHost.When),
                    ForegroundColor = Config.ColorBlackTextOnWhite,
                    FontFamily      = Config.FontFamily,
                    FontSize        = Config.DefaultFontSize
                });

                // venue
                FormattedString formattedStringVenue = new FormattedString();
                formattedStringVenue.Spans.Add(new Span()
                {
                    Text = "at ", ForegroundColor = Config.ColorGrayTextOnWhite, FontAttributes = FontAttributes.None, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
                });
                formattedStringVenue.Spans.Add(new Span()
                {
                    Text            = gameHost.VenueName,
                    ForegroundColor = Config.ColorBlackTextOnWhite,
                    FontAttributes  = this.TreatAsASingleItem ? FontAttributes.None : FontAttributes.Bold,
                    FontFamily      = Config.FontFamily,
                    FontSize        = Config.DefaultFontSize
                });
                Label labelVenue = new BybLabel()
                {
                    FormattedText = formattedStringVenue,
                };

                // lists of people
                ScrollView panel1 = this.createScrollViewWithNames(gameHost, gameHost.AthleteIDs_Going, "Accepted", false, false);
                ScrollView panel2 = this.createScrollViewWithNames(gameHost, gameHost.GetAthleteIDs_Unresponded(), "Not responded", false, true);
                ScrollView panel3 = this.createScrollViewWithNames(gameHost, gameHost.AthleteIDs_CannotGo, "Declined", false, true);
                ScrollView panel4 = this.createScrollViewWithNames(gameHost, gameHost.AthleteIDs_WantToGo, "Wants to be invited", youAreHosting ? true : false, true);

                // accept button
                Button buttonAccept = new BybButton()
                {
                    Style             = (Style)App.Current.Resources["ConfirmButtonStyle"],
                    HorizontalOptions = LayoutOptions.Start,
                    WidthRequest      = 130 + (Config.IsAndroid ? 30 : 0) + (Config.IsTablet ? 30 : 0),
                    HeightRequest     = Config.IsAndroid ? 40 : 30,
                };
                if (this.IsForPast)
                {
                    buttonAccept.IsVisible = false;
                }
                else if (youAreHosting)
                {
                    buttonAccept.Text      = "You are hosting";
                    buttonAccept.Style     = (Style)App.Current.Resources["SimpleButtonStyle"];
                    buttonAccept.IsEnabled = false;
                }
                else if (gameHost.IsGoing(myAthleteID))
                {
                    buttonAccept.Text      = "You are going!";
                    buttonAccept.IsEnabled = false;
                }
                else if (youAreInvited)
                {
                    buttonAccept.Text = "Accept invitation";
                }
                else if (gameHost.IsWantToGo(myAthleteID))
                {
                    buttonAccept.Text      = "Already asked to be invited";
                    buttonAccept.Style     = (Style)App.Current.Resources["SimpleButtonStyle"];
                    buttonAccept.IsEnabled = false;
                }
                else
                {
                    buttonAccept.Text = "Ask to be invited";
                }
                bool buttonAcceptIsDisabled = buttonAccept.IsEnabled == false;
                if (Config.IsAndroid && buttonAcceptIsDisabled)
                {
                    // explanation: On Android disabled buttons become invisible on the white background... so make it enabled but make it look differently
                    buttonAccept.IsEnabled = true;
                    buttonAccept.TextColor = Color.Black;
                    buttonAccept.Opacity   = 0.5;
                }
                buttonAccept.Clicked += (s1, e1) =>
                {
                    if (buttonAcceptIsDisabled)
                    {
                        return;
                    }
                    if (youAreInvited)
                    {
                        this.doOnUserWantsToAcceptAnInvite(gameHost);
                    }
                    else if (youAreHosting == false)
                    {
                        this.doOnUserWantsToBeInvited(gameHost);
                    }
                };


                // decline button
                Button buttonDecline = new BybButton()
                {
                    Style             = (Style)App.Current.Resources["DenyButtonStyle"],
                    HorizontalOptions = LayoutOptions.Start,
                    WidthRequest      = 130 + (Config.IsAndroid ? 30 : 0) + (Config.IsTablet ? 30 : 0),
                    HeightRequest     = Config.IsAndroid ? 40 : 30,
                    Text = "Decline invitation",//buttonText,
                    //IsEnabled = buttonText != ""
                };
                if (this.IsForPast)
                {
                    buttonDecline.IsVisible = false;
                }
                else if (youAreHosting)
                {
                    buttonDecline.Text      = "";
                    buttonDecline.IsVisible = false;
                }
                else if (gameHost.IsCannotGo(myAthleteID))
                {
                    buttonDecline.Text      = "You declined";
                    buttonDecline.IsEnabled = false;
                }
                else if (youAreInvited || gameHost.IsGoing(myAthleteID))
                {
                    buttonDecline.Text = "Decline invitation";
                }
                else
                {
                    buttonDecline.Text      = "";
                    buttonDecline.IsVisible = false;
                }
                bool buttonDeclineIsDisabled = buttonDecline.IsEnabled == false;
                if (Config.IsAndroid && buttonDeclineIsDisabled)
                {
                    // explanation: On Android disabled buttons become invisible on the white background... so make it enabled but make it look differently
                    buttonDecline.IsEnabled = true;
                    buttonDecline.TextColor = Color.Black;
                    buttonDecline.Opacity   = 0.5;
                }
                buttonDecline.Clicked += (s1, e1) =>
                {
                    if (buttonDeclineIsDisabled)
                    {
                        return;
                    }
                    this.doOnUserWantsToDecline(gameHost);
                };

                /// likes and comments
                ///
                var imageLike = new Image()
                {
                    Source = new FileImageSource()
                    {
                        File = "like1.png"
                    },
                    HeightRequest = Config.LikeImageSize,
                    WidthRequest  = Config.LikeImageSize,
                };
                var imageComments = new Image()
                {
                    Source = new FileImageSource()
                    {
                        File = "right.png"
                    },
                    HeightRequest = Config.CommentImageSize,
                    WidthRequest  = Config.CommentImageSize,
                };
                var labelLikesCount = new BybLabel
                {
                };
                var panelLikes = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Center,
                    Padding           = new Thickness(0, 0, 0, 5),
                    Spacing           = 3,
                    Children          =
                    {
                        labelLikesCount,
                        imageLike
                    }
                };
                var labelCommentsCount = new BybLabel
                {
                };
                var panelComments = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Center,
                    Padding           = new Thickness(0, 5, 0, 0),
                    Spacing           = 5,
                    Children          =
                    {
                        labelCommentsCount,
                        imageComments,
                    }
                };
                var panelCommentsCount = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    Spacing           = 0,
                    HorizontalOptions = LayoutOptions.End,
                    VerticalOptions   = LayoutOptions.Center,
                    Children          =
                    {
                        panelLikes,
                        panelComments
                    }
                };
                imageLike.Source = new FileImageSource()
                {
                    File = gameHost.Liked ? "like2.png" : "like1.png"
                };
                imageComments.Source = new FileImageSource()
                {
                    File = gameHost.CommentsCount > 0 ? "right2.png" : "right1.png"
                };
                labelLikesCount.Text         = gameHost.LikesCount.ToString();
                labelLikesCount.TextColor    = gameHost.LikesCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite;
                labelCommentsCount.Text      = gameHost.CommentsCount.ToString();
                labelCommentsCount.TextColor = gameHost.CommentsCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite;
                panelComments.IsVisible      = ShowCommentsCount;
                panelLikes.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = new Command(async() =>
                    {
                        if (gameHost.Liked)
                        {
                            gameHost.LikesCount -= 1;
                        }
                        else
                        {
                            gameHost.LikesCount += 1;
                        }
                        gameHost.Liked = !gameHost.Liked;

                        imageLike.Source = new FileImageSource()
                        {
                            File = gameHost.Liked ? "like2.png" : "like1.png"
                        };
                        labelLikesCount.Text      = gameHost.LikesCount.ToString();
                        labelLikesCount.TextColor = gameHost.LikesCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite;

                        bool ok = await App.WebService.SetLike(NewsfeedItemTypeEnum.GameHost, gameHost.GameHostID, gameHost.Liked);
                        if (ok == false)
                        {
                            App.Navigator.DisplayAlertError("Couldn't set the like. Internet issues?");
                        }
                    }),
                    NumberOfTapsRequired = 1
                });

                var labelInfo = new BybLabel
                {
                    Text                    = this.IsForPast ? "Invited to play snooker" : "Invites to play snooker",
                    TextColor               = Config.ColorGrayTextOnWhite,
                    HorizontalOptions       = LayoutOptions.Fill,
                    HorizontalTextAlignment = TextAlignment.Start
                };

                Label labelInfo2 = new BybLabel
                {
                    Text = (gameHost.EventType == EventTypeEnum.Private ? "Private event" : "Public event") +
                           (gameHost.LimitOnNumberOfPlayers > 0 ? (", max. " + gameHost.LimitOnNumberOfPlayers.ToString() + " can join") : ""),
                    TextColor               = Config.ColorGrayTextOnWhite,
                    HorizontalOptions       = LayoutOptions.Fill,
                    HorizontalTextAlignment = TextAlignment.Start
                };

                var labelWhen = new BybLabel
                {
                    FormattedText = formattedStringWhen,
                    //Text = DateTimeHelper.DateAndTimeToString(gameHost.When),// gameHost.When.ToShortDateString() + " - " + gameHost.When.ToShortTimeString(),
                    TextColor = Config.ColorBlackTextOnWhite
                };

                var panel0 = new StackLayout
                {
                    Orientation     = StackOrientation.Horizontal,
                    Spacing         = 10,
                    Padding         = new Thickness(5, 5, 5, 5),
                    BackgroundColor = Color.White,
                    Children        =
                    {
                        new Grid
                        {
                            //BackgroundColor = Color.Transparent,
                            Padding  = new Thickness(Config.IsTablet ? 10 : 0, 0, Config.IsTablet ? 10 : 0, 0),
                            Children =
                            {
                                new Image()
                                {
                                    Source        = App.ImagesService.GetImageSource(gameHost.HostPersonPicture, BackgroundEnum.White),
                                    WidthRequest  = Config.PersonImageSize,
                                    HeightRequest = Config.PersonImageSize,
                                }
                            }
                        },
                        new StackLayout
                        {
                            Orientation       = StackOrientation.Vertical,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions   = LayoutOptions.Center,
                            Spacing           = 5,
                            Children          =
                            {
                                labelPersonHost,
                                labelInfo,
                                labelWhen,
                                labelVenue,
                                labelInfo2,
                            },
                        },
                        panelCommentsCount
                    }
                };

                var panelButtons = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding           = new Thickness(12, 5, 5, 5),
                    BackgroundColor   = Color.White,
                    Spacing           = 0,
                    Children          =
                    {
                        buttonAccept,
                        buttonDecline
                    }
                };

                var stackGameHost = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Spacing     = 1,
                    //Opacity = IsForPast ? 0.5 : 1.0,
                    Children =
                    {
                        panel0,
                        panel1,
                        panel2,
                        panel3,
                        panel4,
                        panelButtons,
                    }
                };

                /// event handlers
                ///

                var recognizer = new TapGestureRecognizer
                {
                    Command = new Command(async() => { await this.openGameHostPage(gameHost.GameHostID); })
                };

                panel0.GestureRecognizers.Add(recognizer);
                panel1.Content.GestureRecognizers.Add(recognizer);
                panel2.Content.GestureRecognizers.Add(recognizer);
                panel3.Content.GestureRecognizers.Add(recognizer);
                panel4.Content.GestureRecognizers.Add(recognizer);
                panelButtons.GestureRecognizers.Add(recognizer);

                if (this.TreatAsASingleItem == false)
                {
                    labelPersonHost.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async() => { await App.Navigator.GoToPersonProfile(gameHost.HostPersonID); })
                    });
                    labelVenue.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async() => { await App.Navigator.GoToVenueProfile(gameHost.VenueID); })
                    });
                }

                return(stackGameHost);
            }
            catch (Exception exc)
            {
                return(new BybLabel()
                {
                    Text = TraceHelper.ExceptionToString(exc)
                });
            }
        }
Ejemplo n.º 16
0
        public PickCommunityPage()
        {
            this.myAthlete = App.Repository.GetMyAthlete();
            this.myCountry = Country.Get(myAthlete.Country);

            // title
            this.title = new BybTitle("")
            {
                BackgroundColor = Config.ColorBlackBackground
            };
            this.NameAsCommunity = true;

            // ok, cancel
            Button buttonCancel = new BybButton()
            {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "Cancel"
            };

            buttonCancel.Clicked += buttonCancel_Clicked;

            // stacks
            this.stackTop = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Config.ColorBackground,
                Spacing           = 1,
            };
            this.stackCountries = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Config.ColorBackground,
                Spacing           = 1,
            };
            this.stackMetros = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Config.ColorBackground,
                Spacing           = 1,
            };

            // content
            Grid grid = new Grid()
            {
                RowDefinitions =
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(Config.TitleHeight, GridUnitType.Absolute)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(Config.OkCancelButtonsHeight + Config.OkCancelButtonsPadding + Config.OkCancelButtonsPadding, GridUnitType.Absolute)
                    },
                },
            };

            grid.Children.Add(title, 0, 0);
            grid.Children.Add(new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                BackgroundColor   = Color.Transparent,
                Padding           = new Thickness(Config.OkCancelButtonsPadding),
                Spacing           = 1,
                Children          =
                {
                    buttonCancel,
                    //buttonOk,
                }
            }, 0, 2);
            grid.Children.Add(new ScrollView()
            {
                VerticalOptions   = LayoutOptions.Fill,
                HorizontalOptions = LayoutOptions.Fill,
                Padding           = new Thickness(0),
                Content           = new StackLayout()
                {
                    Orientation = StackOrientation.Vertical,
                    Spacing     = 0,
                    Padding     = new Thickness(0),
                    Children    =
                    {
                        this.stackTop,
                        this.createDivider("Countries"),
                        this.stackCountries,
                        this.createDivider("Cities"),
                        this.stackMetros,
                    }
                }
            }, 0, 1);
            this.BackgroundColor = Config.ColorBlackBackground;
            this.Padding         = new Thickness(0, 0, 0, 0);
            this.Content         = grid;
        }
Ejemplo n.º 17
0
        public PickVenuePage()
        {
            this.BackgroundColor = Config.App == MobileAppEnum.SnookerForVenues ? Config.ColorBlackBackground : Config.ColorGrayBackground;

            // FindVenuesControl
            this.findVenuesControl = new FindVenuesControl(false)
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0, 0, 0, 0),
                IsFindVenueMode   = true,
            };
            this.findVenuesControl.UserClickedOnVenue += (s1, e1) =>
            {
                if (this.UserMadeSelection != null)
                {
                    this.UserMadeSelection(s1, e1);
                }
            };

            // cancel and "not listed" button
            Button buttonCancel = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "Cancel"
            };

            buttonCancel.Clicked += (s1, e1) =>
            {
                if (this.UserMadeSelection != null)
                {
                    this.UserMadeSelection(this, null);
                }
            };
            Button buttonNotListed = new BybButton {
                Style = (Style)App.Current.Resources["BlackButtonStyle"], Text = "It's not listed here"
            };

            buttonNotListed.Clicked += buttonNotListed_Clicked;
            var panelOkCancel = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(Config.OkCancelButtonsPadding),
                BackgroundColor   = Config.ColorGrayBackground,
                Spacing           = 1,
                Children          =
                {
                    buttonCancel,
                    buttonNotListed,
                }
            };

            Content = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing         = 0,
                Children        =
                {
                    new BybTitle("Pick Venue")
                    {
                        VerticalOptions = LayoutOptions.Start
                    },
                    new ScrollView
                    {
                        Padding         = new Thickness(0),
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        Content         = new StackLayout
                        {
                            Padding     = new Thickness(0),
                            Spacing     = 0,
                            Orientation = StackOrientation.Vertical,
                            Children    =
                            {
                                this.findVenuesControl,
                            }
                        }
                    },

                    panelOkCancel
                }
            };
            Padding = new Thickness(0);
        }
Ejemplo n.º 18
0
        public SetupExistingUserPage()
        {
            this.BackgroundColor = Color.White;

            emailEditor = new BybStandardEntry()
            {
                Placeholder = "Your e-mail address", Keyboard = Keyboard.Email
            };
            emailEditor.Focused   += (s, e) => { this.Content.VerticalOptions = LayoutOptions.Start; };
            emailEditor.Completed += (s, e) => { passwordEditor.Focus(); };

            passwordEditor = new BybStandardEntry()
            {
                Placeholder = "Password or PIN", IsPassword = true
            };
            passwordEditor.Focused += (s, e) => { this.Content.VerticalOptions = LayoutOptions.Start; };

            Button buttonForgotPassword = new BybButton()
            {
                Style             = (Style)App.Current.Resources["SimpleButtonStyle"],
                Text              = "Forgot password",
                HorizontalOptions = LayoutOptions.Center
            };

            buttonForgotPassword.Clicked += (s1, e1) =>
            {
                App.Navigator.OpenBrowserApp("https://www.snookerbyb.com/account/forgotpassword");
            };

            if (Config.IsTablet)
            {
                emailEditor.HorizontalOptions    = LayoutOptions.Center;
                passwordEditor.HorizontalOptions = LayoutOptions.Center;
                emailEditor.WidthRequest         = 350;
                passwordEditor.WidthRequest      = 350;
            }

            Button loginButton = new BybButton()
            {
                Text  = "Sign in",
                Style = (Style)App.Current.Resources[Config.IsTablet ? "LargeButtonOfSetWidthStyle" : "LargeButtonStyle"]
            };
            Button facebookButton = new BybButton()
            {
                Text  = "Sign in with Facebook",
                Style = (Style)App.Current.Resources[Config.IsTablet ? "LargeButtonOfSetWidthStyle" : "LargeButtonStyle"]
            };

            loginButton.Clicked    += loginButton_Clicked;
            facebookButton.Clicked += facebookButton_Clicked;

            this.Title   = "Existing user";
            this.Content = new StackLayout()
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    new BybLabel {
                        Text = "With Facebook", FontSize = Config.VeryLargeFontSize, TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.Center
                    },
                    facebookButton,
                    new BybLabel {
                        Text = "We will never post without your permission", HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, TextColor = Config.ColorBlackTextOnWhite
                    },
                    new BoxView  {
                        HeightRequest = 10
                    },

                    new BybLabel {
                        Text = "With E-mail", FontSize = Config.VeryLargeFontSize, TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.Center
                    },
                    emailEditor,
                    passwordEditor,
                    loginButton,
                    new BoxView  {
                        HeightRequest = 1
                    },
                    buttonForgotPassword,
                    //new BybLabel { Text = "This will sign you in to " + Config.WebsiteName, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center },
                }
            };

            if (Config.IsTablet)
            {
                this.Padding = new Thickness(120, 0, 120, 0);
            }
            else
            {
                this.Padding = new Thickness(30, 0, 30, 0);
            }
        }
Ejemplo n.º 19
0
        public SetupNewUserPage()
        {
            this.BackgroundColor = Color.White;

            Button facebookButton = new BybButton()
            {
                Text  = "Connect with Facebook",
                Style = (Style)App.Current.Resources[Config.IsTablet ? "LargeButtonOfSetWidthStyle" : "LargeButtonStyle"]
            };
            Button emailButton = new BybButton()
            {
                Text  = "Register with your e-mail",
                Style = (Style)App.Current.Resources[Config.IsTablet ? "LargeButtonOfSetWidthStyle" : "LargeButtonStyle"]
            };

            facebookButton.Clicked += facebookButton_Clicked;
            emailButton.Clicked    += loginButton_Clicked;

            this.Title   = "New User";
            this.Content = new StackLayout()
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Children          =
                        {
                            new BybLabel {
                                Text = "Option 1", FontSize = Config.VeryLargeFontSize, TextColor = Config.ColorBlackTextOnWhite
                            },
                        }
                    },
                    facebookButton,
                    new BybLabel         {
                        Text = "We will never post without your permission", HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, TextColor = Config.ColorBlackTextOnWhite
                    },
                    new BoxView          {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    },

                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Children          =
                        {
                            new BybLabel {
                                Text = "Option 2", FontSize = Config.VeryLargeFontSize, TextColor = Config.ColorBlackTextOnWhite
                            },
                        }
                    },
                    emailButton,
                    new BoxView          {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    },
                }
            };

            if (Config.IsTablet)
            {
                this.Padding = new Thickness(120, 0, 120, 0);
            }
            else
            {
                this.Padding = new Thickness(30, 0, 30, 0);
            }
        }
Ejemplo n.º 20
0
        public SetupNewUserEmailPage()
        {
            this.BackgroundColor = Color.White;

            emailEditor = new BybStandardEntry()
            {
                Placeholder = "Your e-mail address", Keyboard = Keyboard.Email
            };
            //passwordEditor = new BybStandardEntry() { Placeholder = "4-Digit PIN", IsPassword = true, Keyboard.Numeric };
            //passwordEditor2 = new BybStandardEntry() { Placeholder = "Confirm PIN", IsPassword = true, Keyboard.Numeric };
            //nameEditor = new BybStandardEntry() { Placeholder = "Your name", Keyboard = Keyboard.Text, IsVisible = Config.App == MobileAppEnum.SnookerForVenues };

//			passwordEditor.TextChanged += (s1, e1) => {
//				if (passwordEditor.Text.Length >= AccessPinHelper.PinLength)
//					passwordEditor2.Focus();
//			};
//            emailEditor.Completed += (s1, e1) => {
//				passwordEditor.Focus();
//			};
//			passwordEditor.Completed += (s1, e1) => {
//				passwordEditor2.Focus();
//			};
//            passwordEditor2.Completed += (s1, e1) =>
//            {
//            };

            Button okButton = new BybButton()
            {
                Text  = "Register",
                Style = (Style)App.Current.Resources[Config.IsTablet ? "LargeButtonOfSetWidthStyle" : "LargeButtonStyle"]
            };

            okButton.Clicked += okButton_Clicked;

            if (Config.IsTablet)
            {
                emailEditor.HorizontalOptions = LayoutOptions.Center;
                //passwordEditor.HorizontalOptions = LayoutOptions.Center;
                //passwordEditor2.HorizontalOptions = LayoutOptions.Center;
                //nameEditor.HorizontalOptions = LayoutOptions.Center;
                emailEditor.WidthRequest = 350;
                //passwordEditor.WidthRequest = 350;
                //passwordEditor2.WidthRequest = 350;
                //nameEditor.WidthRequest = 350;
            }

            this.Content = new StackLayout
            {
                Children =
                {
                    new BoxView()
                    {
                        HeightRequest = 10
                    },
                    new BybLabel {
                        Text = "Register With E-mail", FontSize = Config.VeryLargeFontSize, TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.Center
                    },
                    new BoxView()
                    {
                        HeightRequest = 10
                    },

                    emailEditor,
                    //passwordEditor,
                    //passwordEditor2,
                    //nameEditor,
                    new BoxView()
                    {
                        HeightRequest = 10
                    },
                    okButton,
                }
            };

            if (Config.IsTablet)
            {
                this.Padding = new Thickness(120, 0, 120, 0);
            }
            else
            {
                this.Padding = new Thickness(30, 0, 30, 0);
            }
        }
Ejemplo n.º 21
0
        public PickOwnerOfABreakPage(SnookerMatchMetadata metadata)
        {
            this.metadata = metadata;

            this.title = new BybTitle("Whose Break Is It?")
            {
                VerticalOptions = LayoutOptions.Start
            };

            double imageSize = Config.DeviceScreenHeightInInches < 4 ? 70 : 100;

            // images
            this.imageYou = new Image()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Source            = App.ImagesService.GetImageSource(null)
            };
            this.imageOpponent = new Image()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Source            = App.ImagesService.GetImageSource(null)
            };
            this.labelYou = new BybLabel()
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.Fill,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                Text = "You"
            };
            this.labelOpponent = new BybLabel()
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.Fill,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Grid gridWithImages = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                Padding           = new Thickness(0),
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                BackgroundColor   = Color.White,
            };

            gridWithImages.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            gridWithImages.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Absolute)
            });
            gridWithImages.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            gridWithImages.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(10, GridUnitType.Absolute)
            });
            gridWithImages.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(imageSize, GridUnitType.Absolute)
            });
            gridWithImages.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(40, GridUnitType.Absolute)
            });
            gridWithImages.Children.Add(this.imageYou, 0, 1);
            gridWithImages.Children.Add(this.imageOpponent, 2, 1);
            gridWithImages.Children.Add(this.labelYou, 0, 2);
            gridWithImages.Children.Add(this.labelOpponent, 2, 2);

            this.imageYou.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { youClicked(); }),
                NumberOfTapsRequired = 1
            });
            this.labelYou.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { youClicked(); }),
                NumberOfTapsRequired = 1
            });
            this.imageOpponent.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { opponentClicked(); }),
                NumberOfTapsRequired = 1
            });
            this.labelOpponent.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { opponentClicked(); }),
                NumberOfTapsRequired = 1
            });

            // cancel button
            Button buttonCancel = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "Cancel"
            };

            buttonCancel.Clicked += (s1, e1) =>
            {
                if (this.UserMadeSelection != null)
                {
                    this.UserMadeSelection(this, null);
                }
            };
            var panelOkCancel = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                //BackgroundColor = Config.ColorBackground,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(Config.OkCancelButtonsPadding),
                Spacing           = 1,
                Children          =
                {
                    buttonCancel
                }
            };

            // content
            Content = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    new ScrollView
                    {
                        Padding         = new Thickness(0),
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        Content         = new StackLayout
                        {
                            Padding     = new Thickness(0),
                            Spacing     = 0,
                            Orientation = StackOrientation.Vertical,
                            Children    =
                            {
                                title,
                                gridWithImages
                            }
                        }
                    },

                    panelOkCancel
                }
            };
            Padding = new Thickness(0, 0, 0, 0);

            this.labelYou.Text   = metadata.PrimaryAthleteName;
            this.imageYou.Source = App.ImagesService.GetImageSource(metadata.PrimaryAthletePicture);
            if (this.metadata.HasOpponentAthlete == false)
            {
                this.imageOpponent.Source = new FileImageSource()
                {
                    File = "plus.png"
                };
                this.labelOpponent.Text = "Pick";
            }
            else
            {
                this.imageOpponent.Source = App.ImagesService.GetImageSource(this.metadata.OpponentPicture);
                this.labelOpponent.Text   = this.metadata.OpponentAthleteName;
            }
        }
Ejemplo n.º 22
0
        public RecordControl()
        {
            this.metadata = new MetadataHelper().CreateDefault();

            this.Padding         = new Thickness(0);
            this.BackgroundColor = Config.ColorGrayBackground;

            // new match panel
            this.metadataControl         = new SnookerMatchMetadataControl(this.metadata, true);
            this.metadataControl.Padding = new Thickness(0, 0, 0, 0);
            this.buttonNewMatch          = new BybButton()
            {
                Text              = "Record a match",
                Style             = (Style)App.Current.Resources["BlackButtonStyle"],
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            this.buttonNewBreak = new BybButton()
            {
                Text              = "Record a break",
                Style             = (Style)App.Current.Resources["BlackButtonStyle"],
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            this.buttonNewMatch.Clicked += buttonNewMatch_Clicked;
            this.buttonNewBreak.Clicked += buttonNewBreak_Clicked;
            this.panelNewMatch           = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 0,
                Padding     = new Thickness(0),
                Children    =
                {
                    this.metadataControl,
                    new StackLayout()
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Padding           = new Thickness(0,        12, 0, 0),
                        Spacing           = Config.SpaceBetweenButtons,
                        Children          =
                        {
                            this.buttonNewBreak,
                            this.buttonNewMatch,
                        }
                    }
                }
            };

            // paused matches panel
            this.panelPausedMatches = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 0,
                Padding     = new Thickness(0, 0, 0, 0)
            };

            // the top level stack
            this.stackTopLevel = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(12, 12, 12, 12),
                Spacing     = 0,
                Children    =
                {
                    this.panelPausedMatches,
                    this.panelNewMatch,
                }
            };
            this.Content = this.stackTopLevel;

            this.stackTopLevel.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() =>
                {
                    App.Navigator.ShowInternalOptions();
                }),
                NumberOfTapsRequired = 2,
            });
        }
Ejemplo n.º 23
0
        public PickAthletePage()
        {
            this.BackgroundColor = Config.ColorGrayBackground;

            bool friendsByDefault = App.Cache.People.GetFriends().Count() > 0;

            // FindPeopleControl
            this.findPeopleControl = new FindPeopleControl(friendsByDefault)
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0, 0, 0, 0)
            };
            this.findPeopleControl.UserClickedOnPerson += (s1, e1) =>
            {
                if (this.UserMadeSelection != null)
                {
                    this.UserMadeSelection(this, new SelectedPersonEventArgs()
                    {
                        Person = e1.Person
                    });
                }
            };

            // buttons
            Button buttonCancel = new BybButton {
                Text = "Cancel", Style = (Style)App.Current.Resources["LargeButtonStyle"]
            };

            buttonCancel.Clicked += (s1, e1) =>
            {
                if (this.UserMadeSelection != null)
                {
                    this.UserMadeSelection(this, new SelectedPersonEventArgs()
                    {
                        Person = null
                    });
                }
            };
            buttonUnknown = new BybButton {
                Text = "Unknown", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            buttonUnknown.Clicked += (s1, e1) =>
            {
                if (this.UserMadeSelection != null)
                {
                    this.UserMadeSelection(this, new SelectedPersonEventArgs()
                    {
                        Person = null, IsUnknown = true,
                    });
                }
            };
            var panelOkCancel = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(Config.OkCancelButtonsPadding),
                Spacing           = 1,
                Children          =
                {
                    buttonCancel,
                    buttonUnknown,
                }
            };

            this.title = new BybTitle("Pick Opponent")
            {
                VerticalOptions = LayoutOptions.Start
            };

            // content
            Content = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing         = 0,
                Children        =
                {
                    title,
                    findPeopleControl,
                    panelOkCancel
                }
            };
            Padding = new Thickness(0, 0, 0, 0);
        }
Ejemplo n.º 24
0
        void init()
        {
            /// title panel
            ///
            this.labelTitle = new BybLabel()
            {
                TextColor  = Color.White,
                FontFamily = Config.FontFamily,
                //FontAttributes = FontAttributes.Bold,
                FontSize = Config.LargerFontSize,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HeightRequest           = Config.TitleHeight,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            };
            this.labelTitle.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => { this.labelTitleClicked(); }),
                NumberOfTapsRequired = 1
            });
//            this.imageOpenMetadata = new Image()
//            {
//                Source = new FileImageSource() { File = "down.png" },
//                HeightRequest = 20,
//                WidthRequest = 20,
//            };
//            this.imageOpenMetadata.GestureRecognizers.Add(new TapGestureRecognizer
//            {
//                Command = new Command(() => { this.openMetadataSlideout(); }),
//                NumberOfTapsRequired = 1
//            });
            var panelTitle = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(10, 20, 10, 0),
                Spacing           = 0,
                Children          =
                {
                    new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            //imageOpenMetadata,
                            labelTitle,
                        }
                    },
                }
            };

            /// pocketed balls
            ///
            this.panelPocketedBallsInner = new StackLayout()
            {
                HeightRequest     = Config.SmallBallSize + 5,
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 2.0,
                Padding           = new Thickness(0)
            };
            this.buttonDelete = new BybButton()
            {
                Text              = "X",
                BackgroundColor   = Config.ColorBlackBackground, // it's not DarkGrey, it's black
                HorizontalOptions = LayoutOptions.End,
                TextColor         = Config.ColorTextOnBackground
            };
            buttonDelete.Clicked += buttonDelete_Clicked;

            this.foulCheckbox = new CheckBox()
            {
                IsVisible     = false,
                Checked       = false,
                DefaultText   = "- tap here if a foul -",
                UncheckedText = "- tap here if a foul -",
                CheckedText   = "Foul",
                FontSize      = Config.DefaultFontSize,
                FontName      = Config.FontFamily,
                //HorizontalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                //MinimumWidthRequest = 120
            };
            this.foulCheckbox.CheckedChanged += (s1, e1) =>
            {
                updateFoul(this.foulCheckbox.Checked);
            };
            this.panelPocketedBallsOuter = new ScrollView
            {
                Padding           = new Thickness(0, 0, 0, 0),
                Orientation       = ScrollOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Content           = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Padding     = new Thickness(15, 0, 15, 0),
                    Children    =
                    {
                        this.panelPocketedBallsInner,
                        this.foulCheckbox,
                        buttonDelete
                    }
                }
            };

            /// panel with the score
            ///
            this.entryPoints = new BybLargeEntry2()
            {
                KeepOnlyNumbers   = true,
                WidthRequest      = 100,
                Keyboard          = Keyboard.Numeric,
                BackgroundColor   = Color.Transparent,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                Placeholder       = "--",
                Text = null//"0"
            };
            this.entryBallsCount = new BybLargeEntry2()
            {
                KeepOnlyNumbers   = true,
                WidthRequest      = 100,
                Keyboard          = Keyboard.Numeric,
                BackgroundColor   = Color.Transparent,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                Placeholder       = "--",
                Text = null//"0"
            };
            this.entryPoints.TextChanged     += entryScore_TextChanged;
            this.entryBallsCount.TextChanged += entryBallsCount_TextChanged;
            this.entryPoints.Focused         += entryScore_Focused;
            this.entryBallsCount.Focused     += entryScore_Focused;
            this.entryPoints.Unfocused       += entryScore_Unfocused;
            this.entryBallsCount.Unfocused   += entryScore_Unfocused;
            var panelScoreInner = new Grid
            {
                Padding           = new Thickness(0, 0, 0, 0),
                ColumnSpacing     = 1,
                RowSpacing        = 1,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Absolute)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Absolute)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Absolute)
                    },
                }
            };
            var panelScoreBalls = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                BackgroundColor = Config.ColorBackground,
                Padding         = new Thickness(15, 10, 0, 10),
                Spacing         = 3,
                Children        =
                {
                    new BybLabel {
                        Text = " Balls", WidthRequest = 60, TextColor = Config.ColorTextOnBackgroundGrayed, HorizontalOptions = LayoutOptions.Start
                    },
                    this.entryBallsCount
                }
            };

            panelScoreBalls.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    this.entryBallsCount.Focus();
                }),
                NumberOfTapsRequired = 1
            });
            panelScoreInner.Children.Add(panelScoreBalls, 0, 1);
            var panelScorePoints = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                BackgroundColor = Config.ColorBackground,
                Padding         = new Thickness(15, 10, 0, 10),
                Spacing         = 3,
                Children        =
                {
                    new BybLabel {
                        Text = " Points", WidthRequest = 60, TextColor = Config.ColorTextOnBackgroundGrayed, HorizontalOptions = LayoutOptions.Start
                    },
                    this.entryPoints
                }
            };

            panelScorePoints.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    this.entryPoints.Focus();
                }),
                NumberOfTapsRequired = 1
            });
            panelScoreInner.Children.Add(panelScorePoints, 2, 1);
            StackLayout panelScore = new StackLayout()
            {
                //BackgroundColor = Color.Blue,
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(15, 0, 15, 0),
                Children          =
                {
                    panelScoreInner
                }
            };

            /// balls
            ///
            buttonsBalls = new List <Button>();
            foreach (var color in Config.BallColors)
            {
                Color textColor = Color.White;
                if (Config.BallColors.IndexOf(color) == 0)
                {
                    textColor = Color.Gray;
                }
                if (Config.BallColors.IndexOf(color) == 2)
                {
                    textColor = Color.Gray;
                }
                Color borderColor = Color.Black;
                if (Config.BallColors.IndexOf(color) == 7)
                {
                    borderColor = Config.ColorTextOnBackgroundGrayed;
                }

                var buttonBall = new BybButton
                {
                    Text                 = Config.BallColors.IndexOf(color) == 0 ? "x" : Config.BallColors.IndexOf(color).ToString(),
                    BackgroundColor      = color,
                    BorderColor          = borderColor,
                    TextColor            = textColor,
                    BorderWidth          = 1,
                    BorderRadius         = (int)(sizeOfBalls / 2),
                    HeightRequest        = sizeOfBalls,
                    MinimumHeightRequest = sizeOfBalls,
                    WidthRequest         = sizeOfBalls,
                    MinimumWidthRequest  = sizeOfBalls,

                    FontFamily     = Config.FontFamily,
                    FontSize       = Config.LargerFontSize,
                    FontAttributes = Config.BallColors.IndexOf(color) == 1 ? FontAttributes.Bold : FontAttributes.None
                };
                buttonBall.Clicked += buttonBall_Clicked;
                buttonsBalls.Add(buttonBall);
            }
            this.panelBalls = new StackLayout
            {
                Padding         = new Thickness(0),
                Orientation     = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.Center,
                Spacing         = buttonSpacing,
                Children        =
                {
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Spacing           = buttonSpacing,
                        Children          =
                        {
                            buttonsBalls[7],
                        }
                    },
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Spacing           = buttonSpacing,
                        Children          =
                        {
                            buttonsBalls[1],
                            //buttonsBalls[0],
                        }
                    },
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Spacing           = buttonSpacing,
                        Children          =
                        {
                            buttonsBalls[6],
                        }
                    },
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Spacing           = buttonSpacing,
                        Children          =
                        {
                            buttonsBalls[5],
                        }
                    },
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Spacing           = buttonSpacing,
                        Children          =
                        {
                            buttonsBalls[3],
                            buttonsBalls[4],
                            buttonsBalls[2],
                        }
                    },
                }
            };

            panelEnteringNumbers = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(20, 30, 20, 20),
                Spacing     = 20,
                Children    =
                {
                    new BybLabel
                    {
                        Text              = "Tap here when done",
                        TextColor         = Config.ColorTextOnBackground,
                        HorizontalOptions = LayoutOptions.Center,
                    },
                }
            };
            panelEnteringNumbers.IsVisible = false;

            /// buttons
            ///
            Button buttonOk = new BybButton {
                Text = "Done", Style = (Style)App.Current.Resources["LargeButtonStyle"]
            };
            Button buttonCancel = new BybButton {
                Text = "Cancel", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };

            buttonOk.Clicked     += buttonOk_Clicked;
            buttonCancel.Clicked += buttonCancel_Clicked;
            var panelOkCancel = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                //BackgroundColor = Config.ColorBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(Config.OkCancelButtonsPadding),
                Spacing           = 1,
                Children          =
                {
                    buttonCancel,
                    buttonOk,
                }
            };

            /// top-level Grid
            ///
            this.grid = new Grid
            {
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                Padding           = new Thickness(0),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },                                                                                                // title
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Absolute)
                    },                                                                                                // empty space
                    new RowDefinition {
                        Height = new GridLength(80 + (Config.IsTablet ? 40 : 0), GridUnitType.Absolute)
                    },                                                                                                                         // score
                    new RowDefinition {
                        Height = new GridLength(Config.IsTablet ? 60 : 35, GridUnitType.Absolute)
                    },                                                                                                // pocketed balls

                    new RowDefinition {
                        Height = new GridLength(0, GridUnitType.Star)
                    },                                                                    // empty space
                    new RowDefinition {
                        Height = new GridLength(10, GridUnitType.Star)
                    },                                                                    // balls
                    new RowDefinition {
                        Height = new GridLength(0, GridUnitType.Star)
                    },                                                                    // empty space

                    new RowDefinition {
                        Height = new GridLength(Config.OkCancelButtonsHeight + Config.OkCancelButtonsPadding * 2, GridUnitType.Absolute)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };
            grid.Children.Add(panelTitle, 0, 0);
            grid.Children.Add(panelScore, 0, 2);
            grid.Children.Add(panelPocketedBallsOuter, 0, 3);
            grid.Children.Add(panelBalls, 0, 5);
            //grid.Children.Add(panelVoice, 0, 5);
            grid.Children.Add(panelEnteringNumbers, 0, 5);
            grid.Children.Add(panelOkCancel, 0, 7);

            // voice button
            this.voiceButtonControl = new VoiceButtonControl()
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start,
                Padding           = new Thickness(15, 15, 0, 0),
            };
            grid.Children.Add(this.voiceButtonControl, 0, 5);


            /// slide-out panel with metadata
            ///
            //            this.metadataControl = new SnookerMatchMetadataControl(this.metadata, true)
            //            {
            //                Padding = new Thickness(15, 15, 15, 15)
            //            };
            //            this.metadataControl.VenueSelected += (s1, e1) => { this.removeSlideouts(); };
            //            this.metadataControl.OpponentSelected += (s1, e1) => { this.removeSlideouts(); };
            //            this.buttonHideMetadata = new BybButton() { Text = "OK", Style = (Style)App.Current.Resources["BlackButtonStyle"], HeightRequest = Config.OkCancelButtonsHeight, VerticalOptions = LayoutOptions.Start };
            //            this.buttonHideMetadata.Clicked += (s1, e1) => { this.removeSlideouts(); };
            //            this.panelSlideoutMetadata = new StackLayout()
            //            {
            //                Orientation = StackOrientation.Vertical,
            //                Padding = new Thickness(15, 0, 15, 0),
            //                HorizontalOptions = LayoutOptions.FillAndExpand,
            //                IsVisible = false,
            //                BackgroundColor = Config.ColorBackground,
            //                Children =
            //                {
            //                    this.metadataControl,
            //                    this.buttonHideMetadata
            //                }
            //            };

            /// content
            ///
            this.absoluteLayout = new AbsoluteLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            this.absoluteLayout.Children.Add(grid, new Point(0, 0));
            //this.absoluteLayout.Children.Add(panelSlideoutMetadata, new Rectangle(0, -100, this.Width, 100));
            Content              = this.absoluteLayout;
            this.Padding         = new Thickness(0, 0, 0, 0);
            this.BackgroundColor = Color.Black;

            this.updateDeleteButton();
            this.updateTitle();

            this.voiceButtonControl.PageTopLevelLayout = absoluteLayout;
        }
Ejemplo n.º 25
0
        public SnookerBreakControl(SnookerMatchMetadata metadata, Label labelPointsLeft, BallsOnTable ballsOnTable, LargeNumberEntry2 entryA, LargeNumberEntry2 entryB)
        {
            this.metadata           = metadata;
            this.sbcLabelPointsLeft = labelPointsLeft;
            this.localBallsOnTable  = ballsOnTable;
            this.framePointsEntryA  = entryA;
            this.framePointsEntryB  = entryB;

            if ((this.framePointsEntryA.Number != null) &&
                (this.framePointsEntryB.Number != null))
            {
                curA = (int)this.framePointsEntryA.Number;
                curB = (int)this.framePointsEntryB.Number;
            }
            else
            {
                curA = 0;
                curB = 0;
            }

            updatePointsDiff();

            /// pocketed balls
            ///

            this.panelPocketedBalls1 = new StackLayout()
            {
                HeightRequest   = Config.SmallBallSize + (Config.IsTablet ? 5 : 2),
                Orientation     = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Center,
                Spacing         = Config.IsTablet ? 3 : 1,
                Padding         = new Thickness(0),
            };
            this.panelPocketedBalls2 = new StackLayout()
            {
                HeightRequest   = Config.SmallBallSize + (Config.IsTablet ? 5 : 2),
                Orientation     = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Center,
                Spacing         = Config.IsTablet ? 3 : 1,
                Padding         = new Thickness(0),
            };
            this.panelPocketedBalls3 = new StackLayout()
            {
                HeightRequest   = Config.SmallBallSize + (Config.IsTablet ? 5 : 2),
                Orientation     = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Center,
                Spacing         = Config.IsTablet ? 3 : 1,
                Padding         = new Thickness(0),
            };
            this.labelPoints = new BybLabel()
            {
                Text            = "",
                TextColor       = Config.ColorTextOnBackground,
                VerticalOptions = LayoutOptions.Center,
            };
            this.labelNoPoints = new BybLabel()
            {
                IsVisible = true,

                Text = "Tap on balls, then swipe here to finish break",
                //Text = "Tap on balls\r\nThen swipe here to assign to a player",
                //Text = "Tap balls, then swipe here to assign to player",
                TextColor = Config.ColorGrayTextOnWhite,
                //FontFamily = Config.FontFamily,
                //FontSize = Config.DefaultFontSize - 1,
                VerticalOptions         = LayoutOptions.Fill,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            this.buttonDelete = new BybLabel()
            {
                Text                    = "X",
                TextColor               = Config.ColorTextOnBackground,
                WidthRequest            = Config.IsTablet ? 35 : 25,
                HeightRequest           = Config.IsTablet ? 35 : 30,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            this.buttonDelete.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.buttonDelete_Clicked(this, EventArgs.Empty); })
            });

            this.foulCheckbox = new CheckBox()
            {
                Checked           = false,
                DefaultText       = "- tap here if a foul -",
                UncheckedText     = "- tap here if a foul -",
                CheckedText       = "Foul",
                FontSize          = Config.DefaultFontSize,
                FontName          = Config.FontFamily,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
            };
            this.foulCheckbox.CheckedChanged += (s1, e1) =>
            {
                updateFoul(this.foulCheckbox.Checked);
            };

            // container for balls and delete button
            var panelPocketedBallsActualBallsContainer = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.Center,
                Spacing           = 0,
                Padding           = new Thickness(0),
                //BackgroundColor = Color.Yellow,
                Children =
                {
                    this.labelNoPoints,
                    this.labelPoints,
                    new StackLayout()
                    {
                        Orientation       = StackOrientation.Vertical,
                        Padding           = new Thickness(0),
                        Spacing           = 0,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.Center,
                        Children          =
                        {
                            this.panelPocketedBalls1,
                            this.panelPocketedBalls2,
                            this.panelPocketedBalls3,
                        }
                    },
                    this.buttonDelete,
                    this.foulCheckbox
                }
            };

            /// the panel with pocketed balls and tips
            ///

            // draggable panel
            this.swipePanel = new SwipePanel(
                panelPocketedBallsActualBallsContainer,
                "Add to " + (this.metadata.OpponentAthleteName ?? "Opponent"),
                "Add to " + (this.metadata.PrimaryAthleteName ?? "You"),
                this.panelPocketedBallsHeight)
            {
                Opacity           = 0.01,
                HeightRequest     = this.panelPocketedBallsHeight,
                Padding           = new Thickness(0, 0, 0, 0),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                BackgroundColor   = Config.ColorBlackBackground,
            };
            this.swipePanel.breakOwnerChanged += swipePanel_breakOwnerChanged;

            this.swipePanel.DraggedLeft += () =>
            {
                if (true == this.swipePanel.getIsOpponentBreak())
                {
                    // if Swiped left, but was counting for opponent:
                    //   - change the break owner first
                    //   - and update the frame score
                    this.swipePanel.setIsOpponentBreak(false);
                    updateOwnerChanged();
                }
                localBallsOnTable.breakFinished();
                updatePointsDiff();

                if (this.DoneLeft != null)
                {
                    this.DoneLeft(this, EventArgs.Empty);
                }
            };
            this.swipePanel.DraggedRight += () =>
            {
                if (false == this.swipePanel.getIsOpponentBreak())
                {
                    // if Swiped right, but was counting for "me":
                    //   - change the break owner first
                    //   - and update the frame score
                    this.swipePanel.setIsOpponentBreak(true);
                    updateOwnerChanged();
                }
                localBallsOnTable.breakFinished();
                updatePointsDiff();

                if (this.DoneRight != null)
                {
                    this.DoneRight(this, EventArgs.Empty);
                }
            };

            /// balls
            ///
            buttonsBalls = new List <Button>();
            foreach (var color in Config.BallColors)
            {
                Color textColor = Color.White;
                if (Config.BallColors.IndexOf(color) == 0)
                {
                    textColor = Color.Gray;
                }
                if (Config.BallColors.IndexOf(color) == 2)
                {
                    textColor = Color.Gray;
                }
                Color borderColor = Color.Black;
                if (Config.BallColors.IndexOf(color) == 7)
                {
                    borderColor = Config.ColorTextOnBackgroundGrayed;
                }

                var buttonBall = new BybButton
                {
                    Text                 = Config.BallColors.IndexOf(color) == 0 ? "x" : Config.BallColors.IndexOf(color).ToString(),
                    BackgroundColor      = color,
                    BorderColor          = borderColor,
                    TextColor            = textColor,
                    BorderWidth          = 1,
                    BorderRadius         = (int)(sizeOfBalls / 2),
                    HeightRequest        = sizeOfBalls,
                    MinimumHeightRequest = sizeOfBalls,
                    WidthRequest         = sizeOfBalls,
                    MinimumWidthRequest  = sizeOfBalls,

                    FontFamily     = Config.FontFamily,
                    FontSize       = Config.LargerFontSize,
                    FontAttributes = Config.BallColors.IndexOf(color) == 1 ? FontAttributes.Bold : FontAttributes.None
                };
                buttonBall.Clicked += buttonBall_Clicked;
                buttonsBalls.Add(buttonBall);
            }

            this.grid = new Grid()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                Padding           = new Thickness(0, padding, 0, 0),
                BackgroundColor   = Config.ColorBlackBackground,
                ColumnDefinitions =
                {
                    //new ColumnDefinition() { Width = new GridLength(90, GridUnitType.Absolute) },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    //new ColumnDefinition() { Width = new GridLength(90, GridUnitType.Absolute) },
                },
                RowDefinitions =
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
            };

            this.buildPanelBalls();
            //grid.Children.Add(panelBalls, 0, 0);//1, 0);

            this.HelpButtonControl = new HelpButtonControl()
            {
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(0, 0, 0, 0),
            };

            this.label_ballsOnTable = new BybLabel()
            {
                Text                    = "On table",
                TextColor               = Config.ColorGrayTextOnWhite,
                VerticalOptions         = LayoutOptions.Fill,
                VerticalTextAlignment   = TextAlignment.Start,
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.Start,
            };

            // add a ball
            this.label_redsOnTable = new BybLabel()
            {
                Text            = "15",
                TextColor       = Config.ColorTextOnBackground,
                VerticalOptions = LayoutOptions.Center,
            };
            int   ballScore      = 1; // or for lowest colored
            Color color2         = Config.BallColors[ballScore];
            Color borderColor2   = color2;
            Color textColor2     = Color.Black;
            int   ballSizeMedium = (int)(Config.SmallBallSize * 1.5);

            redBall = new BybButton
            {
                IsEnabled            = true,
                Text                 = "",
                BackgroundColor      = color2,
                BorderColor          = borderColor2,
                FontFamily           = Config.FontFamily,
                FontSize             = Config.LargerFontSize,
                TextColor            = textColor2,
                BorderWidth          = 1,
                BorderRadius         = (int)(ballSizeMedium / 2),
                HeightRequest        = ballSizeMedium,
                MinimumHeightRequest = ballSizeMedium,
                WidthRequest         = ballSizeMedium,
                MinimumWidthRequest  = ballSizeMedium,
                VerticalOptions      = LayoutOptions.Center,
                HorizontalOptions    = LayoutOptions.Center
            };
            redBall.Clicked += (object sender, EventArgs e) =>
            {
                Console.WriteLine("Red ball clicked ");
                pickerReds.IsEnabled = true;
                pickerReds.Focus();
            };

            this.pickerReds = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                IsVisible         = false,
                IsEnabled         = false
            };
            this.pickerReds.Items.Add("0");
            this.pickerReds.Items.Add("1");
            this.pickerReds.Items.Add("2");
            this.pickerReds.Items.Add("3");
            this.pickerReds.Items.Add("4");
            this.pickerReds.Items.Add("5");
            this.pickerReds.Items.Add("6");
            this.pickerReds.Items.Add("7");
            this.pickerReds.Items.Add("8");
            this.pickerReds.Items.Add("9");
            this.pickerReds.Items.Add("10");
            this.pickerReds.Items.Add("11");
            this.pickerReds.Items.Add("12");
            this.pickerReds.Items.Add("13");
            this.pickerReds.Items.Add("14");
            this.pickerReds.Items.Add("15");
            this.pickerReds.SelectedIndex         = 0;
            this.pickerReds.SelectedIndexChanged += pickerReds_SelectedIndexChanged;

            this.pickerColors = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                //HeightRequest = 50
            };
            this.pickerColors.Items.Add("2");
            this.pickerColors.Items.Add("3");
            this.pickerColors.Items.Add("4");
            this.pickerColors.Items.Add("5");
            this.pickerColors.Items.Add("6");
            this.pickerColors.Items.Add("7");
            this.pickerColors.SelectedIndex         = 0;
            this.pickerColors.SelectedIndexChanged += pickerColors_SelectedIndexChanged;

            // add colored ball
            ballScore    = 2; // or for lowest colored
            color2       = Config.BallColors[ballScore];
            borderColor2 = color2;
            textColor2   = Color.Gray;

            coloredBall = new BybButton
            {
                IsEnabled            = true,
                Text                 = "",
                BackgroundColor      = color2,
                BorderColor          = borderColor2,
                FontFamily           = Config.FontFamily,
                FontSize             = Config.LargerFontSize,
                TextColor            = textColor2,
                BorderWidth          = 1,
                BorderRadius         = (int)(ballSizeMedium / 2),
                HeightRequest        = ballSizeMedium,
                MinimumHeightRequest = ballSizeMedium,
                WidthRequest         = ballSizeMedium,
                MinimumWidthRequest  = ballSizeMedium,
                VerticalOptions      = LayoutOptions.Center,
                HorizontalOptions    = LayoutOptions.Center
            };
            coloredBall.Clicked += (object sender, EventArgs e) =>
            {
                if (0 != localBallsOnTable.numberOfReds)
                {
                    Console.WriteLine("Colored ball clicked: but there are reds on the table, so ignore");
                }
                else
                {
                    Console.WriteLine("Colored ball clicked ");
                    pickerColors.IsEnabled = true;
                    pickerColors.Focus();
                }
            };
            this.stack_ballsOnTable = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(Config.IsTablet ? 30 : 15, 0, 0, 0),
                Spacing     = 10,
                //HorizontalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    label_ballsOnTable,
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Start,
                        Spacing           = buttonSpacing,
                        Padding           = new Thickness(0),
                        Children          =
                        {
                            redBall,
                            label_redsOnTable,
                            pickerReds
                        }
                    },
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Start,
                        Spacing           = buttonSpacing,
                        Padding           = new Thickness(0),
                        Children          =
                        {
                            coloredBall,
                            pickerColors
                        }
                    },
                }
            };

            this.VoiceButtonControl = new VoiceButtonControl()
            {
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(0, 0, 0, 0),
            };
            grid.Children.Add(new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                Padding           = new Thickness(Config.IsTablet ? 30 : 15, 0, 0, 0),
                Spacing           = 10,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    this.stack_ballsOnTable,
                    (new BoxView()
                    {
                        HeightRequest = 40,
                        BackgroundColor = Config.ColorBlackBackground,
                    }),
                    this.HelpButtonControl,
                    this.VoiceButtonControl,
                }
            }, 0, 0);

            /// content
            ///
            this.BackgroundColor = Config.ColorBlackBackground;
            this.Padding         = new Thickness(0);
            this.Spacing         = 0;
            this.Orientation     = StackOrientation.Vertical;

            this.Children.Add(new BoxView()
            {
                HeightRequest   = 1,
                BackgroundColor = Config.ColorBackground,
            });
            this.Children.Add(this.swipePanel);
            this.Children.Add(new BoxView()
            {
                HeightRequest   = 1,
                BackgroundColor = Config.ColorBackground,
            });
            this.Children.Add(grid);

            this.updateControls();

            // update pickers
            updateBallsOnTable_ballsChanged();
        }
Ejemplo n.º 26
0
        public FVOConfigPage()
        {
            this.BackgroundColor = Config.ColorGrayBackground;
            double labelWidth1 = 160;

            // venue
            this.labelVenue = new BybLabel()
            {
                FontAttributes = FontAttributes.Bold, TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center
            };
            Image imageVenue = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelVenue = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Venue", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelVenue,
                    imageVenue,
                }
            };

            panelVenue.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.buttonVenue_Clicked(); })
            });

            // table type
            this.pickerTableType = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            this.pickerTableType.Items.Add("10'");
            this.pickerTableType.Items.Add("12'");
            Image imageTableType = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelTableType = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Table size", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    pickerTableType,
                    imageTableType,
                }
            };

            panelTableType.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pickerTableType.Focus(); })
            });

            // notable break threshold
            this.pickerNotableBreakThreshold = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (int threshold in notableBreakThresholds)
            {
                this.pickerNotableBreakThreshold.Items.Add(threshold.ToString());
            }
            Image imageNotableBreakThreshold = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelNotableBreakThreshold = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //HeightRequest = Config.LargeButtonsHeight,
                Spacing         = 0,
                Padding         = new Thickness(15, 0, 15, 0),
                BackgroundColor = Color.White,
                Children        =
                {
                    new BybLabel {
                        Text = "Notable break threshold", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    pickerNotableBreakThreshold,
                    imageNotableBreakThreshold,
                }
            };

            panelNotableBreakThreshold.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pickerNotableBreakThreshold.Focus(); })
            });

            // table description
            this.entryTableDescription = new BybNoBorderEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Placeholder       = "optional",
            };
            var panelTableDescription = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Table description", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    entryTableDescription,
                }
            };

            // admi
            this.labelAdmin = new BybLabel()
            {
                FontAttributes = FontAttributes.Bold, TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center
            };
            Image imageAdmin = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelAdmin = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Admin", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelAdmin,
                    imageAdmin,
                }
            };

            panelAdmin.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() =>
                {
                    this.DisplayAlert("Byb", "To change the administrator - re-install the app.", "OK");
                })
            });

            // buttons
            Button buttonOk = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "Ok"
            };

            buttonOk.Clicked += buttonOk_Clicked;
            Button buttonCancel = new BybButton {
                Style = (Style)App.Current.Resources["BlackButtonStyle"], Text = "Cancel"
            };

            buttonCancel.Clicked += buttonCancel_Clicked;

            var stackLayout = new StackLayout
            {
                Spacing         = 0,
                Padding         = new Thickness(0),
                BackgroundColor = Config.ColorGrayBackground,

                Children =
                {
                    new BybTitle("Settings")
                    {
                        VerticalOptions = LayoutOptions.Start
                    },

                    new StackLayout()
                    {
                        Orientation       = StackOrientation.Vertical,
                        WidthRequest      = 500,
                        HorizontalOptions = LayoutOptions.Center,
                        Padding           = new Thickness(20),
                        Spacing           = 5,
                        Children          =
                        {
                            panelVenue,
                            panelTableType,
                            panelTableDescription,
                            panelNotableBreakThreshold,
                            panelAdmin,

                            new StackLayout()
                            {
                                Spacing           = 1,
                                Orientation       = StackOrientation.Horizontal,
                                HorizontalOptions = LayoutOptions.Fill,
                                HeightRequest     = Config.OkCancelButtonsHeight,
                                Padding           = new Thickness(0, 10, 0, 0),
                                Children          =
                                {
                                    buttonCancel,
                                    buttonOk,
                                }
                            }
                        }
                    },
                }
            };

            this.Content = stackLayout;
            this.Padding = new Thickness(0, 0, 0, 0);

            this.fill();
        }
Ejemplo n.º 27
0
        void fillPausedMatches()
        {
            // incompleted matches in the db
            var scoreObjs = (from i in App.Repository.GetScores(false)
                             where i.IsUnfinished == true
                             orderby i.TimeModified descending
                             select i).ToList();

            this.panelNewMatch.IsVisible = scoreObjs.Count() == 0;
            this.panelPausedMatches.Children.Clear();

            foreach (var scoreObj in scoreObjs)
            {
                var match         = SnookerMatchScore.FromScore(scoreObj.AthleteAID, scoreObj);
                var matchMetadata = new MetadataHelper().FromScoreForYou(match);

                var metadataControl = new SnookerMatchMetadataControl(matchMetadata, true)
                {
                    Padding = new Thickness(0, 0, 0, 0)
                };
                this.panelPausedMatches.Children.Add(metadataControl);

                var buttonDelete = new BybButton()
                {
                    Text              = "Cancel the match",
                    Style             = (Style)App.Current.Resources["BlackButtonStyle"],
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                };
                buttonDelete.Clicked += async(s1, e1) =>
                {
                    if (await App.Navigator.NavPage.DisplayAlert("Byb", "Delete this match?", "Yes, delete", "Cancel") == true)
                    {
                        App.Repository.SetIsDeletedOnScore(scoreObj.ScoreID, true);
                        this.DoOnOpen();
                    }
                };

                var buttonContinue = new BybButton()
                {
                    Text              = "Continue the match",
                    Style             = (Style)App.Current.Resources["LargeButtonStyle"],
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                };
                buttonContinue.Clicked += async(s1, e1) =>
                {
                    new MetadataHelper().ToScore(matchMetadata, match);

                    var page = new RecordMatchPage(match, false);
                    await App.Navigator.NavPage.Navigation.PushModalAsync(page);
                };

                this.panelPausedMatches.Children.Add(new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Padding           = new Thickness(0, 12, 0, 0),
                    Spacing           = 1,
                    Children          =
                    {
                        buttonDelete,
                        buttonContinue
                    }
                });
                this.panelPausedMatches.Children.Add(new BoxView()
                {
                    HeightRequest = 25
                });

                // load opponent names from web if it's not loaded yet
                if (matchMetadata.OpponentAthleteID > 0 && string.IsNullOrEmpty(matchMetadata.OpponentAthleteName) == true)
                {
                    Task.Run(async() =>
                    {
                        await App.Cache.LoadFromWebserviceIfNecessary_People(new List <int> ()
                        {
                            matchMetadata.OpponentAthleteID
                        });
                        var person = App.Cache.People.Get(matchMetadata.OpponentAthleteID);
                        if (person != null)
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                match.OpponentName                = person.Name;
                                match.OpponentPicture             = person.Picture;
                                matchMetadata.OpponentAthleteName = person.Name;
                                matchMetadata.OpponentPicture     = person.Picture;
                                metadataControl.Refill();
                            });
                        }
                    });
                }
                ;
            }
        }
Ejemplo n.º 28
0
        protected override View createViewForSingleItem(PersonBasicWebModel person)
        {
            try
            {
                string personPicture = person.Picture;
                var    imageSource   = App.ImagesService.GetImageSource(person.Picture, Config.App == MobileAppEnum.SnookerForVenues ? BackgroundEnum.Background1 : BackgroundEnum.White);

                var image = new Image()
                {
                    Source        = imageSource,
                    WidthRequest  = Config.PersonImageSize,
                    HeightRequest = Config.PersonImageSize,
                };

                var stackPerson = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    Spacing           = 10,
                    Padding           = new Thickness(5, 5, 5, 5),
                    BackgroundColor   = Config.App == MobileAppEnum.SnookerForVenues ? Config.ColorBackground : Config.ColorBackgroundWhite,
                    HorizontalOptions = LayoutOptions.Fill,
                    Children          =
                    {
                        new BoxView()
                        {
                            WidthRequest = 0, BackgroundColor = Color.Transparent
                        },
                        image,
                        new StackLayout
                        {
                            Orientation       = StackOrientation.Vertical,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions   = LayoutOptions.Center,
                            Spacing           = 3,
                            Children          =
                            {
                                new BybLabel
                                {
                                    Text              = person.Name,
                                    HeightRequest     = Config.IsTablet ? 25: 18,
                                    TextColor         = Config.App == MobileAppEnum.SnookerForVenues ? Config.ColorTextOnBackground : Config.ColorBlackTextOnWhite,
                                    HorizontalOptions = LayoutOptions.Start,
                                    FontAttributes    = FontAttributes.Bold
                                },
                                new BybLabel
                                {
                                    Text      = person.HasMetro ? person.Metro : "Unknown location",
                                    TextColor = Config.App == MobileAppEnum.SnookerForVenues ? Config.ColorTextOnBackgroundGrayed : Config.ColorGrayTextOnWhite,
                                },
                            }
                        },
                    }
                };

                if (this.ShowRemoveButton)
                {
                    Button removeButton = new BybButton()
                    {
                        Text = "x", WidthRequest = 30, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.FillAndExpand, Style = (Style)App.Current.Resources["SimpleButtonStyle"]
                    };
                    removeButton.Clicked += (s1, e1) => { this.onUserClickedRemoveOnPerson(person); };
                    stackPerson.Children.Add(removeButton);
                }

                image.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = new Command(() => { this.onUserClickedOnPerson(person); }),
                });
                stackPerson.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = new Command(() => { this.onUserClickedOnPerson(person); }),
                });

                return(stackPerson);
            }
            catch (Exception exc)
            {
                return(new StackLayout()
                {
                    Children =
                    {
                        new BybLabel()
                        {
                            Text = TraceHelper.ExceptionToString(exc)
                        }
                    }
                });
            }
        }
Ejemplo n.º 29
0
        public EventsControl()
        {
            this.Padding           = new Thickness(0);
            this.ColumnSpacing     = 0;
            this.RowSpacing        = 0;
            this.BackgroundColor   = Config.ColorGrayBackground;
            this.VerticalOptions   = LayoutOptions.FillAndExpand;
            this.HorizontalOptions = LayoutOptions.FillAndExpand;

            this.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            // tabs
            buttonNewEvents = new BybButtonWithNumber("Current")
            {
                IsNumberVisible = false, HeightRequest = Config.OkCancelButtonsHeight + (Config.IsTablet ? 15 : 5)
            };
            buttonNewEvents.Clicked += (s, e) => { this.IsShowingPastEvents = false; };
            buttonPastEvents         = new BybButtonWithNumber("Past")
            {
                IsNumberVisible = false, HeightRequest = Config.OkCancelButtonsHeight + (Config.IsTablet ? 15 : 5)
            };
            buttonPastEvents.Clicked += (s, e) => { this.IsShowingPastEvents = true; };
            this.Children.Add(new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = Color.White,
                Padding           = new Thickness(0, 0, 0, 0),
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    buttonNewEvents,
                    buttonPastEvents,
                }
            }, 0, 0);

            // buttons
            Button buttonAdd = new BybButton()
            {
                Text = "New event", Style = (Style)App.Current.Resources["LargeButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonAdd.Clicked += (s1, e1) =>
            {
                if (App.Navigator.GetOpenedPage(typeof(NewGameHostPage)) != null)
                {
                    return;
                }

                NewGameHostPage dlg = new NewGameHostPage();
                App.Navigator.NavPage.Navigation.PushModalAsync(dlg);
                dlg.Disappearing += (s2, e2) => { this.ReloadAsync(false); };
            };
            Button buttonSync = new BybButton()
            {
                Text = "Sync", Style = (Style)App.Current.Resources["BlackButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonSync.Clicked += (s1, e1) =>
            {
                App.Navigator.StartSyncAndCheckForNotifications();
                this.ReloadAsync(false);
            };
            this.panelWithButtons = new StackLayout
            {
                Spacing           = 1,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                Padding           = new Thickness(10, 10, 10, 0),
                Children          =
                {
                    buttonAdd,
                    buttonSync
                }
            };
            this.Children.Add(this.panelWithButtons, 0, 1);

            StackLayout stackLayout = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(),
            };

            // status
//            this.labelStatus = new BybLabel()
//            {
//                HorizontalOptions = LayoutOptions.Center,
//				TextColor = Config.ColorBlackTextOnWhite,
//            };
//            this.panelStatus = new StackLayout()
//            {
//                Orientation = StackOrientation.Vertical,
//                HorizontalOptions = LayoutOptions.FillAndExpand,
//                VerticalOptions = LayoutOptions.Start,
//                Padding = new Thickness(10, 15, 0, 15),
//                Children =
//                {
//                    labelStatus
//                }
//            };
//            stackLayout.Children.Add(this.panelStatus);

            // current invites
            this.panelFuture = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(0),
                Spacing     = 0,
            };
            stackLayout.Children.Add(panelFuture);
            this.listOfGameHostsFuture = new ListOfGameHostsControl();
            this.listOfGameHostsFuture.TreatAsASingleItem    = true;
            this.listOfGameHostsFuture.ShowCommentsCount     = true;
            this.listOfGameHostsFuture.Padding               = new Thickness(10, 10, 10, 0);
            this.listOfGameHostsFuture.UserChangedSomething += (s1, e1) => { this.ReloadAsync(false); };
            this.panelFuture.Children.Add(
                new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(10, 10, 0, 0),
                Children    =
                {
                    new BybLabel()
                    {
                        Text = "Your events and events you were invited to:",
                        HorizontalOptions       = LayoutOptions.Start,
                        HorizontalTextAlignment = TextAlignment.Start,
                        TextColor = Config.ColorGrayTextOnWhite,
                    }
                }
            });
            panelFuture.Children.Add(this.listOfGameHostsFuture);
            var panel = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(10, 10, 0, 10),
                Children    =
                {
                    new BybLabel()
                    {
                        Text = "To see public events, go to the",
                        HorizontalOptions       = LayoutOptions.Start,
                        HorizontalTextAlignment = TextAlignment.Start,
                        TextColor = Config.ColorGrayTextOnWhite,
                    },
                    new BybLabel()
                    {
                        Text           = "Community page",
                        FontAttributes = FontAttributes.Bold,
                        TextColor      = Config.ColorBlackTextOnWhite,
                    }
                }
            };

            panelFuture.Children.Add(panel);
            panel.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(async() => { await App.Navigator.GoToCommunity(); })
            });

            // past invites
            this.panelPast = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(0),
                Spacing     = 0,
            };
            stackLayout.Children.Add(panelPast);
            this.listOfGameHostsPast = new ListOfGameHostsControl();
            this.listOfGameHostsPast.TreatAsASingleItem    = true;
            this.listOfGameHostsPast.ShowCommentsCount     = true;
            this.listOfGameHostsPast.Padding               = new Thickness(10, 10, 10, 0);
            this.listOfGameHostsPast.IsForPast             = true;
            this.listOfGameHostsPast.UserChangedSomething += (s1, e1) => { this.ReloadAsync(false); };
            this.panelPast.Children.Add(this.listOfGameHostsPast);

            // scrolling and pulltorefresh
            var scrollView = new ScrollView
            {
                Padding           = new Thickness(0),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Content           = stackLayout,
            };

            this.pullToRefresh = new Refractored.XamForms.PullToRefresh.PullToRefreshLayout()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Content           = scrollView,
                RefreshColor      = Config.ColorRedBackground,
            };
            pullToRefresh.RefreshCommand = new Command(() => { this.ReloadAsync(false); });
            this.Children.Add(pullToRefresh, 0, 2);

            this.IsShowingPastEvents = false;
        }
Ejemplo n.º 30
0
        public NewsfeedItemPage(NewsfeedItemWebModel item, bool isModal)
        {
            this.isModal = isModal;
            this.item    = item;

            NewsfeedItemBaseControl newsfeedItemControl;

            if (item.ItemType == NewsfeedItemTypeEnum.Post)
            {
                newsfeedItemControl = new NewsfeedItemPostControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.Result)
            {
                newsfeedItemControl = new NewsfeedItemResultControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.Score)
            {
                newsfeedItemControl = new NewsfeedItemScoreControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.GameHost)
            {
                newsfeedItemControl = new NewsfeedItemGameHostControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.NewUser)
            {
                newsfeedItemControl = new NewsfeedItemNewUserControl(item, true);
            }
            else
            {
                throw new NotImplementedException();
            }
            newsfeedItemControl.ShowCommentsCount  = false;
            newsfeedItemControl.TreatAsASingleItem = false;
            newsfeedItemControl.NeedsARefresh     += (s1, e1) => { this.AnythingChanged = true; };
            //newsfeedItemControl.Padding = new Thickness(0);

            this.labelLoading = new BybLabel()
            {
                HeightRequest         = 40,
                VerticalTextAlignment = TextAlignment.Center,
                HorizontalOptions     = LayoutOptions.Center,
                TextColor             = Config.ColorBlackTextOnWhite,
                IsVisible             = true,
                Text = "Loading...",
            };

            this.listOfCommentsControl = new ListOfCommentsControl()
            {
                Padding = new Thickness(10, 10, 0, 0),
            };

            this.editor = new BybEditor()
            {
                HeightRequest = 40,
            };
            this.editor.Unfocused += editor_Unfocused;
            this.editor.Focused   += editor_Focused;
            this.editor.Completed += editor_Completed;

            this.buttonCancel = new BybButton {
                Text = "Close", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            buttonCancel.Clicked += buttonCancel_Clicked;

            Button buttonPostComment = new BybButton {
                Text = "Done", Style = (Style)App.Current.Resources["SimpleButtonStyle"], HorizontalOptions = LayoutOptions.End
            };

            buttonPostComment.Clicked += buttonPostComment_Clicked;
            this.panelWithButtons      = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                //BackgroundColor = Config.ColorBackground,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(10, 0, 10, 0),
                Spacing           = 0,
                IsVisible         = false,
                Children          =
                {
                    buttonPostComment,
                    //buttonCancel2,
                }
            };

            var stackLayout = new StackLayout
            {
                Spacing = 0,
                Padding = new Thickness(0, 0, 0, 0),

                Children =
                {
                    new StackLayout
                    {
                        Padding           = new Thickness(10, 10, 10, 0),
                        Orientation       = StackOrientation.Vertical,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Children          =
                        {
                            newsfeedItemControl,
                        }
                    },

                    this.labelLoading,
                    new ScrollView
                    {
                        Padding         = new Thickness(10, 0, 10, 10),
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        Content         = new StackLayout
                        {
                            Orientation = StackOrientation.Vertical,
                            Children    =
                            {
                                this.listOfCommentsControl,
                                new StackLayout
                                {
                                    Orientation     = StackOrientation.Horizontal,
                                    BackgroundColor = Config.ColorGrayBackground,
                                    Padding         = new Thickness(10, 10, 0, 0),
                                    Children        =
                                    {
                                        new BybLabel
                                        {
                                            Text            = "Enter your comments here:",
                                            VerticalOptions = LayoutOptions.Center,
                                            TextColor       = Config.ColorGrayTextOnWhite
                                        },
                                        panelWithButtons,
                                    },
                                },
//                                new Frame
//                                {
//                                    BackgroundColor = Config.ColorGrayBackground,
//                                    Padding = new Thickness(10,10,0,0),
//                                    Content = new BybLabel
//                                    {
//                                        Text = "Enter your comments here:"
//                                    }
//                                },
                                //panelWithButtons,
                                new Frame
                                {
                                    BackgroundColor = Config.ColorGrayBackground,
                                    Padding         = new Thickness(15,  5, 5, 5),
                                    Content         = editor,
                                },
                            }
                        }
                    },

                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        //BackgroundColor = Config.ColorBackground,
                        HorizontalOptions = LayoutOptions.Fill,
                        HeightRequest     = Config.OkCancelButtonsHeight,
                        Padding           = new Thickness(Config.OkCancelButtonsPadding),
                        Children          =
                        {
                            buttonCancel,
                        }
                    }
                }
            };

            if (this.isModal)
            {
                stackLayout.Children.Insert(0, new BybTitle("Comments"));
            }

            this.Content         = stackLayout;
            this.Padding         = new Thickness(0, 0, 0, 0);
            this.BackgroundColor = Config.ColorGrayBackground;
            this.Title           = "Comments";
        }