Skip to content

Commit a0e31fa

Browse files
committed
fix update stripesMaskLayer in updateProgress
- update only stripesMaskLayer - added isStripesLayerHidden
1 parent b319d38 commit a0e31fa

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

Sources/ComponentsKit/Components/CircularProgress/Models/CircularProgressVM.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ extension CircularProgressVM {
143143
// MARK: - UIKit Helpers
144144

145145
extension CircularProgressVM {
146+
var isStripesLayerHidden: Bool {
147+
switch self.style {
148+
case .light:
149+
return true
150+
case .striped:
151+
return false
152+
}
153+
}
146154
func stripesBezierPath(in rect: CGRect) -> UIBezierPath {
147155
return UIBezierPath(cgPath: self.stripesCGPath(in: rect))
148156
}

Sources/ComponentsKit/Components/CircularProgress/UKCircularProgress.swift

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,14 @@ open class UKCircularProgress: UIView, UKComponent {
131131
private func updateProgress() {
132132
let progress = self.model.progress(for: self.currentValue)
133133

134-
let backgroundLayerStart: CGFloat
135-
let backgroundLayerEnd: CGFloat
136-
switch self.model.style {
137-
case .light:
138-
backgroundLayerStart = 0
139-
backgroundLayerEnd = 1
140-
141-
case .striped:
142-
backgroundLayerStart = self.model.stripedArcStart(for: progress)
143-
backgroundLayerEnd = self.model.stripedArcEnd(for: progress)
144-
}
145-
146134
CATransaction.begin()
147135
CATransaction.setAnimationDuration(self.model.animationDuration)
148136
CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: .linear))
149-
150137
self.progressLayer.strokeEnd = progress
151-
152-
self.backgroundLayer.strokeStart = backgroundLayerStart
153-
self.backgroundLayer.strokeEnd = backgroundLayerEnd
154-
155-
if case .striped = self.model.style {
156-
self.stripesMaskLayer.strokeStart = backgroundLayerStart
157-
self.stripesMaskLayer.strokeEnd = backgroundLayerEnd
158-
} else {
159-
self.stripesMaskLayer.strokeStart = 0
160-
self.stripesMaskLayer.strokeEnd = 1
138+
if !self.model.isStripesLayerHidden {
139+
self.stripesMaskLayer.strokeStart = self.model.stripedArcStart(for: progress)
140+
self.stripesMaskLayer.strokeEnd = self.model.stripedArcEnd(for: progress)
161141
}
162-
163142
CATransaction.commit()
164143

165144
if let labelText = self.model.label {

0 commit comments

Comments
 (0)