2021-12-13 23:06:14 +03:00
|
|
|
// Copyright © 2021 Tokenary. All rights reserved.
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
2021-12-14 00:10:45 +03:00
|
|
|
protocol GasPriceSliderDelegate: AnyObject {
|
|
|
|
|
|
|
|
func sliderValueChanged(value: Double)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-12-13 23:06:14 +03:00
|
|
|
class GasPriceSliderTableViewCell: UITableViewCell {
|
|
|
|
|
2021-12-14 00:10:45 +03:00
|
|
|
@IBOutlet weak var slowSpeedLabel: UILabel!
|
|
|
|
@IBOutlet weak var fastSpeedLabel: UILabel!
|
|
|
|
private weak var sliderDelegate: GasPriceSliderDelegate?
|
2021-12-13 23:06:14 +03:00
|
|
|
@IBOutlet weak var slider: UISlider!
|
|
|
|
|
|
|
|
@IBAction func sliderValueChanged(_ sender: Any) {
|
2021-12-14 00:10:45 +03:00
|
|
|
sliderDelegate?.sliderValueChanged(value: Double(slider.value))
|
|
|
|
}
|
|
|
|
|
|
|
|
func setup(value: Double?, isEnabled: Bool, delegate: GasPriceSliderDelegate) {
|
|
|
|
sliderDelegate = delegate
|
|
|
|
update(value: value, isEnabled: isEnabled)
|
|
|
|
}
|
|
|
|
|
|
|
|
func update(value: Double?, isEnabled: Bool) {
|
|
|
|
slider.isEnabled = isEnabled
|
|
|
|
slowSpeedLabel.alpha = isEnabled ? 1 : 0.5
|
|
|
|
fastSpeedLabel.alpha = isEnabled ? 1 : 0.5
|
|
|
|
if let value = value {
|
|
|
|
slider.value = Float(value)
|
|
|
|
}
|
2021-12-13 23:06:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|