Exemplo n.º 1
0
        protected override View CreateContent()
        {
            var grid = CreateGrid(style.Padding, 3 + _additionalButtons.Count());


            _titleLabel = CreateLabel(style.TitleLabelStyle, _title);

            _messageLabel = CreateLabel(style.BodyLabelStyle, _message);


            grid.Children.Add(_titleLabel, 0, 0);
            grid.Children.Add(_messageLabel, 0, 1);

            _okButton = CreateSheetButton(style.PrimaryButtonStyle, _primaryButtonText);


            _okButton.Clicked += (sender, e) =>
            {
                Hide();
                ButtonTapped(this, new AlertSheetEventArgs(0));
            };


            grid.Children.Add(_okButton, 0, 2);

            for (int i = 0; i < _additionalButtons.Length; i++)
            {
                CreateSecondaryButton(grid, i);
            }


            return(grid);
        }
Exemplo n.º 2
0
        protected SheetButton CreateSheetButton(SheetButtonStyle style, string text)
        {
            var button = new SheetButton()
            {
                Text = text
            };

            style.ApplyTo(button);
            return(button);
        }
Exemplo n.º 3
0
 internal void ApplyTo(SheetButton button)
 {
     button.BackgroundColor = BackgroundColor;
     button.BorderColor     = BorderColor;
     button.BorderWidth     = BorderWidth;
     button.BorderRadius    = BorderRadius;
     button.FontAttributes  = FontAttributes;
     button.FontSize        = FontSize;
     button.FontFamily      = FontFamily;
     button.TextAlignment   = TextAlignment;
     button.TextColor       = TextColor;
     button.Margin          = Margin;
 }
Exemplo n.º 4
0
        protected override View CreateContent()
        {
            var grid = new Grid()
            {
                BackgroundColor = Color.Transparent,
                Padding         = new Thickness(5, 20, 5, 5),
                RowDefinitions  = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                }
            };

            for (int i = 0; i < _buttons.Length; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
            }

            _titleLabel = CreateLabel(style.TitleLabelStyle, _title);

            _messageLabel = CreateLabel(style.BodyLabelStyle, _message);

            _input = CreateEntry(style.EntryStyle, _inputOptions);

            _input.Completed += (sender, e) =>
            {
                Finish();
            };

            for (int i = 0; i < _buttons.Length; i++)
            {
                SheetButton button = null;

                if (i == 0)
                {
                    button = CreateSheetButton(style.PrimaryButtonStyle, _buttons[0]);
                }
                else
                {
                    button = CreateSheetButton(style.SecondaryButtonStyle, _buttons[i]);
                }

                button.Clicked += (sender, e) =>
                {
                    Hide();
                    var senderText = (sender as Button).Text;
                    _result.TrySetResult(new InputResult()
                    {
                        ButtonIndex = _buttons.ToList().IndexOf(senderText), InputText = _input.Text
                    });
                };
                grid.Children.Add(button, 0, 3 + i);
            }

            grid.Children.Add(_titleLabel, 0, 0);
            grid.Children.Add(_messageLabel, 0, 1);
            grid.Children.Add(_input, 0, 2);

            return(grid);
        }