/// <summary>
        /// Registers the default styling service with a new CSS style engine
        /// to retrieve, if no other styling service has been registered yet.
        /// </summary>
        /// <param name="configuration">The configuration to extend.</param>
        /// <param name="setup">Optional setup for the style engine.</param>
        /// <returns>The new instance with the service.</returns>
        public static IConfiguration WithCss(this IConfiguration configuration, Action <CssStyleEngine> setup = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (!configuration.GetServices <IStylingProvider>().Any())
            {
                var service = new StylingService();
                var engine  = new CssStyleEngine();
                setup?.Invoke(engine);
                service.Register(engine);
                return(configuration.With(service));
            }

            return(configuration);
        }
        /// <summary>
        /// Registers the default styling service with a new CSS style engine
        /// to retrieve, if no other styling service has been registered yet.
        /// </summary>
        /// <param name="configuration">The configuration to extend.</param>
        /// <param name="setup">Optional setup for the style engine.</param>
        /// <returns>The new instance with the service.</returns>
        public static IConfiguration WithCss(this IConfiguration configuration, Action <CssStyleEngine> setup = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (configuration.GetServices <IStylingService>().Any() == false)
            {
                var service = new StylingService();
                var engine  = new CssStyleEngine();

                if (setup != null)
                {
                    setup(engine);
                }

                service.Register(engine);
                return(configuration.With(service));
            }

            return(configuration);
        }
Exemple #3
0
        private SfPopupLayout CreateGamePopup() => new SfPopupLayout
        {
            PopupView =
            {
                Margin           =                                           5,
                AppearanceMode   = AppearanceMode.OneButton,
                AcceptButtonText = string.Empty,
                ShowFooter       = false,
                ShowHeader       = false,
                ShowCloseButton  = false,
                VerticalOptions  = LayoutOptions.StartAndExpand,
                PopupStyle       = new PopupStyle {
                    CornerRadius                     =                      20
                },
                AnimationMode   = AnimationMode.Fade,
                HeightRequest   =                                         200,
                WidthRequest    =                                         200,
                BackgroundColor = Color.White,
                ContentTemplate = new DataTemplate(() =>
                {
                    var stack                        = new StackLayout
                    {
                        Orientation                  = StackOrientation.Vertical
                    };

                    var newGameButton                = new Button
                    {
                        Text  = "New game",
                        Style = StylingService.GetStyle("PopupButtonStyle"),
                    };
                    newGameButton.Clicked            += NewGameButton_Clicked;

                    var joinLabel                    = new Label
                    {
                        Text                    = "Join game",
                        Style                   = StylingService.GetStyle("SmallLabelStyle"),
                        HorizontalOptions       = LayoutOptions.CenterAndExpand,
                        HorizontalTextAlignment = TextAlignment.Center,
                        Margin                  = new Thickness(0, 5, 0, 5)
                    };

                    var joinQrGameButton             = new Button
                    {
                        Text  = "with QR Code",
                        Style = StylingService.GetStyle("PopupButtonStyle"),
                    };
                    joinQrGameButton.Clicked         += JoinQrGameButton_Clicked;

                    var joinInvitationGameButton     = new Button
                    {
                        Text  = "with Invitiation number",
                        Style = StylingService.GetStyle("PopupButtonStyle"),
                    };
                    joinInvitationGameButton.Clicked += JoinInvitationGameButton_Clicked;

                    stack.Children.Add(newGameButton);
                    stack.Children.Add(joinLabel);
                    stack.Children.Add(joinQrGameButton);
                    stack.Children.Add(joinInvitationGameButton);
                    return(stack);
                })
            }
        };