Ejemplo n.º 1
0
        public WelcomePage()
        {
            var player1Label = new DarkBlueLabel {
                Text = "Player 1"
            };
            var player2Label = new DarkBlueLabel {
                Text = "Player 2"
            };

            _player1Entry = new Entry
            {
                AutomationId  = AutomationIdConstants.Player1Entry,
                Placeholder   = PlaceholderConstants.WelcomePagePlaceholderText,
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => _player2Entry.Focus())
            };
            _player1Entry.SetBinding(Entry.TextProperty, nameof(ViewModel.Player1));

            _player2Entry = new Entry
            {
                AutomationId  = AutomationIdConstants.Player2Entry,
                Placeholder   = PlaceholderConstants.WelcomePagePlaceholderText,
                ReturnType    = ReturnType.Go,
                ReturnCommand = new Command(() => StartGame())
            };
            _player2Entry.SetBinding(Entry.TextProperty, nameof(ViewModel.Player2));

            _startGameButton = new BounceButton
            {
                AutomationId = AutomationIdConstants.StartGameButton,
                Margin       = new Thickness(0, 20, 0, 0),
                Text         = "Start"
            };

            NavigationPage.SetBackButtonTitle(this, "");

            Title           = "FaceOff";
            BackgroundColor = Color.FromHex("#91E2F4");

            Content = new StackLayout
            {
                Padding  = 20,
                Children =
                {
                    player1Label,
                    _player1Entry,
                    player2Label,
                    _player2Entry,
                    _startGameButton
                }
            };
        }
Ejemplo n.º 2
0
        public WelcomePage()
        {
            var welcomeViewModel = new WelcomeViewModel();

            BindingContext = welcomeViewModel;

            var player1Label = new DarkBlueLabel {
                Text = "Player 1"
            };
            var player2Label = new DarkBlueLabel {
                Text = "Player 2"
            };

            _player1Entry = new Entry();
            _player1Entry.SetBinding(Entry.TextProperty, nameof(welcomeViewModel.Player1));

            _player2Entry = new Entry();
            _player2Entry.SetBinding(Entry.TextProperty, nameof(welcomeViewModel.Player2));

            _startGameButton = new BounceButton
            {
                Margin = new Thickness(0, 20, 0, 0),
                Text   = "Start"
            };

            PopulateAutomationIDs();
            PopulatePlaceholderText();
            ConfigureCustomReturnEffect();

            NavigationPage.SetBackButtonTitle(this, "");

            Title           = "Face Off";
            BackgroundColor = Color.FromHex("#91E2F4");

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    Padding  = 20,
                    Children =
                    {
                        player1Label,
                        _player1Entry,
                        player2Label,
                        _player2Entry,
                        _startGameButton
                    }
                }
            };
        }
