Robert
4 天以前 dddaf0fa8bb2e9b77f1d5db6c11980c9e1d60acf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
//  WorldCupListRankView.swift
//  WanPai
//
//  Created by Robert on 2025/8/17.
//
 
import UIKit
import JQTools
import RxSwift
class WorldCupListRankView: UIView,JQNibView, UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSoure?.count ?? 0
    
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tabview.dequeueReusableCell(withIdentifier: "WorldCupListRankViewCellId", for: indexPath) as! WorldCupListRankViewCell
        cell.chooseBtn.isSelected = indexPath.row == selectIndex ? true : false
        cell.index = indexPath.row
        cell.selectionStyle = .none
        cell.tag = indexPath.row
        cell.titleLab.text = dataSoure?[indexPath.row].name ?? ""
               // RxSwift绑定
        cell.chooseBtn.rx.tap
                   .map { cell.tag } // 从cell的tag获取行索引
                   .subscribe(onNext: { [weak self] row in
                       self?.selectIndex = row
                       self?.selectIndex = row
                       self?.tabview.reloadData()
                   })
                   .disposed(by: disposeBag)
        return cell
    }
    
 
    @IBOutlet weak var tabBackView: UIView!
    
    @IBOutlet weak var sureAction: UIButton!
    
    private var clouse:((Int)->Void)!
    
    @IBOutlet weak var tabview: UITableView!
    
    var dataSoure: Array<GetWorldCupListFromRank>?
    
    var disposeBag = DisposeBag()
    
    var selectIndex = 0
    
    
    override  func awakeFromNib() {
        super.awakeFromNib()
        alpha = 0
        tabview.delegate = self
        tabview.dataSource = self
        tabview.separatorStyle = .none
        tabview.rowHeight = 44
//        tabview.register(WorldCupListRankViewCell.self, forCellReuseIdentifier: "WorldCupListRankViewCellId")
        tabview.register(UINib(nibName: "WorldCupListRankViewCell", bundle: nil), forCellReuseIdentifier: "WorldCupListRankViewCellId")
        sureAction.layer.masksToBounds = true
        sureAction.layer.cornerRadius = 5
       
    }
    static func show(arr:[GetWorldCupListFromRank]?, clouse:@escaping (Int) -> Void){
        
        let alertView = WorldCupListRankView.jq_loadNibView()
        alertView.clouse = clouse
        alertView.frame = sceneDelegate?.window?.frame ?? .zero
        sceneDelegate?.window?.addSubview(alertView)
        UIView.animate(withDuration: 0.4) {
            alertView.layoutIfNeeded()
            alertView.alpha = 1
        } completion: { _ in
 
        }
        alertView.dataSoure = arr
        alertView.tabview.reloadData()
    }
    
    @IBAction func sureAction(_ sender: Any) {
        if dataSoure?.count == 0 {
            return
        }
        self.clouse(Int(dataSoure?[self.selectIndex].id ?? "0") ?? 0)
    }
    
}