Beispiel #1
0
        protected override void Initialize()
        {
            base.Initialize();

            var messageLabel = new PaddedLabel(SnackBar.Layout.PaddingLeft,
                                               SnackBar.Layout.PaddingTop,
                                               SnackBar.Layout.PaddingRight,
                                               SnackBar.Layout.PaddingBottom)
            {
                Text  = SnackBar.Message,
                Lines = 0,
                AdjustsFontSizeToFitWidth = true,
                TextAlignment             = SnackBar.Appearance.TextAlignment
            };

            if (SnackBar.Appearance.Background != NativeSnackBarAppearance.DefaultColor)
            {
                messageLabel.BackgroundColor = SnackBar.Appearance.Background;
            }

            if (SnackBar.Appearance.Foreground != NativeSnackBarAppearance.DefaultColor)
            {
                messageLabel.TextColor = SnackBar.Appearance.Foreground;
            }

            if (SnackBar.Appearance.Font != NativeSnackBarAppearance.DefaultFont)
            {
                messageLabel.Font = SnackBar.Appearance.Font;
            }

            _ = StackView ?? throw new NullReferenceException();
            StackView.AddArrangedSubview(messageLabel);
        }
        protected override void Initialize(CGRect cornerRadius)
        {
            base.Initialize(cornerRadius);
            var messageLabel = new PaddedLabel(SnackBar.Layout.PaddingLeft,
                                               SnackBar.Layout.PaddingTop,
                                               SnackBar.Layout.PaddingRight,
                                               SnackBar.Layout.PaddingBottom)
            {
                StringValue = SnackBar.Message,
                Selectable  = false,
                Alignment   = SnackBar.Appearance.TextAlignment,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            if (SnackBar.Appearance.Background != NativeSnackBarAppearance.DefaultColor)
            {
                messageLabel.BackgroundColor = SnackBar.Appearance.Background;
            }

            if (SnackBar.Appearance.Foreground != NativeSnackBarAppearance.DefaultColor)
            {
                messageLabel.TextColor = SnackBar.Appearance.Foreground;
            }

            if (SnackBar.Appearance.Font != NativeSnackBarAppearance.DefaultFont)
            {
                messageLabel.Font = SnackBar.Appearance.Font;
            }

            StackView?.AddArrangedSubview(messageLabel);
        }
Beispiel #3
0
        private void SetEmptyText(ListView element)
        {
            if (Superview != null && Superview.Frame.Width > 0)
            {
                if (emptyLabel == null)
                {
                    emptyLabel               = new PaddedLabel();
                    emptyLabel.Center        = Center;
                    emptyLabel.Bounds        = Bounds;
                    emptyLabel.TextAlignment = UITextAlignment.Center;
                    emptyLabel.LineBreakMode = UILineBreakMode.WordWrap;
                    emptyLabel.Lines         = 10;
                    SetEmptyTextFont(element);
                    SetEmptyTextColor(element);
                    UpdateEmptyLabelVisibility();

                    Control.BackgroundView = emptyLabel;
                }

                emptyLabel.Text = element.EmptyText;
            }
        }