Skip to content

Commit e8a045f

Browse files
authored
Merge pull request #25 from flexih/main
Supports spin
2 parents f9676f1 + 6aa2225 commit e8a045f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Example Apps/iOS Example/Scenes/PresetsController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ class PresetsController: SPDiffableTableController {
104104
message: "Try again",
105105
preset: .error
106106
),
107+
IndicatorPresetModel(
108+
name: "Spin",
109+
title: "Spin",
110+
message: "Animatable",
111+
preset: .spin(.medium)
112+
),
107113
IndicatorPresetModel(
108114
name: "Custom Image",
109115
title: "Custom Image",

Sources/SPIndicator/SPIndicatorIconPreset.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public enum SPIndicatorIconPreset {
2929

3030
case done
3131
case error
32-
32+
case spin(_ style: UIActivityIndicatorView.Style)
3333
case custom(_ image: UIImage)
3434
}
3535

@@ -46,6 +46,10 @@ public extension SPIndicatorIconPreset {
4646
let view = SPIndicatorIconErrorView()
4747
view.tintColor = UIColor.systemRed
4848
return view
49+
case .spin(let style):
50+
let view = UIActivityIndicatorView(style: style)
51+
view.startAnimating()
52+
return view
4953
case .custom(let image):
5054
let imageView = UIImageView(image: image)
5155
imageView.contentMode = .scaleAspectFit
@@ -57,6 +61,7 @@ public extension SPIndicatorIconPreset {
5761
switch self {
5862
case .error: return .error
5963
case .done: return .success
64+
case .spin(_): return .none
6065
case .custom(_): return .success
6166
}
6267
}
@@ -96,6 +101,8 @@ public extension SPIndicatorLayout {
96101
iconSize = .init(width: 14, height: 14)
97102
margins.left = 19
98103
margins.right = margins.left
104+
case .spin(_):
105+
self.init()
99106
case .custom(_):
100107
self.init()
101108
}

0 commit comments

Comments
 (0)