| | |
| | | |
| | | class HomeListenMenuVC: BaseVC { |
| | | |
| | | |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | |
| | | private var repeatColors = ["#F8A169","#92CADB","#9E8ADB","#6DD1BA","#37C06E","#DEB975","#C54A59","#5DA0D3","#F0C433","#DC4827"] |
| | | private var titleItems = ["第一季","第二季","第三季","第四季"] |
| | | private var selectIndexPath:IndexPath = IndexPath(row: 0, section: 0) |
| | | |
| | | private var dataItems = Array<[ListenWeekModel]>(repeating: [], count: 4) |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | getData() |
| | | } |
| | | |
| | | |
| | | private func getData(){ |
| | | Services.weekList(quarter: selectIndexPath.row).subscribe(onNext: {result in |
| | | self.dataItems[self.selectIndexPath.row] = result.data ?? [] |
| | | self.collectionView.reloadData() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return 20 |
| | | return dataItems[selectIndexPath.row].count |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | |
| | | extension HomeListenMenuVC:UITableViewDataSource,UITableViewDelegate{ |
| | | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| | | selectIndexPath = indexPath |
| | | |
| | | if dataItems[indexPath.row].count == 0{ |
| | | getData() |
| | | } |
| | | tableView.reloadData() |
| | | } |
| | | |