Example #1
0
        private View MessageView()
        {
            var loadingIndicator = new ActivityIndicator()
            {
                Color         = Colors.Text,
                IsRunning     = true,
                HeightRequest = Sizes.TextSmall,
                WidthRequest  = Sizes.TextSmall,
            };

            loadingIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                        converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Loading));

            var infoIndicator = new SvgCachedImage()
            {
                IsVisible     = false,
                Source        = Images.HistoryInfo,
                HeightRequest = Sizes.TextSmall,
                WidthRequest  = Sizes.TextSmall,
            };

            infoIndicator.ReplaceColor(Colors.Text);
            infoIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                     converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Info));

            var errorIndicator = new SvgCachedImage()
            {
                IsVisible     = false,
                Source        = Images.PopupCloseSmall,
                HeightRequest = Sizes.TextSmall,
                WidthRequest  = Sizes.TextSmall,
            };

            errorIndicator.ReplaceColor(Colors.Text);
            errorIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                      converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Error));

            var warningIndicator = new Label()
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                IsVisible         = false,
                Text     = "\u26A0",
                FontSize = Sizes.TextMicro + 1,
            };

            warningIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                        converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Warning));

            var lbl = new Label()
            {
                VerticalOptions         = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor = Colors.Text,
                FontSize  = Sizes.TextMicro + 1,
            };

            lbl.SetBinding(Label.TextProperty, nameof(NotifyCenter.MessageDetails.Text));

            var layout = new ContentView()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Content           = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Fill,
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(0, 12),
                    Spacing           = 10,
                    Children          =
                    {
                        loadingIndicator,
                        infoIndicator,
                        errorIndicator,
                        warningIndicator,
                        lbl,
                    }
                }
            };

            layout.AddTouchCommand(new Binding(nameof(NotifyCenter.MessageDetails.ClickedCommand)));
            layout.SetBinding(BackgroundColorProperty, nameof(NotifyCenter.MessageDetails.Type),
                              converter: new InfoLevelToColorConverter());

            return(layout);
        }