Skip to content

Commit

Permalink
fix: fix indicator colors
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyingtao committed Jun 14, 2023
1 parent d28e886 commit c4d4b57
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Inchworm/Source/ProcessIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ protocol ProcessIndicatorViewDelegate {
}

class ProcessIndicatorView: UIView {

fileprivate var progressLayer = CAShapeLayer()
fileprivate var minusProgressLayer = CAShapeLayer()
fileprivate var trackLayer = CAShapeLayer()
fileprivate var progressNumberLayer = CATextLayer()
fileprivate var iconLayer = CALayer()

let trackColorVlue = UIColor(displayP3Red: 55.0 / 255.0, green: 45.0 / 255.0, blue: 9.0 / 255.0, alpha: 1)
let minusTrackColorValue = UIColor(displayP3Red: 84.0 / 255.0, green: 84.0 / 255.0, blue: 84.0 / 255.0, alpha: 1)

var limitNumber = 30
var normalIconImage: CGImage?
var dimmedIconImage: CGImage?
Expand Down Expand Up @@ -200,16 +202,16 @@ class ProcessIndicatorView: UIView {

progressLayer.path = circlePath.cgPath
progressColor = UIColor(displayP3Red: 247.0 / 255.0, green: 198.0 / 255.0, blue: 0, alpha: 1)
trackColor = UIColor(displayP3Red: 55.0 / 255.0, green: 45.0 / 255.0, blue: 9.0 / 255.0, alpha: 1)
trackColor = trackColorVlue
progressLayer.strokeColor = progressColor.cgColor
progressLayer.strokeEnd = abs(CGFloat(progress))
progressNumberLayer.foregroundColor = progressColor.cgColor
} else {
progressLayer.isHidden = true
minusProgressLayer.isHidden = false

minusProgressColor = UIColor(displayP3Red: 203.0 / 255.0, green: 203.0 / 255.0, blue: 203.0 / 255.0, alpha: 1)
trackColor = UIColor(displayP3Red: 84.0 / 255.0, green: 84.0 / 255.0, blue: 84.0 / 255.0, alpha: 1)
minusProgressColor = .white
trackColor = minusTrackColorValue
minusProgressLayer.strokeColor = minusProgressColor.cgColor
minusProgressLayer.strokeEnd = abs(CGFloat(progress))
progressNumberLayer.foregroundColor = minusProgressColor.cgColor
Expand Down Expand Up @@ -239,14 +241,14 @@ class ProcessIndicatorView: UIView {
trackLayer.strokeColor = UIColor.gray.cgColor
case .editingSelf:
iconLayer.contents = normalIconImage
trackLayer.strokeColor = UIColor.white.cgColor
trackLayer.strokeColor = (progress > 0 ? trackColorVlue : minusTrackColorValue).cgColor
iconLayer.isHidden = true
progressNumberLayer.isHidden = false
progressLayer.isHidden = false
minusProgressLayer.isHidden = false
case .editingOthers:
iconLayer.contents = normalIconImage
trackLayer.strokeColor = UIColor.white.cgColor
trackLayer.strokeColor = (progress > 0 ? trackColorVlue : minusTrackColorValue).cgColor
iconLayer.isHidden = false
progressNumberLayer.isHidden = true
progressLayer.isHidden = false
Expand Down

0 comments on commit c4d4b57

Please sign in to comment.