| | |
| | | // |
| | | |
| | | import UIKit |
| | | import RxRelay |
| | | import RxSwift |
| | | |
| | | enum GamesSubType:Int{ |
| | | case all = -1 |
| | |
| | | case online = 1 |
| | | } |
| | | |
| | | class GamesOffLineViewModel:RefreshModel<GameListModel>{ |
| | | let spaceId = BehaviorRelay<String>(value: "") |
| | | let sutuId = BehaviorRelay<String>(value: "") |
| | | |
| | | override func api() -> (Observable<BaseResponse<[GameListModel]>>)? { |
| | | return Services.game_gameList(spaceId: spaceId.value, sutuId: sutuId.value) |
| | | } |
| | | } |
| | | |
| | | class GamesSubListVC: BaseVC { |
| | | private var type:GamesSubType! |
| | | private var model:QRCodeModel! |
| | | |
| | | private let offLineViewModel = GamesOffLineViewModel() |
| | | |
| | | private var tableView:UITableView! |
| | | |
| | | init(type:GamesSubType) { |
| | | init(type:GamesSubType,model:QRCodeModel) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.type = type |
| | | self.model = model |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | if type == .offline{ |
| | | offLineViewModel.spaceId.accept(model.space_id!) |
| | | offLineViewModel.sutuId.accept(model.sutu_id!) |
| | | offLineViewModel.configure(tableView, needMore: false) |
| | | offLineViewModel.beginRefresh() |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | extension GamesSubListVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_GamesTCell") as! GamesTCell |
| | | if type == .offline{ |
| | | cell.gameListModel = offLineViewModel.dataSource.value[indexPath.row] |
| | | } |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| | | return 212 |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return 5 |
| | | return offLineViewModel.dataSource.value.count |
| | | } |
| | | } |