示例#1
0
        void createPeopleTabIfNotCreatedYet()
        {
            if (this.findPeopleControl != null)
            {
                return;
            }

            this.findPeopleControl = new FindPeopleControl(false)
            {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };
            this.findPeopleControl.LoadStarted += () =>
            {
                if (this.rootForPeople != null)
                {
                    this.rootForPeople.IsRefreshing = true;
                }
            };
            this.findPeopleControl.LoadCompleted += () =>
            {
                if (this.rootForNewsfeed != null)
                {
                    this.rootForNewsfeed.IsRefreshing = false;
                }
                if (this.rootForPeople != null)
                {
                    this.rootForPeople.IsRefreshing = false;
                }
            };
            this.findPeopleControl.NameAsCommunity      = true;
            this.findPeopleControl.UserClickedOnPerson += async(s1, e1) =>
            {
                await App.Navigator.GoToPersonProfile(e1.Person.ID);
            };
            this.rootForPeople = new PullToRefreshLayout()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Content           = this.findPeopleControl,
                RefreshColor      = Config.ColorRedBackground,
            };
            this.rootForPeople.RefreshCommand = new Command(() =>
            {
                this.findPeopleControl.ReloadAsync(this.CurrentCommunity, false);
            });
            this.Children.Add(this.rootForPeople, 0, 1);
        }
示例#2
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);
        }
