|
@@ -86,34 +86,42 @@ extension Indicator {
|
|
|
|
|
|
|
|
// MARK: - ActivityIndicator
|
|
// MARK: - ActivityIndicator
|
|
|
// Displays a NSProgressIndicator / UIActivityIndicatorView
|
|
// Displays a NSProgressIndicator / UIActivityIndicatorView
|
|
|
-struct ActivityIndicator: Indicator {
|
|
|
|
|
|
|
+class ActivityIndicator: Indicator {
|
|
|
|
|
|
|
|
#if os(macOS)
|
|
#if os(macOS)
|
|
|
private let activityIndicatorView: NSProgressIndicator
|
|
private let activityIndicatorView: NSProgressIndicator
|
|
|
#else
|
|
#else
|
|
|
private let activityIndicatorView: UIActivityIndicatorView
|
|
private let activityIndicatorView: UIActivityIndicatorView
|
|
|
#endif
|
|
#endif
|
|
|
|
|
+ private var animatingCount = 0
|
|
|
|
|
|
|
|
var view: IndicatorView {
|
|
var view: IndicatorView {
|
|
|
return activityIndicatorView
|
|
return activityIndicatorView
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func startAnimatingView() {
|
|
func startAnimatingView() {
|
|
|
- #if os(macOS)
|
|
|
|
|
- activityIndicatorView.startAnimation(nil)
|
|
|
|
|
- #else
|
|
|
|
|
- activityIndicatorView.startAnimating()
|
|
|
|
|
- #endif
|
|
|
|
|
- activityIndicatorView.isHidden = false
|
|
|
|
|
|
|
+ animatingCount += 1
|
|
|
|
|
+ // Alrady animating
|
|
|
|
|
+ if animatingCount == 1 {
|
|
|
|
|
+ #if os(macOS)
|
|
|
|
|
+ activityIndicatorView.startAnimation(nil)
|
|
|
|
|
+ #else
|
|
|
|
|
+ activityIndicatorView.startAnimating()
|
|
|
|
|
+ #endif
|
|
|
|
|
+ activityIndicatorView.isHidden = false
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func stopAnimatingView() {
|
|
func stopAnimatingView() {
|
|
|
- #if os(macOS)
|
|
|
|
|
- activityIndicatorView.stopAnimation(nil)
|
|
|
|
|
- #else
|
|
|
|
|
- activityIndicatorView.stopAnimating()
|
|
|
|
|
- #endif
|
|
|
|
|
- activityIndicatorView.isHidden = true
|
|
|
|
|
|
|
+ animatingCount = max(animatingCount - 1, 0)
|
|
|
|
|
+ if animatingCount == 0 {
|
|
|
|
|
+ #if os(macOS)
|
|
|
|
|
+ activityIndicatorView.stopAnimation(nil)
|
|
|
|
|
+ #else
|
|
|
|
|
+ activityIndicatorView.stopAnimating()
|
|
|
|
|
+ #endif
|
|
|
|
|
+ activityIndicatorView.isHidden = true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
init() {
|
|
init() {
|
|
@@ -135,7 +143,7 @@ struct ActivityIndicator: Indicator {
|
|
|
|
|
|
|
|
// MARK: - ImageIndicator
|
|
// MARK: - ImageIndicator
|
|
|
// Displays an ImageView. Supports gif
|
|
// Displays an ImageView. Supports gif
|
|
|
-struct ImageIndicator: Indicator {
|
|
|
|
|
|
|
+class ImageIndicator: Indicator {
|
|
|
private let animatedImageIndicatorView: ImageView
|
|
private let animatedImageIndicatorView: ImageView
|
|
|
|
|
|
|
|
var view: IndicatorView {
|
|
var view: IndicatorView {
|