SDWebImageIndicator.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "SDWebImageCompat.h"
  9. #if SD_UIKIT || SD_MAC
  10. // A protocol to custom the indicator during the image loading
  11. // All of these methods are called from main queue
  12. @protocol SDWebImageIndicator <NSObject>
  13. @required
  14. /**
  15. The view associate to the indicator.
  16. @return The indicator view
  17. */
  18. - (nonnull UIView *)indicatorView;
  19. /**
  20. Start the animating for indicator.
  21. */
  22. - (void)startAnimatingIndicator;
  23. /**
  24. Stop the animating for indicator.
  25. */
  26. - (void)stopAnimatingIndicator;
  27. @optional
  28. /**
  29. Update the loading progress (0-1.0) for indicator. Optional
  30. @param progress The progress, value between 0 and 1.0
  31. */
  32. - (void)updateIndicatorProgress:(double)progress;
  33. @end
  34. #pragma mark - Activity Indicator
  35. // Activity indicator class
  36. // for UIKit(macOS), it use a `UIActivityIndicatorView`
  37. // for AppKit(macOS), it use a `NSProgressIndicator` with the spinning style
  38. @interface SDWebImageActivityIndicator : NSObject <SDWebImageIndicator>
  39. #if SD_UIKIT
  40. @property (nonatomic, strong, readonly, nonnull) UIActivityIndicatorView *indicatorView;
  41. #else
  42. @property (nonatomic, strong, readonly, nonnull) NSProgressIndicator *indicatorView;
  43. #endif
  44. @end
  45. // Convenience way to use activity indicator.
  46. @interface SDWebImageActivityIndicator (Conveniences)
  47. /// gray-style activity indicator
  48. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayIndicator;
  49. /// large gray-style activity indicator
  50. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayLargeIndicator;
  51. /// white-style activity indicator
  52. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteIndicator;
  53. /// large white-style activity indicator
  54. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteLargeIndicator;
  55. @end
  56. #pragma mark - Progress Indicator
  57. // Progress indicator class
  58. // for UIKit(macOS), it use a `UIProgressView`
  59. // for AppKit(macOS), it use a `NSProgressIndicator` with the bar style
  60. @interface SDWebImageProgressIndicator : NSObject <SDWebImageIndicator>
  61. #if SD_UIKIT
  62. @property (nonatomic, strong, readonly, nonnull) UIProgressView *indicatorView;
  63. #else
  64. @property (nonatomic, strong, readonly, nonnull) NSProgressIndicator *indicatorView;
  65. #endif
  66. @end
  67. // Convenience way to create progress indicator. Remember to specify the indicator width or use layout constraint if need.
  68. @interface SDWebImageProgressIndicator (Conveniences)
  69. /// default-style progress indicator
  70. @property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *defaultIndicator;
  71. /// bar-style progress indicator
  72. @property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *barIndicator API_UNAVAILABLE(macos, tvos);
  73. @end
  74. #endif