示例#3
0
        public FVOMainPage()
        {
            this.labelTitle = new BybLabel()
            {
                Text      = "Pick Opponents",
                TextColor = Config.ColorTextOnBackgroundGrayed,
                FontSize  = Config.VeryLargeFontSize,
            };

            this.labelSyncStatus = new BybLabel()
            {
                Text              = "",
                TextColor         = Config.ColorTextOnBackground,
                FontSize          = Config.LargerFontSize,
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
            };

            /// selected players
            ///

            // player A
            imageA = new BybPersonImage()
            {
                WidthRequest      = imageSize,
                HeightRequest     = imageSize,
                HorizontalOptions = LayoutOptions.End,   //.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start, //.FillAndExpand,
                BackgroundColor   = Config.ColorBlackBackground,
            };
            imageA.SetImagePickOpponent();
            labelA = new BybLabel()
            {
                Text                    = "",
                TextColor               = Config.ColorTextOnBackground,
                HeightRequest           = 50,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            var panelA = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.End,
                Padding           = new Thickness(0),
                Spacing           = 0,
                Children          =
                {
                    imageA,
                    labelA,
                }
            };

            panelA.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.panelA_Clicked(); })
            });

            // player B
            imageB = new BybPersonImage()
            {
                WidthRequest      = imageSize,
                HeightRequest     = imageSize,
                HorizontalOptions = LayoutOptions.Start, //.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start, //.FillAndExpand,
                BackgroundColor   = Config.ColorBlackBackground,
            };
            imageB.SetImagePickOpponent();
            labelB = new BybLabel()
            {
                Text                    = "Select Player 2",
                TextColor               = Config.ColorTextOnBackground,
                HeightRequest           = 50,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            var panelB = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(0),
                Spacing           = 0,
                Children          =
                {
                    imageB,
                    labelB,
                }
            };

            panelB.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.panelB_Clicked(); })
            });

            Grid gridSelectedPlayers = new Grid()
            {
                //BackgroundColor = Color.Red,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Padding           = new Thickness(0),
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                RowDefinitions    = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(0.01, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1.00, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(0.01, GridUnitType.Star)
                    },
                }
            };

            gridSelectedPlayers.Children.Add(panelA, 1, 0);
            gridSelectedPlayers.Children.Add(new Frame()
            {
                Padding         = new Thickness(0, 0, 0, 50),
                HasShadow       = false,
                BackgroundColor = Color.Transparent,
                Content         = new BybLabel()
                {
                    Text                    = "vs.",
                    FontSize                = Config.VeryLargeFontSize + 20,
                    TextColor               = Config.ColorTextOnBackgroundGrayed,
                    VerticalOptions         = LayoutOptions.Center,
                    HorizontalOptions       = LayoutOptions.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                }
            }, 2, 0);
            gridSelectedPlayers.Children.Add(panelB, 3, 0);

            /// start/reset buttons
            ///
            this.buttonStartMatch = new BybButton()
            {
                Text  = "Start Match",
                Style = (Style)App.Current.Resources["LargeButtonStyle"]
            };
            buttonStartMatch.Clicked += buttonStartMatch_Clicked;
            this.buttonReset          = new BybButton()
            {
                Text  = "Reset",
                Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            buttonReset.Clicked += buttonReset_Clicked;

            /// bottom panel
            ///
            this.buttonSettings = new BybButton()
            {
                Text            = "Settings",
                Style           = (Style)App.Current.Resources["SimpleButtonStyle"],
                TextColor       = Config.ColorTextOnBackground,
                VerticalOptions = LayoutOptions.Center,
            };
            buttonSettings.Clicked += buttonSettings_Clicked;
            this.buttonHistory      = new BybButton()
            {
                Text            = "History",
                Style           = (Style)App.Current.Resources["SimpleButtonStyle"],
                TextColor       = Config.ColorTextOnBackground,
                VerticalOptions = LayoutOptions.Center,
            };
            this.buttonHistory.Clicked += buttonHistory_Clicked;
            //this.buttonHistory = new BybLabel()
            //{
            //    Text = "History",
            //    TextColor = Config.ColorTextOnBackground,
            //    VerticalOptions = LayoutOptions.Center,
            //    WidthRequest = 100,
            //    HeightRequest = 40,
            //    HorizontalTextAlignment = TextAlignment.End,
            //    VerticalTextAlignment = TextAlignment.Center,
            //};
            Label labelInfo = new BybLabel()
            {
                Text = "Tip: Install 'Snooker Byb' app on your personal mobile device.",
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.Center,
                TextColor = Config.ColorGrayTextOnWhite,
            };
            StackLayout panelBottom = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = Config.TitleHeight,
                Padding           = new Thickness(20, 0, 20, 0),
                BackgroundColor   = Config.ColorBackground,
                Children          =
                {
                    buttonSettings,
                    labelInfo,
                    buttonHistory,
                }
            };

            /// picking athletes panel
            ///

            // tab buttons
            this.buttonExisting = new BybButtonWithNumber("Existing")
            {
                IsNumberVisible = false, HeightRequest = Config.OkCancelButtonsHeight
            };
            this.buttonExisting.Clicked += (s1, e1) =>
            {
                this.registerControl.Clear();
                this.PickingAthleteStatus = PickingAthleteStatusEnum.Existing;
            };
            this.buttonRegister = new BybButtonWithNumber("Register")
            {
                IsNumberVisible = false, HeightRequest = Config.OkCancelButtonsHeight
            };
            this.buttonRegister.Clicked += (s1, e1) =>
            {
                if (this.alertAboutSettingsIfNecessary())
                {
                    return;
                }
                this.PickingAthleteStatus = PickingAthleteStatusEnum.Register;
            };

            Grid panelPickingAthletes = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Config.ColorBackground,
            };

            this.findPeopleControl = new FindPeopleControl(false);
            this.findPeopleControl.UserClickedOnPerson += findPeopleControl_UserClickedOnPerson;
            this.findPeopleControl.BackgroundColor      = Config.ColorBackground;
            this.findPeopleControl.Padding              = new Thickness(0, 60, 10, 0);

            this.registerControl = new FVORegisterControl();
            this.registerControl.UserClickedCancel += registerControl_UserClickedCancel;
            this.registerControl.UserRegistered    += registerControl_UserRegistered;
            this.registerControl.Padding            = new Thickness(20, 80, 20, 20);

            panelPickingAthletes.Children.Add(this.findPeopleControl);
            panelPickingAthletes.Children.Add(this.registerControl);

            panelPickingAthletes.Children.Add(new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = Config.ColorBackground,
                Padding           = new Thickness(0, 0, 0, 0),
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                Children          =
                {
                    this.buttonExisting,
                    this.buttonRegister,
                }
            });

            /// layout
            ///
            Grid panelRoot = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0),
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                RowDefinitions    = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(Config.TitleHeight, GridUnitType.Absolute)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(Config.TitleHeight - 20, GridUnitType.Absolute)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(3, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(2, GridUnitType.Star)
                    },
                }
            };

            panelRoot.Children.Add(
                new BybLabel()
            {
                Text              = "Snooker Byb",
                FontSize          = Config.VeryLargeFontSize,
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            }, 0, 2, 0, 1);
            panelRoot.Children.Add(
                new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.End,
                Padding           = new Thickness(0, 0, 20, 0),
                Children          =
                {
                    this.labelSyncStatus
                }
            }, 0, 2, 0, 1);
            panelRoot.Children.Add(
                new BoxView()
            {
                BackgroundColor   = Config.ColorBackground,
                HeightRequest     = 2,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.End,
            }, 0, 2, 0, 1);
            panelRoot.Children.Add(new Frame()
            {
                HasShadow         = false,
                BackgroundColor   = Color.Transparent,
                Padding           = new Thickness(40, 40, 0, 0),
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start,
                Content           = labelTitle
            }, 0, 1);
            panelRoot.Children.Add(panelBottom, 0, 2, 2, 3);
            panelRoot.Children.Add(
                new BoxView()
            {
                BackgroundColor   = Config.ColorBlackBackground,
                HeightRequest     = 2,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
            }, 0, 2, 2, 3);
            panelRoot.Children.Add(new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(20, 0, 20, 20),
                Spacing           = 0,
                Children          =
                {
                    buttonReset,
                    buttonStartMatch,
                }
            }, 0, 1);
            panelRoot.Children.Add(gridSelectedPlayers, 0, 1);
            panelRoot.Children.Add(panelPickingAthletes, 1, 1);

            this.BackgroundColor = Config.ColorBlackBackground;
            this.Content         = panelRoot;
            NavigationPage.SetHasNavigationBar(this, false);

            this.fill();
            this.fillPickingAthletesPanel();

            this.PickingAthleteStatus = PickingAthleteStatusEnum.Existing;

            App.Sync.StatusChanged += sync_StatusChanged;
        }