Skip to content

Commit

Permalink
Added ScaleableWaitingIndicator
Browse files Browse the repository at this point in the history
Added ScaleableWaitingIndicator control as an animated resizable indication that the app is waiting on a task to finish.
  • Loading branch information
Appracatappra committed Dec 21, 2023
1 parent b5533d5 commit 92de0ba
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Appracatappra/SwiftletUtilities",
"state" : {
"revision" : "4d6bf1f7d694af526dc834cf9b0acfc28949cbc3",
"version" : "1.1.12"
"revision" : "35b92f3d0e5ea66ef3254dd1e812cdc8e61c3578",
"version" : "1.1.13"
}
}
],
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Since, the **Swift Package Manager** is integrated with Xcode 11 (and greater),
* **WordArtButton** - `WordArtButton` is a `SwiftUI` control that is displayed as interactable Word Art. `WordArtButton` will work with both touch based and focus base UIs.
* **WordArtView** - `WordArtView` displays text in the given font at the given size and rotation with the defined gradient.
* **ZoomView** - `ZoomView` A zoomable, scrollable container for the given SwiftUI content. It provides buttons to zoom in & out and to return to the default zoom level.
* **ScaleableWaitingIndicator** - A View that displays an animated waiting indicator that can be scaled to any size desired.

### Embedded Sounds

Expand Down
59 changes: 59 additions & 0 deletions Sources/SwiftUIKit/Components/ScaleableWaitingIndicator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// GamepadWaitingIndicator.swift
// ReedWriteCycle (iOS)
//
// Created by Kevin Mullins on 11/16/22.
//

import SwiftUI

/// A View that displays an animated waiting indicator that can be scaled to any size desired.
public struct ScaleableWaitingIndicator: View {

// MARK: - Properties
/// The `StrokeStyle` of the control.
public var style = StrokeStyle (lineWidth: 6, lineCap: .round)

/// The color of the control.
public var color = Color.white

/// If `true` the control is animated.
@State public var animate = false

// MARK: - Initializers
/// Creates a new instance.
/// - Parameters:
/// - style: The `StrokeStyle` of the control.
/// - color: The color of the control.
public init(style: StrokeStyle = StrokeStyle (lineWidth: 6, lineCap: .round), color: SwiftUI.Color = Color.white) {
self.style = style
self.color = color
}

// MARK: - Control Body
/// The body of the control.
public var body: some View {
ZStack {
Circle()
.trim(from: 0, to: 0.2)
.stroke (AngularGradient(gradient: .init(colors: [color]), center: .center),
style: style)
.rotationEffect(Angle(degrees: animate ? 360 : 8))
.animation(Animation.linear(duration: 0.7).repeatForever(autoreverses: false), value: animate)
Circle()
.trim(from: 0.5, to: 0.7)
.stroke (AngularGradient(gradient: .init(colors: [color]), center: .center),
style: style)
. rotationEffect (Angle (degrees: animate ? 368: 0))
.animation(Animation.linear(duration: 0.7).repeatForever(autoreverses: false), value: animate)
}.onAppear () {
self.animate.toggle()
}
}

}

#Preview {
ScaleableWaitingIndicator()
.background(Color.black)
}
1 change: 1 addition & 0 deletions Sources/SwiftUIKit/SwiftUIKit.docc/SwiftUIKit.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* **WordArtButton** - `WordArtButton` is a `SwiftUI` control that is displayed as interactable Word Art. `WordArtButton` will work with both touch based and focus base UIs.
* **WordArtView** - `WordArtView` displays text in the given font at the given size and rotation with the defined gradient.
* **ZoomView** - `ZoomView` A zoomable, scrollable container for the given SwiftUI content. It provides buttons to zoom in & out and to return to the default zoom level.
* **ScaleableWaitingIndicator** - A View that displays an animated waiting indicator that can be scaled to any size desired.

### Embedded Sounds

Expand Down

0 comments on commit 92de0ba

Please sign in to comment.