예제 #1
0
 public SweetAlertService(IJSRuntime jSRuntime, SweetAlertServiceOptions options)
 {
     this.jSRuntime = jSRuntime;
     if (options == null)
     {
         return;
     }
     theme = options.Theme;
     colorSchemeThemes = options.ColorSchemeThemes
         .Select(kvp => new int[2] { (int)kvp.Key, (int)kvp.Value })
         .ToArray();
 }
예제 #2
0
        public SweetAlertService(IJSRuntime jSRuntime, SweetAlertServiceOptions options)
        {
            _jSRuntime = jSRuntime;
            if (options == null)
            {
                return;
            }
            _theme             = options.Theme;
            _colorSchemeThemes = options.ColorSchemeThemes
                                 .Select(kvp => new[] { (int)kvp.Key, (int)kvp.Value })
                                 .ToArray();

            if (options.DefaultOptions != null)
            {
                _defaultOptions = options.DefaultOptions;
            }

            _ = SendThemesToJs();
        }
예제 #3
0
 private async void SetTheme(SweetAlertTheme theme)
 {
     await jSRuntime.InvokeAsync <object>("CurrieTechnologies.Blazor.SweetAlert2.SetTheme", (int)theme);
 }
 /// <summary>
 ///     Sets the SweetAlertTheme to be used with a given color scheme preference.
 ///     This utilizes the <code>prefers-color-scheme</code> CSS media feature, and behaves similarly.
 ///     Browsers that do not support the feature will fall back to the theme set in
 ///     <code>SweetAlertServiceOptions.Theme</code>.
 /// </summary>
 /// <param name="scheme">The user color scheme preference to apply this theme to</param>
 /// <param name="theme">The theme to use when the user has the provided color scheme preference</param>
 public void SetThemeForColorSchemePreference(ColorScheme scheme, SweetAlertTheme theme)
 {
     ColorSchemeThemes.Add(scheme, theme);
 }