Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

env:
xcodeVersion: 26.0.1
dotnetVersion: 10.0.100-rc.1.25451.107
dotnetVersion: 10.0.100-rc.2.25502.107

jobs:
build:
Expand Down
25 changes: 19 additions & 6 deletions BTProgressHUD/ProgressHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,27 +256,40 @@ UIView HudView
return _hudView;

UIView hudView;
if (ProgressHUDAppearance.HudBackgroundColor.Equals(UIColor.Clear))
if (ProgressHUDAppearance.HudBackgroundVisualEffect != null)
{
hudView = new UIView
{
BackgroundColor = ProgressHUDAppearance.HudBackgroundColor
BackgroundColor = UIColor.Clear,
};

hudView.AddSubview(new UIVisualEffectView(ProgressHUDAppearance.HudBackgroundVisualEffect)
{
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
});
}
else
{
hudView = new UIToolbar
hudView = new UIView
{
Translucent = true,
BarTintColor = ProgressHUDAppearance.HudBackgroundColor,
BackgroundColor = ProgressHUDAppearance.HudBackgroundColor
BackgroundColor = ProgressHUDAppearance.HudBackgroundColor,
};
}

hudView.AutoresizingMask =
UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleTopMargin |
UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleLeftMargin;

if (ProgressHUDAppearance.HudBorderThickness > 0)
{
hudView.Layer.BorderWidth = ProgressHUDAppearance.HudBorderThickness;
}

if (ProgressHUDAppearance.HudBorderColor != null)
{
hudView.Layer.BorderColor = ProgressHUDAppearance.HudBorderColor.CGColor;
}

hudView.Layer.CornerRadius = ProgressHUDAppearance.HudCornerRadius;
hudView.Layer.MasksToBounds = true;

Expand Down
41 changes: 38 additions & 3 deletions BTProgressHUD/ProgressHUDAppearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public static class ProgressHUDAppearance
OperatingSystem.IsIOSVersionAtLeast(13, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(13) ?
UIColor.Label.ColorWithAlpha(0.8f) :
UIColor.FromWhiteAlpha(0.0f, 0.8f);

public static UIVisualEffect DefaultBackgroundVisualEffect { get; } =
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
UIGlassEffect.Create(UIGlassEffectStyle.Regular) :
UIBlurEffect.FromStyle(UIBlurEffectStyle.Regular);

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

public const float DefaultRingRadius = 14f;
public const float DefaultRingThickness = 1f;
public const float DefaultHudCornerRadius = 10f;
public static float DefaultHudCornerRadius { get; } =
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
20f : 10f;

public static float DefaultHudBorderThickness { get; } =
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
1f : 0f;

public static UIColor DefaultHudBorderColor { get; } =
OperatingSystem.IsIOSVersionAtLeast(26, 0) || OperatingSystem.IsMacCatalystVersionAtLeast(26) ?
UIColor.FromWhiteAlpha(1.0f, 0.3f) :
UIColor.Clear;

public const double DefaultProgressUpdateInterval = 300;
public const float DefaultActivityIndicatorScale = 1f;

Expand Down Expand Up @@ -66,11 +83,26 @@ public static class ProgressHUDAppearance
/// Get or set hud corner radius
/// </summary>
public static float HudCornerRadius { get; set; } = DefaultHudCornerRadius;

/// <summary>
/// Get or set hud background color
/// Get or set hud background color. This only works if HudBackgroundVisualEffect is null
/// </summary>
public static UIColor HudBackgroundColor { get; set; } = DefaultHudBackgroundColor;

/// <summary>
/// Get or set hud border thickness
/// </summary>
public static float HudBorderThickness { get; set; } = DefaultHudBorderThickness;

/// <summary>
/// Get or set hud border color
/// </summary>
public static UIColor HudBorderColor { get; set; } = DefaultHudBorderColor;

/// <summary>
/// Get or set hud background visual effect
/// </summary>
public static UIVisualEffect? HudBackgroundVisualEffect { get; set; } = DefaultBackgroundVisualEffect;

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

HudCornerRadius = DefaultHudCornerRadius;
HudBackgroundColor = DefaultHudBackgroundColor;
HudBorderThickness = DefaultHudBorderThickness;
HudBackgroundVisualEffect = DefaultBackgroundVisualEffect;
HudBorderThickness = DefaultHudBorderThickness;
HudImageTintColor = DefaultForegroundColor;
HudToastBackgroundColor = DefaultHudToastBackgroundColor;
HudFont = DefaultHudFont;
Expand Down
3 changes: 2 additions & 1 deletion BTProgressHUDDemo/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<DataTemplate>
<VerticalStackLayout Margin="16, 2">
<Button Text="{Binding Text}"
Command="{Binding Command}"/>
Command="{Binding Command}"
BackgroundColor="{Binding Color}"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
Expand Down
18 changes: 16 additions & 2 deletions BTProgressHUDDemo/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ public class MainViewModel
float progress = -1;
NSTimer timer;

Color[] colors =
[
Color.FromRgb(255, 59, 48),
Color.FromRgb(255, 149, 0),
Color.FromRgb(255, 204, 0),
Color.FromRgb(76, 217, 100),
Color.FromRgb(90, 200, 250),
Color.FromRgb(0, 122, 255),
Color.FromRgb(88, 86, 214),
Color.FromRgb(255, 45, 85)
];

public MainViewModel()
{
Items =
Expand Down Expand Up @@ -104,10 +116,10 @@ public MainViewModel()
ProgressHUDAppearance.RingColor = UIColor.Green;
ProgressHUDAppearance.RingBackgroundColor = UIColor.Brown;

ProgressHUDAppearance.HudBackgroundColor = UIColor.Yellow;
ProgressHUDAppearance.HudBackgroundColor = UIColor.Brown;
ProgressHUDAppearance.HudTextColor = UIColor.Purple;
ProgressHUDAppearance.HudButtonTextColor = UIColor.Orange;
ProgressHUDAppearance.HudCornerRadius = 2;
ProgressHUDAppearance.HudCornerRadius = 16;
ProgressHUDAppearance.HudTextAlignment = UITextAlignment.Left;
ProgressHUDAppearance.HudTextColor = UIColor.Cyan;
ProgressHUDAppearance.HudToastBackgroundColor = UIColor.Blue;
Expand Down Expand Up @@ -188,6 +200,7 @@ public MainViewModel()

CommandItem Create(string text, Action action, bool timedKill) => new CommandItem(
text,
colors[Random.Shared.Next(colors.Length)],
new Command(() =>
{
try
Expand Down Expand Up @@ -224,6 +237,7 @@ void KillAfter()

public record CommandItem(
string Text,
Color Color,
ICommand Command
);
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ control the following options:

- Corner Radius
- Background Color
- Background Visual Effect (overrides background color)
- Border Thickness
- Border Color
- Image Tint Color
- Text Font
- Button Font
Expand Down