Skip to content

Commit

Permalink
Fix tvOS warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasGessner committed Oct 15, 2020
1 parent 19d74f0 commit 768e2f2
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions JGProgressHUD/JGProgressHUD/JGProgressHUD.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static inline CGRect JGProgressHUD_CGRectIntegral(CGRect rect) {
return (CGRect){{((CGFloat)floor(rect.origin.x*scale))/scale, ((CGFloat)floor(rect.origin.y*scale))/scale}, {((CGFloat)ceil(rect.size.width*scale))/scale, ((CGFloat)ceil(rect.size.height*scale))/scale}};
}

API_AVAILABLE(ios(12.0))
API_AVAILABLE(ios(12.0), tvos(10.0))
static inline JGProgressHUDStyle JGProgressHUDStyleFromUIUserInterfaceStyle(UIUserInterfaceStyle uiStyle) {
if (uiStyle == UIUserInterfaceStyleDark) {
return JGProgressHUDStyleDark;
Expand Down Expand Up @@ -204,15 +204,23 @@ + (instancetype)progressHUDWithStyle:(JGProgressHUDStyle)style {
}

- (instancetype)initWithAutomaticStyle {
if (@available(iOS 13.0, *)) {
UIUserInterfaceStyle currentStyle = [[UITraitCollection currentTraitCollection] userInterfaceStyle];
if (@available(iOS 12.0, tvOS 10.0, *)) {
JGProgressHUDStyle initialStyle;

self = [self initWithStyle:JGProgressHUDStyleFromUIUserInterfaceStyle(currentStyle)];
if (@available(iOS 13.0, tvOS 13.0, *)) {
initialStyle = JGProgressHUDStyleFromUIUserInterfaceStyle([[UITraitCollection currentTraitCollection] userInterfaceStyle]);
}
else {
initialStyle = JGProgressHUDStyleExtraLight;
}

self = [self initWithStyle:initialStyle];

if (self != nil) {
_automaticStyle = YES;
}
} else {
}
else {
self = [self initWithStyle:JGProgressHUDStyleExtraLight];
}

Expand Down Expand Up @@ -1127,7 +1135,7 @@ - (void)setProgress:(float)progress animated:(BOOL)animated {
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];

if (@available(iOS 12.0, *)) {
if (@available(iOS 12.0, tvOS 10.0, *)) {
if (_automaticStyle) {
self.style = JGProgressHUDStyleFromUIUserInterfaceStyle(self.traitCollection.userInterfaceStyle);
}
Expand Down

0 comments on commit 768e2f2

Please sign in to comment.