//
//  SpeakEleProgressViewCtr.swift
//  SpeakEasyLearnEnglish
//
//  Created by mac on 2025/7/15.
//

import UIKit

class SpeakEleProgressViewCtr: SpeakEleBaseViewCtr {
    
    lazy var tableView: UITableView = {
        let tV = UITableView()
        tV.tableHeaderView = headerV
        tV.backgroundColor = .clear
        tV.separatorStyle = .none
        tV.showsVerticalScrollIndicator = false
        tV.register(SpeakEleDailyCell.self, forCellReuseIdentifier: SpeakEleDailyCell.className())
        tV.register(SpeakEleChooseCell.self, forCellReuseIdentifier: SpeakEleChooseCell.className())
        tV.register(SpeakEleLtimeCell.self, forCellReuseIdentifier: SpeakEleLtimeCell.className())
        tV.register(SpeakEleReviewCell.self, forCellReuseIdentifier: SpeakEleReviewCell.className())
        tV.register(SpeakEleOtherCell.self, forCellReuseIdentifier: SpeakEleOtherCell.className())
        tV.delegate = self
        tV.dataSource = self
        return tV
    }()
    
    let headerV = SpeakEleProgressHeaderView(frame: CGRect(x: 0, y: 0, width: Dev.screenW, height: 40))
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.init(with: "#F6F7F9")
        makeUI()
    }
    
    func makeUI() {
        self.view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalTo(statusBarHeight + 20)
            make.left.right.equalTo(0)
            make.bottom.equalTo(-tabbarHeight)
        }
    }
}

extension SpeakEleProgressViewCtr: UITableViewDelegate,UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }
    
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if indexPath.row == 0 {
            let cell = tableView.dequeueReusableCell(withIdentifier: SpeakEleDailyCell.className(), for: indexPath) as! SpeakEleDailyCell
            return cell
        } else if indexPath.row == 1 {
            let cell = tableView.dequeueReusableCell(withIdentifier: SpeakEleChooseCell.className(), for: indexPath) as! SpeakEleChooseCell
            return cell
        }
        
        let cell = tableView.dequeueReusableCell(withIdentifier: SpeakEleChooseCell.className(), for: indexPath) as! SpeakEleChooseCell
        return cell
    }
    
    
}