Ejemplo n.º 3
0
        public FaceOffPage()
        {
            this.SetBinding(TitleProperty, nameof(ViewModel.PageTitle));

            _photo1ScoreButton = new BounceButton(AutomationIdConstants.ScoreButton1);
            _photo1ScoreButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsScore1ButtonEnabled));
            _photo1ScoreButton.SetBinding(IsVisibleProperty, nameof(ViewModel.IsScore1ButtonVisable));
            _photo1ScoreButton.SetBinding(Button.TextProperty, nameof(ViewModel.ScoreButton1Text));
            _photo1ScoreButton.SetBinding(Button.CommandProperty, nameof(ViewModel.Photo1ScoreButtonPressed));

            var photo1ScoreButtonStack = new StackLayout
            {
                Padding  = new Thickness(24, 24, 24, 24),
                Children = { _photo1ScoreButton }
            };

            #region Create Score Button 2 Stack
            _photo2ScoreButton = new BounceButton(AutomationIdConstants.ScoreButton2);
            _photo2ScoreButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsScore2ButtonEnabled));
            _photo2ScoreButton.SetBinding(IsVisibleProperty, nameof(ViewModel.IsScore2ButtonVisable));
            _photo2ScoreButton.SetBinding(Button.TextProperty, nameof(ViewModel.ScoreButton2Text));
            _photo2ScoreButton.SetBinding(Button.CommandProperty, nameof(ViewModel.Photo2ScoreButtonPressed));

            var photo2ScoreButtonStack = new StackLayout
            {
                Padding  = new Thickness(24, 24, 24, 24),
                Children = { _photo2ScoreButton }
            };
            #endregion

            #region Create Photo Activity Indicators
            var photo1ActivityIndicator = new ActivityIndicator
            {
                AutomationId = AutomationIdConstants.Photo1ActivityIndicator
            };
            photo1ActivityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsCalculatingPhoto1Score));
            photo1ActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsCalculatingPhoto1Score));

            var photo2ActivityIndicator = new ActivityIndicator
            {
                AutomationId = AutomationIdConstants.Photo2ActivityIndicator
            };
            photo2ActivityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsCalculatingPhoto2Score));
            photo2ActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsCalculatingPhoto2Score));
            #endregion

            #region Create Photo 1 Button Stack
            var takePhoto1Button = new BounceButton(AutomationIdConstants.TakePhoto1Button)
            {
                Text = "Take Photo"
            };
            takePhoto1Button.SetBinding(IsEnabledProperty, nameof(ViewModel.IsTakeLeftPhotoButtonEnabled));
            takePhoto1Button.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhoto1ButtonPressed));

            var player1NameLabel = new DarkBlueLabel
            {
                Text = Settings.Player1Name,
                HorizontalOptions = LayoutOptions.Center
            };

            var takePhoto1ButtonStack = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(24, 24, 24, 24),
                Children          =
                {
                    player1NameLabel,
                    takePhoto1Button
                }
            };
            takePhoto1ButtonStack.SetBinding(IsVisibleProperty, nameof(ViewModel.IsTakeLeftPhotoButtonStackVisible));
            #endregion

            #region Create Photo 2 Button Stack
            var takePhoto2Button = new BounceButton(AutomationIdConstants.TakePhoto2Button)
            {
                Text = "Take Photo"
            };
            takePhoto2Button.SetBinding(IsEnabledProperty, nameof(ViewModel.IsTakeRightPhotoButtonEnabled));
            takePhoto2Button.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhoto2ButtonPressed));

            var player2NameLabel = new DarkBlueLabel
            {
                Text = Settings.Player2Name,
                HorizontalOptions = LayoutOptions.Center,
            };

            var takePhoto2ButtonStack = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(24, 24, 24, 24),
                Children          =
                {
                    player2NameLabel,
                    takePhoto2Button
                }
            };
            takePhoto2ButtonStack.SetBinding(IsVisibleProperty, nameof(ViewModel.IsTakeRightPhotoButtonStackVisible));
            #endregion

            #region Create Photo Image Containers
            _photoImage1 = new FrameImage(AutomationIdConstants.PhotoImage1);
            _photoImage1.SetBinding(IsVisibleProperty, nameof(ViewModel.IsPhotoImage1Enabled));
            _photoImage1.ContentImage.SetBinding(Image.SourceProperty, nameof(ViewModel.Photo1ImageSource));

            _photoImage2 = new FrameImage(AutomationIdConstants.PhotoImage2);
            _photoImage2.SetBinding(IsVisibleProperty, nameof(ViewModel.IsPhotoImage2Enabled));
            _photoImage2.ContentImage.SetBinding(Image.SourceProperty, nameof(ViewModel.Photo2ImageSource));
            #endregion

            #region Create Photo 1 Stack
            var photo1Stack = new StackLayout
            {
                Style    = StylesConstants.StackLayoutStyle,
                Children =
                {
                    _photoImage1,
                    photo1ScoreButtonStack,
                    photo1ActivityIndicator
                },
            };
            #endregion

            #region Create Photo 2 Stack
            var photo2Stack = new StackLayout
            {
                Style    = StylesConstants.StackLayoutStyle,
                Children =
                {
                    _photoImage2,
                    photo2ScoreButtonStack,
                    photo2ActivityIndicator
                }
            };
            #endregion

            #region Create Reset Button Stack
            var resetButton = new BounceButton(AutomationIdConstants.ResetButton)
            {
                Text = "Reset"
            };
            resetButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsResetButtonEnabled));
            resetButton.SetBinding(IsVisibleProperty, nameof(ViewModel.IsResetButtonEnabled));
            resetButton.SetBinding(Button.CommandProperty, nameof(ViewModel.ResetButtonPressed));

            var resetButtonStack = new StackLayout
            {
                Padding  = new Thickness(24, 24, 24, 24),
                Children =
                {
                    resetButton
                }
            };
            #endregion

            #region Create Relative Laout
            var buttonImageRelativeLayout = new RelativeLayout();

            buttonImageRelativeLayout.Children.Add(photo1Stack,
                                                   Constraint.RelativeToParent(parent => parent.X + _frameImagePadding),
                                                   Constraint.RelativeToParent(parent => parent.Y + _frameImagePadding),
                                                   Constraint.RelativeToParent(parent => parent.Width / 2 - 2 * _frameImagePadding),
                                                   Constraint.RelativeToParent(parent => parent.Height * 7 / 8)
                                                   );

            buttonImageRelativeLayout.Children.Add(photo2Stack,
                                                   Constraint.RelativeToParent(parent => parent.Width / 2 + _frameImagePadding),
                                                   Constraint.RelativeToParent(parent => parent.Y + _frameImagePadding),
                                                   Constraint.RelativeToParent(parent => parent.Width / 2 - 2 * _frameImagePadding),
                                                   Constraint.RelativeToParent(parent => parent.Height * 7 / 8)
                                                   );

            buttonImageRelativeLayout.Children.Add(takePhoto1ButtonStack,
                                                   Constraint.RelativeToParent(parent => parent.X),
                                                   Constraint.RelativeToParent(parent => parent.Y),
                                                   Constraint.RelativeToParent(parent => parent.Width / 2)
                                                   );

            buttonImageRelativeLayout.Children.Add(takePhoto2ButtonStack,
                                                   Constraint.RelativeToParent(parent => parent.Width / 2),
                                                   Constraint.RelativeToParent(parent => parent.Y),
                                                   Constraint.RelativeToParent(parent => parent.Width / 2)
                                                   );

            buttonImageRelativeLayout.Children.Add(resetButtonStack,
                                                   Constraint.RelativeToParent(parent => parent.X),
                                                   Constraint.RelativeToParent(parent => parent.Height * 7 / 8 - resetButtonStack.Height),
                                                   Constraint.RelativeToParent(parent => parent.Width),
                                                   Constraint.RelativeToParent(parent => parent.Height * 1 / 8)
                                                   );
            #endregion

            #region Set Page Content
            Content = buttonImageRelativeLayout;
            #endregion
        }