diff --git a/Package.resolved b/Package.resolved index 313c699..9afd16f 100644 --- a/Package.resolved +++ b/Package.resolved @@ -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" } } ], diff --git a/README.md b/README.md index 619320d..ec4b136 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Sources/SwiftUIKit/Components/ScaleableWaitingIndicator.swift b/Sources/SwiftUIKit/Components/ScaleableWaitingIndicator.swift new file mode 100755 index 0000000..ad3e584 --- /dev/null +++ b/Sources/SwiftUIKit/Components/ScaleableWaitingIndicator.swift @@ -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) +} diff --git a/Sources/SwiftUIKit/SwiftUIKit.docc/SwiftUIKit.md b/Sources/SwiftUIKit/SwiftUIKit.docc/SwiftUIKit.md index 47a9b4f..36cd355 100644 --- a/Sources/SwiftUIKit/SwiftUIKit.docc/SwiftUIKit.md +++ b/Sources/SwiftUIKit/SwiftUIKit.docc/SwiftUIKit.md @@ -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