SDWebImageIndicator.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. /**
  11. A protocol to custom the indicator during the image loading.
  12. All of these methods are called from main queue.
  13. */
  14. @protocol SDWebImageIndicator <NSObject>
  15. @required
  16. /**
  17. The view associate to the indicator.
  18. @return The indicator view
  19. */
  20. @property (nonatomic, strong, readonly, nonnull) UIView *indicatorView;
  21. /**
  22. Start the animating for indicator.
  23. */
  24. - (void)startAnimatingIndicator;
  25. /**
  26. Stop the animating for indicator.
  27. */
  28. - (void)stopAnimatingIndicator;
  29. @optional
  30. /**
  31. Update the loading progress (0-1.0) for indicator. Optional
  32. @param progress The progress, value between 0 and 1.0
  33. */
  34. - (void)updateIndicatorProgress:(double)progress;
  35. @end
  36. #pragma mark - Activity Indicator
  37. /**
  38. Activity indicator class.
  39. for UIKit(macOS), it use a `UIActivityIndicatorView`.
  40. for AppKit(macOS), it use a `NSProgressIndicator` with the spinning style.
  41. */
  42. @interface SDWebImageActivityIndicator : NSObject <SDWebImageIndicator>
  43. #if SD_UIKIT
  44. @property (nonatomic, strong, readonly, nonnull) UIActivityIndicatorView *indicatorView;
  45. #else
  46. @property (nonatomic, strong, readonly, nonnull) NSProgressIndicator *indicatorView;
  47. #endif
  48. @end
  49. /**
  50. Convenience way to use activity indicator.
  51. */
  52. @interface SDWebImageActivityIndicator (Conveniences)
  53. /// gray-style activity indicator
  54. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayIndicator;
  55. /// large gray-style activity indicator
  56. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayLargeIndicator;
  57. /// white-style activity indicator
  58. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteIndicator;
  59. /// large white-style activity indicator
  60. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteLargeIndicator;
  61. @end
  62. #pragma mark - Progress Indicator
  63. /**
  64. Progress indicator class.
  65. for UIKit(macOS), it use a `UIProgressView`.
  66. for AppKit(macOS), it use a `NSProgressIndicator` with the bar style.
  67. */
  68. @interface SDWebImageProgressIndicator : NSObject <SDWebImageIndicator>
  69. #if SD_UIKIT
  70. @property (nonatomic, strong, readonly, nonnull) UIProgressView *indicatorView;
  71. #else
  72. @property (nonatomic, strong, readonly, nonnull) NSProgressIndicator *indicatorView;
  73. #endif
  74. @end
  75. /**
  76. Convenience way to create progress indicator. Remember to specify the indicator width or use layout constraint if need.
  77. */
  78. @interface SDWebImageProgressIndicator (Conveniences)
  79. /// default-style progress indicator
  80. @property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *defaultIndicator;
  81. /// bar-style progress indicator
  82. @property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *barIndicator API_UNAVAILABLE(macos, tvos);
  83. @end
  84. #endif