Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

Timer label is not visible when UICircularTimerRing is animating #171

@tomerciucran

Description

@tomerciucran

Bug Report

⚠️ Your issue will be closed if these are not filled out. ⚠️

Version

6.0.0

Overview of what you tried to do

Implement a UICircularTimerRing with a custom formatter.

What is the expected outcome?

the circle ring being animated and the timer label displaying each second as expected.

What is the actual outcome?

the label in the middle of the circle is only visible before the animation starts and after it finishes.
Could be related to the gradient changes on the last update because it was working fine on 5.1.0. Same result with or without a custom value formatter.

Post sample code or example here

If sample code can't be provided because it's too long, please provide a small example project,
where I can test, if you cannot provide either. There is not much I can do.

class ExerciseBreakCircularRingValueFormatter: UICircularRingValueFormatter {
    let totalDuration: CGFloat
    
    init(totalDuration: CGFloat) {
        self.totalDuration = totalDuration
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func string(for value: Any) -> String? {
        guard let value = value as? CGFloat else { return nil }
        let interval = totalDuration - value
        let minutes = Int(interval) / 60 % 60
        let seconds = Int(interval) % 60
        return String(format: "%02i:%02i", minutes, seconds)
    }
}

class ExerciseBreakViewController: UIViewController, Pausable {
   @IBOutlet weak var progressView: UICircularTimerRing! {
        didSet {
            progressView.font = Fonts.getFont(type: .headlineBold)
            progressView.valueFormatter = ExerciseBreakCircularRingValueFormatter(totalDuration: CGFloat(viewModel.duration.value))
        }
    }

   override func viewDidAppear(_ animated: Bool) {
      self.progressView.startTimer(to: duration) { [weak self] state in
                guard let `self` = self else { return }
                switch state {
                case .finished:
                    self.delegate?.exerciseItemDidEnd(exercise: self.viewModel)
                default: break
                }
            }
   }
}

Have you tried fixing this yourself?

This project is open source, and I'm a student with very minimal amount of time.
Please give an attempt at fixing the issue first before creating a bug report.
This saves everyone time and benefits anyone who uses the library.
Pull requests are welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions