CNLiveMineEarnListViewController.swift 3.06 KB
//
//  CNLiveMineEarnListViewController.swift
//  metaCode
//
//  Created by open on 2023/6/28.
//

import Foundation
import JXPagingView

enum MineEarnShowType {
    case record //积分记录
    case balance//余额记录
}

typealias CallBack = (_ scrollView: UIScrollView) -> Void
class CNLiveMineEarnListViewController: CNLiveBaseViewController, JXPagingViewListViewDelegate, UITableViewDelegate, UITableViewDataSource {
    
    
    let kMIneBodyFiveViewCellIdentifier = "kMIneBodyFiveViewCellIdentifier"
    lazy var tableView: UITableView = {
        let tableView = UITableView.init(frame: .zero, style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.backgroundColor = .clear
        tableView.separatorStyle = .none
        tableView.showsVerticalScrollIndicator = false
        tableView.showsHorizontalScrollIndicator = false
        tableView.register(MIneBodyFiveViewCell.self, forCellReuseIdentifier: kMIneBodyFiveViewCellIdentifier)
        let footerView = UIView(frame: CGRect(x: 0, y: 0, width: KSreenWidth - 40, height: 10))
        footerView.clipsToBounds = true
        footerView.backgroundColor = .white
        footerView.addCorner(conrners: [.bottomLeft,.bottomRight], radius: 5)
        tableView.tableFooterView = footerView
        return tableView
    }()
    
    var _callBack: CallBack!
    var _show_type : MineEarnShowType!
    init(show_type: MineEarnShowType) {
        super.init(nibName: nil, bundle: nil)
        _show_type = show_type
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(20)
            make.right.equalToSuperview().offset(-20)
        }
    }
}
extension CNLiveMineEarnListViewController {
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 6
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: kMIneBodyFiveViewCellIdentifier) as? MIneBodyFiveViewCell else {
            return MIneBodyFiveViewCell()
        }
        cell.setupWithDataSource(isLast: indexPath.row == 5)
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 70
    }
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        _callBack(scrollView)
    }
}

extension CNLiveMineEarnListViewController {
    
    func listView() -> UIView {
        return view
    }
    
    func listScrollView() -> UIScrollView {
        return tableView
    }
    
    func listViewDidScrollCallback(callback: @escaping (UIScrollView) -> ()) {
        _callBack = callback
    }
}