   
   // MARK: Animation State
 
-  func updateOnState(isOn: Bool, animated: Bool) {
+  func updateOnState(isOn: Bool, animated: Bool, shouldFireHaptics: Bool) {
     _isOn = isOn
     var startProgress = isOn ? onStartProgress : offStartProgress
     var endProgress = isOn ? onEndProgress : offEndProgress

    self.hapticGenerator = NullHapticGenerator()
    #endif
    super.init(animation: animation)
    updateOnState(isOn: _isOn, animated: false)
    self.accessibilityTraits = UIAccessibilityTraits.button
  }
  

      animationView.currentProgress = finalProgress
      return
    }

    if shouldFireHaptics {
      self.hapticGenerator.generateImpact()
    }

    animationView.play(fromProgress: startProgress, toProgress: endProgress, loopMode: LottieLoopMode.playOnce) { (finished) in
      if finished == true {
        self.animationView.currentProgress = finalProgress
      }
    }

    updateAccessibilityLabel()
  }
  
  public override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
    super.endTracking(touch, with: event)
    updateOnState(isOn: !_isOn, animated: true, shouldFireHaptics: true)
    sendActions(for: .valueChanged)
  }
  
  public override func animationDidSet() {
    updateOnState(isOn: _isOn, animated: true, shouldFireHaptics: false)
  }

  // MARK: Private

  private func updateAccessibilityLabel() {
    accessibilityValue = _isOn ? NSLocalizedString("On", comment: "On") : NSLocalizedString("Off", comment: "Off")
  }
  
}
