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

import UIKit

class NowPlayingSlider: UISlider {
    
    private let trackHeight: CGFloat = 7.0
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        setThumbImage(UIImage(named: "nowplaying-seekbar"), for: .normal)
        setThumbImage(UIImage(named: "nowplaying-seekbar-pressed"), for: .highlighted)
        setThumbImage(UIImage(named: "nowplaying-seekbar-pressed"), for: .selected)
        
        let minImage = UIImage.image(color: UIColor(red: 0, green: 177/255.0, blue: 217/255.0, alpha: 1.0),
                                     size: CGSize(width: 1.0, height: trackHeight))
        setMinimumTrackImage(minImage, for: .normal)
        
        let maxImage = UIImage.image(color: UIColor(white: 225/255.0, alpha: 1.0),
                                     size: CGSize(width: 1.0, height: trackHeight))
        setMaximumTrackImage(maxImage, for: .normal)
    }

    override func trackRect(forBounds bounds: CGRect) -> CGRect {
        let superRect = super.trackRect(forBounds: bounds)
        
        var customBounds = superRect
        // Move the track to the top of the view and make it wider.
        customBounds.origin.y = 10
        customBounds.size.height = trackHeight

        return customBounds
    }
}
