SDWebImageIndicator.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. /// These indicator use the fixed color without dark mode support
  54. /// gray-style activity indicator
  55. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayIndicator;
  56. /// large gray-style activity indicator
  57. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayLargeIndicator;
  58. /// white-style activity indicator
  59. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteIndicator;
  60. /// large white-style activity indicator
  61. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteLargeIndicator;
  62. /// These indicator use the system style, supports dark mode if available (iOS 13+/macOS 10.14+)
  63. /// large activity indicator
  64. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *largeIndicator;
  65. /// medium activity indicator
  66. @property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *mediumIndicator;
  67. @end
  68. #pragma mark - Progress Indicator
  69. /**
  70. Progress indicator class.
  71. for UIKit(macOS), it use a `UIProgressView`.
  72. for AppKit(macOS), it use a `NSProgressIndicator` with the bar style.
  73. */
  74. @interface SDWebImageProgressIndicator : NSObject <SDWebImageIndicator>
  75. #if SD_UIKIT
  76. @property (nonatomic, strong, readonly, nonnull) UIProgressView *indicatorView;
  77. #else
  78. @property (nonatomic, strong, readonly, nonnull) NSProgressIndicator *indicatorView;
  79. #endif
  80. @end
  81. /**
  82. Convenience way to create progress indicator. Remember to specify the indicator width or use layout constraint if need.
  83. */
  84. @interface SDWebImageProgressIndicator (Conveniences)
  85. /// default-style progress indicator
  86. @property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *defaultIndicator;
  87. /// bar-style progress indicator
  88. @property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *barIndicator API_UNAVAILABLE(macos, tvos);
  89. @end
  90. #endif