diff --git a/ActivityIndicatorView.podspec b/ActivityIndicatorView.podspec
index 6eee66e..7db2b99 100644
--- a/ActivityIndicatorView.podspec
+++ b/ActivityIndicatorView.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ActivityIndicatorView"
- s.version = "1.0.1"
+ s.version = "1.1.0"
s.summary = "A number of preset loading indicators created with SwiftUI."
s.homepage = 'https://github.com/exyte/ActivityIndicatorView.git'
diff --git a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Example/Example/ContentView.swift b/Example/Example/ContentView.swift
index fab462b..f71b189 100644
--- a/Example/Example/ContentView.swift
+++ b/Example/Example/ContentView.swift
@@ -23,19 +23,19 @@ struct ContentView: View {
Spacer()
VStack(spacing: spacing) {
Spacer()
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .default)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .default())
.frame(width: size, height: size)
.foregroundColor(.red)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .arcs)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .arcs())
.frame(width: size, height: size)
.foregroundColor(.red)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .rotatingDots)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .rotatingDots())
.frame(width: size, height: size)
.foregroundColor(.red)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .equalizer)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .equalizer())
.frame(width: size, height: size)
.foregroundColor(.red)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .growingArc())
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .growingArc(.red))
.frame(width: size, height: size)
.foregroundColor(.red)
Spacer()
@@ -45,18 +45,18 @@ struct ContentView: View {
VStack(spacing: spacing) {
Spacer()
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .opacityDots)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .opacityDots())
.frame(width: size, height: size)
.foregroundColor(.red)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .scalingDots)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .scalingDots())
.frame(width: size, height: size)
.foregroundColor(.red)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .gradient([Color.white, Color.red]))
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .gradient([Color.white, Color.red]))
.frame(width: size, height: size)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .growingCircle)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .growingCircle)
.frame(width: size, height: size)
.foregroundColor(.red)
- ActivityIndicatorView(isVisible: self.$showLoadingIndicator, type: .flickeringDots)
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .flickeringDots())
.frame(width: size, height: size)
.foregroundColor(.red)
Spacer()
diff --git a/Example/Podfile.lock b/Example/Podfile.lock
index 724cb03..69ec5a1 100644
--- a/Example/Podfile.lock
+++ b/Example/Podfile.lock
@@ -1,5 +1,5 @@
PODS:
- - ActivityIndicatorView (1.0.0)
+ - ActivityIndicatorView (1.0.1)
DEPENDENCIES:
- ActivityIndicatorView (from `../`)
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"
SPEC CHECKSUMS:
- ActivityIndicatorView: a9f6fc491aa8a7b351ea899fab0570b8288ba5b4
+ ActivityIndicatorView: 425e6db935766a4a87d65cd2ce021a023bfa0603
PODFILE CHECKSUM: 54898b444f2a064d09ec9574815fb481a733ffec
diff --git a/README.md b/README.md
index bb9947a..9636b40 100644
--- a/README.md
+++ b/README.md
@@ -38,26 +38,53 @@ You may alter it with standard SwiftUI means like this:
.frame(width: 50.0, height: 50.0)
.foregroundColor(.red)
```
+Or specify another indicator type:
-### Indicator types
-`default` - iOS UIActivityIndicator style
-`arcs`
-`rotatingDots`
-`flickeringDots`
-`scalingDots`
-`opacityDots`
-`equalizer`
-`growingArc` - add custom color for growing Arc, the default value is `Color.red`
```swift
- ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .growingArc(.red))
+ ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .growingArc(.red, lineWidth: 4))
.frame(width: 50.0, height: 50.0)
```
-`growingCircle`
-`gradient` - circle with angular gradient border stroke, pass colors ilke this:
- ```swift
- ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .gradient([.white, .red]))
- .frame(width: 50.0, height: 50.0)
- ```
+
+### Indicator types
+Each indicator type has a number of parameters that have reasonable defaults. You can change them as you see fit, but it is advised to not set them too high or too low.
+
+`default` - iOS UIActivityIndicator style
+```swift
+.default(count: 8)
+```
+`arcs`
+```swift
+.arcs(count: 3, lineWidth: 2)
+```
+`rotatingDots`
+```swift
+.rotatingDots(count: 5)
+```
+`flickeringDots`
+```swift
+.flickeringDots(count: 8)
+```
+`scalingDots`
+```swift
+.scalingDots(count: 3, inset: 2)
+```
+`opacityDots`
+```swift
+.opacityDots(count: 3, inset: 4)
+```
+`equalizer`
+```swift
+.equalizer(count: 5)
+```
+`growingArc` - add custom color for growing Arc, the default value is `Color.black`
+```swift
+.growingArc(.red, lineWidth: 4))
+```
+`growingCircle` no parameters
+`gradient` - circle with angular gradient border stroke, pass colors ilke this:
+```swift
+.gradient([.white, .red], lineWidth: 4)
+```
## Examples
diff --git a/Source/ActivityIndicatorView.swift b/Source/ActivityIndicatorView.swift
index 6c2e30b..c0aedb5 100644
--- a/Source/ActivityIndicatorView.swift
+++ b/Source/ActivityIndicatorView.swift
@@ -11,23 +11,23 @@ import SwiftUI
public struct ActivityIndicatorView: View {
public enum IndicatorType {
- case `default`
- case arcs
- case rotatingDots
- case flickeringDots
- case scalingDots
- case opacityDots
- case equalizer
- case growingArc(Color = .red)
+ case `default`(count: Int = 8)
+ case arcs(count: Int = 3, lineWidth: CGFloat = 2)
+ case rotatingDots(count: Int = 5)
+ case flickeringDots(count: Int = 8)
+ case scalingDots(count: Int = 3, inset: Int = 2)
+ case opacityDots(count: Int = 3, inset: Int = 4)
+ case equalizer(count: Int = 5)
+ case growingArc(Color = .black, lineWidth: CGFloat = 4)
case growingCircle
- case gradient([Color], CGLineCap = .butt)
+ case gradient([Color], CGLineCap = .butt, lineWidth: CGFloat = 4)
}
@Binding var isVisible: Bool
var type: IndicatorType
public init(isVisible: Binding, type: IndicatorType) {
- self._isVisible = isVisible
+ _isVisible = isVisible
self.type = type
}
@@ -44,26 +44,26 @@ public struct ActivityIndicatorView: View {
private var indicator: some View {
ZStack {
switch type {
- case .default:
- DefaultIndicatorView()
- case .arcs:
- ArcsIndicatorView()
- case .rotatingDots:
- RotatingDotsIndicatorView()
- case .flickeringDots:
- FlickeringDotsIndicatorView()
- case .scalingDots:
- ScalingDotsIndicatorView()
- case .opacityDots:
- OpacityDotsIndicatorView()
- case .equalizer:
- EqualizerIndicatorView()
- case .growingArc(let color):
- GrowingArcIndicatorView(color: color)
+ case .default(let count):
+ DefaultIndicatorView(count: count)
+ case .arcs(let count, let lineWidth):
+ ArcsIndicatorView(count: count, lineWidth: lineWidth)
+ case .rotatingDots(let count):
+ RotatingDotsIndicatorView(count: count)
+ case .flickeringDots(let count):
+ FlickeringDotsIndicatorView(count: count)
+ case .scalingDots(let count, let inset):
+ ScalingDotsIndicatorView(count: count, inset: inset)
+ case .opacityDots(let count, let inset):
+ OpacityDotsIndicatorView(count: count, inset: inset)
+ case .equalizer(let count):
+ EqualizerIndicatorView(count: count)
+ case .growingArc(let color, let lineWidth):
+ GrowingArcIndicatorView(color: color, lineWidth: lineWidth)
case .growingCircle:
GrowingCircleIndicatorView()
- case .gradient(let colors, let lineCap):
- GradientIndicatorView(colors: colors, lineCap: lineCap)
+ case .gradient(let colors, let lineCap, let lineWidth):
+ GradientIndicatorView(colors: colors, lineCap: lineCap, lineWidth: lineWidth)
}
}
}
diff --git a/Source/Indicators/ArcsIndicatorView.swift b/Source/Indicators/ArcsIndicatorView.swift
index 26fd779..699952c 100644
--- a/Source/Indicators/ArcsIndicatorView.swift
+++ b/Source/Indicators/ArcsIndicatorView.swift
@@ -10,19 +10,22 @@ import SwiftUI
struct ArcsIndicatorView: View {
- private let count: Int = 3
+ let count: Int
+ let lineWidth: CGFloat
var body: some View {
GeometryReader { geometry in
- ForEach(0.. Path in
var p = Path()
- p.addArc(center: CGPoint(x: self.size.width / 2, y: self.size.height / 2),
- radius: self.size.width / 2 - CGFloat(self.index) * CGFloat(self.count),
+ p.addArc(center: CGPoint(x: size.width / 2, y: size.height / 2),
+ radius: size.width / 2 - CGFloat(index) * CGFloat(count),
startAngle: .degrees(0),
endAngle: .degrees(Double(Int.random(in: 120...300))),
clockwise: true)
- return p.strokedPath(.init(lineWidth: 2))
+ return p.strokedPath(.init(lineWidth: lineWidth))
}
.frame(width: size.width, height: size.height)
.rotationEffect(.degrees(rotation))
.onAppear {
- self.rotation = 0
+ rotation = 0
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
withAnimation(animation) {
- self.rotation = 360
+ rotation = 360
}
}
}
diff --git a/Source/Indicators/DefaultIndicatorView.swift b/Source/Indicators/DefaultIndicatorView.swift
index d50a82f..78437b2 100644
--- a/Source/Indicators/DefaultIndicatorView.swift
+++ b/Source/Indicators/DefaultIndicatorView.swift
@@ -10,13 +10,14 @@ import SwiftUI
struct DefaultIndicatorView: View {
- private let count: Int = 8
+ let count: Int
public var body: some View {
GeometryReader { geometry in
- ForEach(0..