Skip to content

Commit a8f4cb0

Browse files
committed
Default to Liquid Glass on iOS/MacCatalyst 26.0
1 parent a0540f9 commit a8f4cb0

File tree

2 files changed

+57
-9
lines changed

2 files changed

+57
-9
lines changed

BTProgressHUD/ProgressHUD.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,40 @@ UIView HudView
256256
return _hudView;
257257

258258
UIView hudView;
259-
if (ProgressHUDAppearance.HudBackgroundColor.Equals(UIColor.Clear))
259+
if (ProgressHUDAppearance.HudBackgroundVisualEffect != null)
260260
{
261261
hudView = new UIView
262262
{
263-
BackgroundColor = ProgressHUDAppearance.HudBackgroundColor
263+
BackgroundColor = UIColor.Clear,
264264
};
265+
266+
hudView.AddSubview(new UIVisualEffectView(ProgressHUDAppearance.HudBackgroundVisualEffect)
267+
{
268+
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
269+
});
265270
}
266271
else
267272
{
268-
hudView = new UIToolbar
273+
hudView = new UIView
269274
{
270-
Translucent = true,
271-
BarTintColor = ProgressHUDAppearance.HudBackgroundColor,
272-
BackgroundColor = ProgressHUDAppearance.HudBackgroundColor
275+
BackgroundColor = ProgressHUDAppearance.HudBackgroundColor,
273276
};
274277
}
275278

276279
hudView.AutoresizingMask =
277280
UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleTopMargin |
278281
UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleLeftMargin;
279282

283+
if (ProgressHUDAppearance.HudBorderThickness > 0)
284+
{
285+
hudView.Layer.BorderWidth = ProgressHUDAppearance.HudBorderThickness;
286+
}
287+
288+
if (ProgressHUDAppearance.HudBorderColor != null)
289+
{
290+
hudView.Layer.BorderColor = ProgressHUDAppearance.HudBorderColor.CGColor;
291+
}
292+
280293
hudView.Layer.CornerRadius = ProgressHUDAppearance.HudCornerRadius;
281294
hudView.Layer.MasksToBounds = true;
282295

BTProgressHUD/ProgressHUDAppearance.cs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public static class ProgressHUDAppearance
1414
OperatingSystem.IsIOSVersionAtLeast(13, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(13) ?
1515
UIColor.Label.ColorWithAlpha(0.8f) :
1616
UIColor.FromWhiteAlpha(0.0f, 0.8f);
17+
18+
public static UIVisualEffect DefaultBackgroundVisualEffect { get; } =
19+
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
20+
UIGlassEffect.Create(UIGlassEffectStyle.Regular) :
21+
UIBlurEffect.FromStyle(UIBlurEffectStyle.Regular);
1722

1823
public static UIColor DefaultHudToastBackgroundColor { get; } = UIColor.Clear;
1924
public static UIFont DefaultHudFont { get; } = UIFont.BoldSystemFontOfSize(16f);
@@ -28,7 +33,19 @@ public static class ProgressHUDAppearance
2833

2934
public const float DefaultRingRadius = 14f;
3035
public const float DefaultRingThickness = 1f;
31-
public const float DefaultHudCornerRadius = 10f;
36+
public static float DefaultHudCornerRadius { get; } =
37+
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
38+
20f : 10f;
39+
40+
public static float DefaultHudBorderThickness { get; } =
41+
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
42+
1f : 0f;
43+
44+
public static UIColor DefaultHudBorderColor { get; } =
45+
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
46+
UIColor.FromWhiteAlpha(1.0f, 0.3f) :
47+
UIColor.Clear;
48+
3249
public const double DefaultProgressUpdateInterval = 300;
3350
public const float DefaultActivityIndicatorScale = 1f;
3451

@@ -66,11 +83,26 @@ public static class ProgressHUDAppearance
6683
/// Get or set hud corner radius
6784
/// </summary>
6885
public static float HudCornerRadius { get; set; } = DefaultHudCornerRadius;
69-
86+
7087
/// <summary>
71-
/// Get or set hud background color
88+
/// Get or set hud background color. This only works if HudBackgroundVisualEffect is null
7289
/// </summary>
7390
public static UIColor HudBackgroundColor { get; set; } = DefaultHudBackgroundColor;
91+
92+
/// <summary>
93+
/// Get or set hud border thickness
94+
/// </summary>
95+
public static float HudBorderThickness { get; set; } = DefaultHudBorderThickness;
96+
97+
/// <summary>
98+
/// Get or set hud border color
99+
/// </summary>
100+
public static UIColor HudBorderColor { get; set; } = DefaultHudBorderColor;
101+
102+
/// <summary>
103+
/// Get or set hud background visual effect
104+
/// </summary>
105+
public static UIVisualEffect? HudBackgroundVisualEffect { get; set; } = DefaultBackgroundVisualEffect;
74106

75107
/// <summary>
76108
/// Get or set image tint color
@@ -127,6 +159,9 @@ public static void ResetToDefaults()
127159

128160
HudCornerRadius = DefaultHudCornerRadius;
129161
HudBackgroundColor = DefaultHudBackgroundColor;
162+
HudBorderThickness = DefaultHudBorderThickness;
163+
HudBackgroundVisualEffect = DefaultBackgroundVisualEffect;
164+
HudBorderThickness = DefaultHudBorderThickness;
130165
HudImageTintColor = DefaultForegroundColor;
131166
HudToastBackgroundColor = DefaultHudToastBackgroundColor;
132167
HudFont = DefaultHudFont;

0 commit comments

Comments
 (0)