//
// © 2018-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

import UIKit

typealias SpeakerSliderDidChangeCellCallback = (SpeakerSliderTableViewCell) -> ()

class SpeakerSliderTableViewCell: UITableViewCell {

    static let reuseIdentifier = "SpeakerSliderTableViewCell"
	
	@IBOutlet private weak var sliderContent: SpeakerSliderTableViewCellContentView!
	
	var sliderDidChange: SpeakerSliderDidChangeCellCallback?
	
	var speakerName: String {
		get {
			return sliderContent.speakerName
		}
		set {
			sliderContent.speakerName = newValue
		}
	}

    var accessibilityName: String {
        get {
            return sliderContent.accessibilityName
        }
        set {
            sliderContent.accessibilityName = newValue
        }
    }

    var isTracking: Bool {
        get {
            return sliderContent.isTracking
        }
    }

    var expanded: SpeakerSliderTableViewCellContentView.ExpandedState {
        get {
            return sliderContent.expanded
        }
        set {
            sliderContent.expanded = newValue
        }
    }
	
	var volumePercent: Int {
		get {
			return sliderContent.volumePercent
		}
		set {
			sliderContent.volumePercent = newValue
		}
	}

    var enabled: Bool {
        get {
            return sliderContent.enabled
        }
        set {
            sliderContent.enabled = newValue
        }
    }

    var showPercent: Bool {
        get {
            return sliderContent.showPercent
        }
        set {
            sliderContent.showPercent = newValue
        }
    }
	
	override func awakeFromNib() {
		sliderContent.sliderDidChange = { [weak self] _ in
			guard let self = self else {
				return
			}
			if let callback = self.sliderDidChange {
				callback(self)
			}
		}
	}
}
