Merge pull request #25 from flexih/main

Supports spin
This commit is contained in:
Ivan Vorobei
2023-04-21 15:11:46 +03:00
committed by GitHub
2 changed files with 14 additions and 1 deletions
@@ -104,6 +104,12 @@ class PresetsController: SPDiffableTableController {
message: "Try again",
preset: .error
),
IndicatorPresetModel(
name: "Spin",
title: "Spin",
message: "Animatable",
preset: .spin(.medium)
),
IndicatorPresetModel(
name: "Custom Image",
title: "Custom Image",
@@ -29,7 +29,7 @@ public enum SPIndicatorIconPreset {
case done
case error
case spin(_ style: UIActivityIndicatorView.Style)
case custom(_ image: UIImage)
}
@@ -46,6 +46,10 @@ public extension SPIndicatorIconPreset {
let view = SPIndicatorIconErrorView()
view.tintColor = UIColor.systemRed
return view
case .spin(let style):
let view = UIActivityIndicatorView(style: style)
view.startAnimating()
return view
case .custom(let image):
let imageView = UIImageView(image: image)
imageView.contentMode = .scaleAspectFit
@@ -57,6 +61,7 @@ public extension SPIndicatorIconPreset {
switch self {
case .error: return .error
case .done: return .success
case .spin(_): return .none
case .custom(_): return .success
}
}
@@ -96,6 +101,8 @@ public extension SPIndicatorLayout {
iconSize = .init(width: 14, height: 14)
margins.left = 19
margins.right = margins.left
case .spin(_):
self.init()
case .custom(_):
self.init()
}