//
//  Cell_HomeOrderListBottomAction.swift
//  VattiCSS
//
//  Created by Jan on 2023/8/23.
//

import UIKit

class Cell_HomeOrderListBottomAction: UITableViewCell {
    @IBOutlet weak var btn_action: UIButton!
    @IBOutlet weak var bgView: UIView!
    var callBack: TCRowCallBack?
    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = UIColor(hexString: "f9f9f9")

        let image = UIImage(named: "icon_blue_jianbian")
        bgView.layer.contents = image?.cgImage
        
        bgView.makeLayerRadius(value: 5,type: [.layerMinXMaxYCorner,.layerMaxXMaxYCorner])
        
        
//        self.bgView.layer.cornerRadius = 0
//        self.bgView.alpha = 1
//        // fillCode
//        let bgLayer1 = CALayer()
//        bgLayer1.frame = bgView.bounds
//        bgLayer1.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1.00).cgColor
//        self.bgView.layer.addSublayer(bgLayer1)
//        
//        let bglayer2 = CAGradientLayer()
//        bglayer2.colors = [UIColor(red: 220/255, green: 231/255, blue: 255/255, alpha: 1.00).cgColor, UIColor(red: 0.28, green: 0.55, blue: 1, alpha: 0.00).cgColor]
//        bglayer2.locations = [0, 1]
//        bglayer2.frame = bgView.bounds
//        
//        self.bgView.layer.addSublayer(bglayer2)
//        
//        bglayer2.startPoint = CGPoint(x: 1.00, y: 0.50)
//        bglayer2.endPoint = CGPoint(x: 0.00, y: 0.50)

    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    @IBAction func righrAction(_ sender: UIButton) {
        callBack?(sender.titleLabel?.text ?? "")
    }
    
    
}



extension Cell_HomeOrderListBottomAction: TCCell_RowCellUpdateProtocol {

    typealias DataSource = (HomeModel.HomeOrder,Int)
    typealias ConfigModel = TCFormCellConfigModel
    
    func row_update(callBack block: TCRowCallBack?) {
        callBack = block
    }
    
    func row_update(config data: TCFormCellConfigModel) {
      
    }
    
    func row_update(dataSource data: (HomeModel.HomeOrder,Int)) {
        switch data.1 {
        case 1:
            btn_action.setTitle("确认接单".languageString(), for: .normal)
            btn_action.isHidden = false
        case 3,41:
            btn_action.setTitle("派工".languageString(), for: .normal)
            btn_action.isHidden = false
        default:
            btn_action.isHidden = true
            break
        }
    }
    
}

