Skip to content

Commit 463c3cb

Browse files
committed
fix backgroundLayer logic
- added isBackgroundLayerHidden
1 parent a0e31fa commit 463c3cb

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ extension CircularProgressVM {
151151
return false
152152
}
153153
}
154+
var isBackgroundLayerHidden: Bool {
155+
switch self.style {
156+
case .light:
157+
return false
158+
case .striped:
159+
return true
160+
}
161+
}
154162
func stripesBezierPath(in rect: CGRect) -> UIBezierPath {
155163
return UIBezierPath(cgPath: self.stripesCGPath(in: rect))
156164
}

Sources/ComponentsKit/Components/CircularProgress/UKCircularProgress.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ open class UKCircularProgress: UIView, UKComponent {
168168
self.backgroundLayer.frame = self.bounds
169169
self.progressLayer.frame = self.bounds
170170
self.stripesLayer.frame = self.bounds
171-
172171
self.stripesMaskLayer.frame = self.bounds
173172

174173
self.updateShapePaths()
@@ -206,18 +205,15 @@ open class UKCircularProgress: UIView, UKComponent {
206205

207206
extension UKCircularProgress {
208207
fileprivate enum Style {
209-
static func backgroundLayer(_ layer: CAShapeLayer, model: CircularProgressVM) {
208+
static func backgroundLayer(
209+
_ layer: CAShapeLayer,
210+
model: CircularProgressVM
211+
) {
210212
layer.fillColor = UIColor.clear.cgColor
211-
212-
switch model.style {
213-
case .light:
214-
layer.strokeColor = model.color.background.uiColor.cgColor
215-
case .striped:
216-
layer.strokeColor = UIColor.clear.cgColor
217-
}
218-
213+
layer.strokeColor = model.color.background.uiColor.cgColor
219214
layer.lineCap = .round
220215
layer.lineWidth = model.circularLineWidth
216+
layer.isHidden = model.isBackgroundLayerHidden
221217
}
222218

223219
static func progressLayer(_ layer: CAShapeLayer, model: CircularProgressVM) {

0 commit comments

Comments
 (0)