Merge branch 'refactor_indicator' into 5.x
* refactor_indicator: Update to support gray & grayLarge on iOS & tvOS
This commit is contained in:
commit
46b62cfb70
|
@ -59,9 +59,9 @@
|
||||||
@interface SDWebImageActivityIndicator (Conveniences)
|
@interface SDWebImageActivityIndicator (Conveniences)
|
||||||
|
|
||||||
/// gray-style activity indicator
|
/// gray-style activity indicator
|
||||||
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayIndicator API_UNAVAILABLE(tvos);
|
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayIndicator;
|
||||||
/// large gray-style activity indicator
|
/// large gray-style activity indicator
|
||||||
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayLargeIndicator API_UNAVAILABLE(ios, tvos);
|
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayLargeIndicator;
|
||||||
/// white-style activity indicator
|
/// white-style activity indicator
|
||||||
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteIndicator;
|
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteIndicator;
|
||||||
/// large white-style activity indicator
|
/// large white-style activity indicator
|
||||||
|
|
|
@ -38,12 +38,7 @@
|
||||||
|
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
- (void)commonInit {
|
- (void)commonInit {
|
||||||
#if SD_TV
|
self.indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||||
UIActivityIndicatorViewStyle style = UIActivityIndicatorViewStyleWhite;
|
|
||||||
#else
|
|
||||||
UIActivityIndicatorViewStyle style = UIActivityIndicatorViewStyleGray;
|
|
||||||
#endif
|
|
||||||
self.indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:style];
|
|
||||||
self.indicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
|
self.indicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,21 +75,30 @@
|
||||||
|
|
||||||
@implementation SDWebImageActivityIndicator (Conveniences)
|
@implementation SDWebImageActivityIndicator (Conveniences)
|
||||||
|
|
||||||
#if SD_MAC || SD_IOS
|
|
||||||
+ (SDWebImageActivityIndicator *)grayIndicator {
|
+ (SDWebImageActivityIndicator *)grayIndicator {
|
||||||
SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new];
|
SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new];
|
||||||
|
#if SD_UIKIT
|
||||||
|
#if SD_IOS
|
||||||
|
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
|
||||||
|
#else
|
||||||
|
indicator.indicatorView.color = [UIColor colorWithWhite:0 alpha:0.45]; // Color from `UIActivityIndicatorViewStyleGray`
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return indicator;
|
return indicator;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SD_MAC
|
|
||||||
+ (SDWebImageActivityIndicator *)grayLargeIndicator {
|
+ (SDWebImageActivityIndicator *)grayLargeIndicator {
|
||||||
SDWebImageActivityIndicator *indicator = SDWebImageActivityIndicator.grayIndicator;
|
SDWebImageActivityIndicator *indicator = SDWebImageActivityIndicator.grayIndicator;
|
||||||
|
#if SD_UIKIT
|
||||||
|
UIColor *grayColor = indicator.indicatorView.color;
|
||||||
|
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
|
||||||
|
indicator.indicatorView.color = grayColor;
|
||||||
|
#else
|
||||||
indicator.indicatorView.controlSize = NSControlSizeRegular;
|
indicator.indicatorView.controlSize = NSControlSizeRegular;
|
||||||
|
#endif
|
||||||
[indicator.indicatorView sizeToFit];
|
[indicator.indicatorView sizeToFit];
|
||||||
return indicator;
|
return indicator;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
+ (SDWebImageActivityIndicator *)whiteIndicator {
|
+ (SDWebImageActivityIndicator *)whiteIndicator {
|
||||||
SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new];
|
SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new];
|
||||||
|
@ -153,7 +157,7 @@
|
||||||
|
|
||||||
#if SD_MAC
|
#if SD_MAC
|
||||||
- (void)commonInit {
|
- (void)commonInit {
|
||||||
self.indicatorView = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 160, 0)];
|
self.indicatorView = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 160, 0)]; // Width from `UIProgressView` default width
|
||||||
self.indicatorView.style = NSProgressIndicatorStyleBar;
|
self.indicatorView.style = NSProgressIndicatorStyleBar;
|
||||||
self.indicatorView.controlSize = NSControlSizeSmall;
|
self.indicatorView.controlSize = NSControlSizeSmall;
|
||||||
[self.indicatorView sizeToFit];
|
[self.indicatorView sizeToFit];
|
||||||
|
|
Loading…
Reference in New Issue