Skip to content

Commit

Permalink
fix: fix indicator status by adding editingOthers to IndicatorStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyingtao committed Jun 14, 2023
1 parent e1a14c4 commit d28e886
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Inchworm/Source/ProcessIndicatorContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extension ProcessIndicatorContainer: UIScrollViewDelegate {
setActiveIndicatorIndex(targetIndex)

guard let processIndicatorView = getActiveIndicator() else { return }
if processIndicatorView.status == .editing {
if processIndicatorView.status == .editingSelf {
self.didActive(processIndicatorView.progress)
}
}
Expand Down
36 changes: 23 additions & 13 deletions Inchworm/Source/ProcessIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,21 @@ class ProcessIndicatorView: UIView {

if self !== object {
active = false
if getProgressValue() == 0 && status != .tempReset {
status = .initial

if status != .tempReset {
if getProgressValue() == 0 {
status = .initial
} else {
status = .editingOthers
}
}
}
}

@objc func handleTap() {
if active {
if status == .tempReset {
status = .editing
status = .editingSelf
delegate?.didRemoveTempReset(self)
} else {
status = .tempReset
Expand All @@ -136,24 +141,20 @@ class ProcessIndicatorView: UIView {
if status == .tempReset {
delegate?.didTempReset(self)
}

status = .editingSelf
}

NotificationCenter.default.post(name: .ProgressIndicatorActivated, object: self)
}

fileprivate func createIcon() {
// let iconLayerLength = frame.width / 2
//
// iconLayer.frame = CGRect(x: frame.width / 2 - iconLayerLength / 2 , y: frame.height / 2 - iconLayerLength / 2 , width: iconLayerLength, height: iconLayerLength)
iconLayer.contentsGravity = .resizeAspect
layer.addSublayer(iconLayer)
}

fileprivate func createCircularPath() {
backgroundColor = UIColor.clear
// layer.cornerRadius = self.frame.size.width/2
//
// trackLayer.path = circlePath.cgPath
trackLayer.fillColor = UIColor.clear.cgColor
trackLayer.strokeColor = trackColor.cgColor
trackLayer.lineWidth = 2.0
Expand Down Expand Up @@ -186,13 +187,12 @@ class ProcessIndicatorView: UIView {
progressNumberLayer.fontSize = 16

progressNumberLayer.alignmentMode = .center
// progressNumberLayer.frame = CGRect(x: self.layer.bounds.origin.x, y: ((self.layer.bounds.height - progressNumberLayer.fontSize) / 2), width: self.layer.bounds.width, height: self.layer.bounds.height)

layer.addSublayer(progressNumberLayer)
}

private func setProgress(_ progress: Float) {
status = .editing
status = .editingSelf

if progress > 0 {
progressLayer.isHidden = false
Expand Down Expand Up @@ -237,11 +237,20 @@ class ProcessIndicatorView: UIView {
case .tempReset:
iconLayer.contents = dimmedIconImage
trackLayer.strokeColor = UIColor.gray.cgColor
case .editing:
case .editingSelf:
iconLayer.contents = normalIconImage
trackLayer.strokeColor = UIColor.white.cgColor
iconLayer.isHidden = true
progressNumberLayer.isHidden = false
progressLayer.isHidden = false
minusProgressLayer.isHidden = false
case .editingOthers:
iconLayer.contents = normalIconImage
trackLayer.strokeColor = UIColor.white.cgColor
iconLayer.isHidden = false
progressNumberLayer.isHidden = true
progressLayer.isHidden = false
minusProgressLayer.isHidden = false
}
}
}
Expand All @@ -254,5 +263,6 @@ extension Notification.Name {
enum IndicatorStatus {
case initial
case tempReset
case editing
case editingSelf
case editingOthers
}

0 comments on commit d28e886

Please sign in to comment.