Skip to content

Commit

Permalink
added color to spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicegginton committed May 26, 2019
1 parent 958e8fa commit b2a7d2b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/Spinner/Spinner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ public final class Spinner {
var speed: Double
/// Dispatch queue that the spinner will run within
var queue: DispatchQueue
/// Color of the spinner
var color: Color

public init(_ pattern: SpinnerPattern, _ text: String = "", speed: Double? = nil) {
public init(_ pattern: SpinnerPattern, _ text: String = "", speed: Double? = nil, color: Color = .white) {
self.pattern = pattern
self.text = text
self.speed = speed ?? pattern.defaultSpeed
self.color = color

self.frameIndex = 0
self.running = false
Expand Down Expand Up @@ -185,7 +188,7 @@ public final class Spinner {

func currentFrame() -> String {

let currentFrame = self.pattern.frames[self.frameIndex]
let currentFrame = self.pattern.frames[self.frameIndex].applyingCodes(self.color)

self.frameIndex = (self.frameIndex + 1) % self.pattern.frames.count

Expand Down

0 comments on commit b2a7d2b

Please sign in to comment.