@@ -34,15 +34,15 @@ public sealed class ProgressHUD : UIView
3434
3535 private static readonly NSObject obj = new ( ) ;
3636
37- private UIImage ? _errorImage ;
38- private UIImage ? _successImage ;
39- private UIImage ? _infoImage ;
40- private UIImage ? _errorOutlineImage ;
41- private UIImage ? _successOutlineImage ;
42- private UIImage ? _infoOutlineImage ;
43- private UIImage ? _errorOutlineFullImage ;
44- private UIImage ? _successOutlineFullImage ;
45- private UIImage ? _infoOutlineFullImage ;
37+ private UIImage ? _errorImage = ProgressHUDAppearance . ErrorImage ;
38+ private UIImage ? _successImage = ProgressHUDAppearance . SuccessImage ;
39+ private UIImage ? _infoImage = ProgressHUDAppearance . InfoImage ;
40+ private UIImage ? _errorOutlineImage = ProgressHUDAppearance . ErrorOutlineImage ;
41+ private UIImage ? _successOutlineImage = ProgressHUDAppearance . SuccessOutlineImage ;
42+ private UIImage ? _infoOutlineImage = ProgressHUDAppearance . InfoOutlineImage ;
43+ private UIImage ? _errorOutlineFullImage = ProgressHUDAppearance . ErrorOutlineFullImage ;
44+ private UIImage ? _successOutlineFullImage = ProgressHUDAppearance . SuccessOutlineFullImage ;
45+ private UIImage ? _infoOutlineFullImage = ProgressHUDAppearance . InfoOutlineFullImage ;
4646
4747 private MaskType _maskType ;
4848 private NSTimer ? _fadeoutTimer ;
@@ -100,22 +100,12 @@ public ProgressHUD(UIWindow window) : base(window.Bounds)
100100 BackgroundColor = UIColor . Clear ;
101101 Alpha = 0 ;
102102 AutoresizingMask = UIViewAutoresizing . FlexibleWidth | UIViewAutoresizing . FlexibleHeight ;
103-
104- SetOSSpecificLookAndFeel ( ) ;
105103 }
106104
107105 public UIWindow HudWindow { get ; private set ; }
108106
109107 public static CGRect KeyboardSize { get ; private set ; } = CGRect . Empty ;
110108
111- public UIColor HudBackgroundColour { get ; set ; } = UIColor . FromWhiteAlpha ( 0.0f , 0.8f ) ;
112- public UIColor HudForegroundColor { get ; set ; } = UIColor . White ;
113- public UIColor HudStatusShadowColor { get ; set ; } = UIColor . Black ;
114- public UIColor HudToastBackgroundColor { get ; set ; } = UIColor . Clear ;
115- public UIFont HudFont { get ; set ; } = UIFont . BoldSystemFontOfSize ( 16f ) ;
116- public UITextAlignment HudTextAlignment { get ; set ; } = UITextAlignment . Center ;
117- public Ring Ring { get ; } = new ( ) ;
118-
119109 public UIImage ErrorImage
120110 {
121111 get => _errorImage ?? ImageHelper . ErrorImage . Value ! ;
@@ -215,9 +205,6 @@ public UIImage InfoOutlineFullImage
215205
216206 return For ( window ) ;
217207 }
218-
219- public float RingRadius { get ; set ; } = 14f ;
220- public float RingThickness { get ; set ; } = 6f ;
221208
222209 CAShapeLayer RingLayer
223210 {
@@ -226,7 +213,8 @@ CAShapeLayer RingLayer
226213 if ( _ringLayer == null )
227214 {
228215 var center = new CGPoint ( HudView . Frame . Width / 2 , HudView . Frame . Height / 2 ) ;
229- _ringLayer = ShapeHelper . CreateRingLayer ( center , RingRadius , RingThickness , Ring . Color ) ;
216+ _ringLayer = ShapeHelper . CreateRingLayer ( center , ProgressHUDAppearance . RingRadius ,
217+ ProgressHUDAppearance . RingThickness , ProgressHUDAppearance . RingColor ) ;
230218 HudView . Layer . AddSublayer ( _ringLayer ) ;
231219 }
232220 return _ringLayer ;
@@ -240,7 +228,8 @@ CAShapeLayer RingLayer
240228 if ( _backgroundRingLayer == null )
241229 {
242230 var center = new CGPoint ( HudView . Frame . Width / 2 , HudView . Frame . Height / 2 ) ;
243- _backgroundRingLayer = ShapeHelper . CreateRingLayer ( center , RingRadius , RingThickness , Ring . BackgroundColor ) ;
231+ _backgroundRingLayer = ShapeHelper . CreateRingLayer ( center , ProgressHUDAppearance . RingRadius ,
232+ ProgressHUDAppearance . RingThickness , ProgressHUDAppearance . RingBackgroundColor ) ;
244233 _backgroundRingLayer . StrokeEnd = 1 ;
245234 HudView . Layer . AddSublayer ( _backgroundRingLayer ) ;
246235 }
@@ -269,13 +258,13 @@ UIView HudView
269258 var hudView = new UIToolbar
270259 {
271260 Translucent = true ,
272- BarTintColor = HudBackgroundColour ,
273- BackgroundColor = HudBackgroundColour ,
261+ BarTintColor = ProgressHUDAppearance . HudBackgroundColor ,
262+ BackgroundColor = ProgressHUDAppearance . HudBackgroundColor ,
274263 AutoresizingMask =
275264 UIViewAutoresizing . FlexibleBottomMargin | UIViewAutoresizing . FlexibleTopMargin |
276265 UIViewAutoresizing . FlexibleRightMargin | UIViewAutoresizing . FlexibleLeftMargin
277266 } ;
278- hudView . Layer . CornerRadius = 10 ;
267+ hudView . Layer . CornerRadius = ProgressHUDAppearance . HudCornerRadius ;
279268 hudView . Layer . MasksToBounds = true ;
280269
281270 AddSubview ( hudView ) ;
@@ -292,12 +281,12 @@ UILabel StringLabel
292281 {
293282 _stringLabel ??= new UILabel
294283 {
295- BackgroundColor = HudToastBackgroundColor ,
284+ BackgroundColor = ProgressHUDAppearance . HudToastBackgroundColor ,
296285 AdjustsFontSizeToFitWidth = true ,
297- TextAlignment = HudTextAlignment ,
286+ TextAlignment = ProgressHUDAppearance . HudTextAlignment ,
298287 BaselineAdjustment = UIBaselineAdjustment . AlignCenters ,
299- TextColor = HudForegroundColor ,
300- Font = HudFont ,
288+ TextColor = ProgressHUDAppearance . HudTextColor ,
289+ Font = ProgressHUDAppearance . HudFont ,
301290 Lines = 0
302291 } ;
303292
@@ -321,9 +310,8 @@ UIButton CancelHudButton
321310 BackgroundColor = UIColor . Clear ,
322311 UserInteractionEnabled = true
323312 } ;
324- _cancelHud . TitleLabel . Font = HudFont ;
325-
326- _cancelHud . SetTitleColor ( HudForegroundColor , UIControlState . Normal ) ;
313+ _cancelHud . TitleLabel . Font = ProgressHUDAppearance . HudButtonFont ;
314+ _cancelHud . SetTitleColor ( ProgressHUDAppearance . HudButtonTextColor , UIControlState . Normal ) ;
327315 UserInteractionEnabled = true ;
328316 }
329317
@@ -364,11 +352,14 @@ UIActivityIndicatorView SpinnerView
364352 {
365353 get
366354 {
367- _spinnerView ??= new UIActivityIndicatorView ( UIActivityIndicatorViewStyle . WhiteLarge )
355+ _spinnerView ??= new UIActivityIndicatorView (
356+ OperatingSystem . IsMacCatalystVersionAtLeast ( 13 , 1 ) || OperatingSystem . IsIOSVersionAtLeast ( 13 ) ?
357+ UIActivityIndicatorViewStyle . Large :
358+ UIActivityIndicatorViewStyle . WhiteLarge )
368359 {
369360 HidesWhenStopped = true ,
370361 Bounds = new CGRect ( 0 , 0 , 37 , 37 ) ,
371- Color = HudForegroundColor
362+ Color = ProgressHUDAppearance . RingColor
372363 } ;
373364
374365 // ReSharper disable once ConditionIsAlwaysTrueOrFalse
@@ -379,20 +370,6 @@ UIActivityIndicatorView SpinnerView
379370 }
380371 }
381372
382- private void SetOSSpecificLookAndFeel ( )
383- {
384- HudBackgroundColour =
385- ( System . OperatingSystem . IsIOSVersionAtLeast ( 13 , 0 ) || OperatingSystem . IsMacCatalystVersionAtLeast ( 13 ) )
386- ? UIColor . SystemBackground . ColorWithAlpha ( 0.8f ) : UIColor . White . ColorWithAlpha ( 0.8f ) ;
387- HudForegroundColor =
388- ( System . OperatingSystem . IsIOSVersionAtLeast ( 13 , 0 ) || OperatingSystem . IsMacCatalystVersionAtLeast ( 13 ) )
389- ? UIColor . Label . ColorWithAlpha ( 0.8f ) : UIColor . FromWhiteAlpha ( 0.0f , 0.8f ) ;
390- HudStatusShadowColor =
391- ( System . OperatingSystem . IsIOSVersionAtLeast ( 13 , 0 ) || OperatingSystem . IsMacCatalystVersionAtLeast ( 13 ) )
392- ? UIColor . Label . ColorWithAlpha ( 0.8f ) : UIColor . FromWhiteAlpha ( 200f / 255f , 0.8f ) ;
393- RingThickness = 1f ;
394- }
395-
396373 public void Show ( string ? status = null , float progress = - 1 , MaskType maskType = MaskType . None , double timeoutMs = 1000 )
397374 {
398375 obj . InvokeOnMainThread ( ( ) => ShowProgressWorker ( progress , status , maskType , timeoutMs : timeoutMs ) ) ;
@@ -510,9 +487,6 @@ private void ShowProgressWorker(
510487 ToastPosition toastPosition = ToastPosition . Center , string ? cancelCaption = null , Action ? cancelCallback = null ,
511488 double timeoutMs = 1000 , bool showContinuousProgress = false , UIImage ? displayContinuousImage = null )
512489 {
513- if ( TintColor != null )
514- Ring . ResetStyle ( TintColor ) ;
515-
516490 // ReSharper disable once ConditionIsAlwaysTrueOrFalse
517491 if ( OverlayView . Superview == null )
518492 {
@@ -557,7 +531,7 @@ private void ShowProgressWorker(
557531 }
558532
559533 RingLayer . StrokeEnd = 0.0f ;
560- StartProgressTimer ( TimeSpan . FromMilliseconds ( Ring . ProgressUpdateInterval ) ) ;
534+ StartProgressTimer ( TimeSpan . FromMilliseconds ( ProgressHUDAppearance . RingProgressUpdateInterval ) ) ;
561535 }
562536 else
563537 {
@@ -651,7 +625,7 @@ private void ShowImageWorker(UIImage image, string? status, MaskType maskType, T
651625 Show ( null , - 1F , maskType ) ;
652626 }
653627
654- ImageView . TintColor = HudForegroundColor ;
628+ ImageView . TintColor = ProgressHUDAppearance . HudImageTintColor ;
655629 ImageView . Image = image . ImageWithRenderingMode ( UIImageRenderingMode . AlwaysTemplate ) ;
656630 ImageView . Hidden = false ;
657631 StringLabel . Text = status ;
@@ -762,9 +736,6 @@ private void RemoveHud()
762736 UnRegisterNotifications ( ) ;
763737 NSNotificationCenter . DefaultCenter . RemoveObserver ( this ) ;
764738
765- if ( TintColor != null )
766- Ring . ResetStyle ( TintColor ) ;
767-
768739 CancelRingLayerAnimation ( ) ;
769740 StringLabel . RemoveFromSuperview ( ) ;
770741 SpinnerView . RemoveFromSuperview ( ) ;
0 commit comments