//
|
// CourseMenuVC.swift
|
// XQMuse
|
//
|
// Created by 无故事王国 on 2024/8/16.
|
//
|
|
import UIKit
|
import JQTools
|
|
class CourseMenuVC: BaseVC {
|
|
private var tableView:UITableView!
|
private var collectionView:UICollectionView!
|
private var titleItems = [TitleItem]()
|
private var selectIndex:Int = 0
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "全部课程"
|
|
titleItems.append(TitleItem(title: "会员专区"))
|
titleItems.append(TitleItem(title: "免费专区"))
|
titleItems.append(TitleItem(title: "付费专区"))
|
titleItems.append(TitleItem(title: "线下课程"))
|
titleItems.append(TitleItem(title: "水晶疗愈"))
|
}
|
|
override func setUI() {
|
super.setUI()
|
view.backgroundColor = UIColor.white
|
|
tableView = UITableView(frame: .zero, style: .plain)
|
tableView.backgroundColor = UIColor(hexString: "#f6f6f6")
|
tableView.separatorStyle = .none
|
tableView.isScrollEnabled = false
|
tableView.register(UINib(nibName: "MenuListTCell", bundle: nil), forCellReuseIdentifier: "_MenuListTCell")
|
tableView.delegate = self
|
tableView.dataSource = self
|
view.addSubview(tableView)
|
tableView.snp.makeConstraints { make in
|
make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top)
|
make.left.bottom.equalToSuperview()
|
make.width.equalTo(JQ_ScreenW * 0.2487)
|
}
|
|
let layout = UICollectionViewFlowLayout()
|
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
collectionView.delegate = self
|
collectionView.dataSource = self
|
collectionView.showsVerticalScrollIndicator = false
|
collectionView.register(UINib(nibName: "HomeRelaxBanner_2_CCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxBanner_2_CCell")
|
collectionView.contentInset = UIEdgeInsets(top: 34, left: 21, bottom: 0, right: 21)
|
view.addSubview(collectionView)
|
collectionView.snp.makeConstraints { make in
|
make.left.equalTo(tableView.snp.right)
|
make.right.equalToSuperview()
|
make.top.bottom.equalTo(tableView)
|
}
|
}
|
}
|
|
extension CourseMenuVC:UITableViewDelegate & UITableViewDataSource{
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
selectIndex = indexPath.row
|
tableView.reloadData()
|
}
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_MenuListTCell", for: indexPath) as! MenuListTCell
|
cell.backgroundColor = .clear
|
cell.view_line.isHidden = indexPath.row != selectIndex
|
cell.label_title.text = titleItems[indexPath.row].title
|
cell.label_title.textColor = indexPath.row == selectIndex ? UIColor(hexString: "#8AAE65") : UIColor(hexString: "#5C5C5C")
|
return cell
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return titleItems.count
|
}
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
return 53
|
}
|
}
|
|
extension CourseMenuVC:UICollectionViewDelegate & UICollectionViewDataSource{
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
if indexPath.row == 0{
|
let vc = CourseDetialVC(courseSytle: .style1)
|
push(vc: vc)
|
}else{
|
let vc = CourseDetialVC(courseSytle: .style2)
|
push(vc: vc)
|
}
|
}
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_CCell", for: indexPath) as! HomeRelaxBanner_2_CCell
|
cell.backgroundColor = .jq_randomColor
|
return cell
|
}
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return 2
|
}
|
}
|
|
extension CourseMenuVC:UICollectionViewDelegateFlowLayout{
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
return 10
|
}
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
return 10
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
let w = ((JQ_ScreenW - 70) * (1 - 0.2487)) / 2
|
return CGSize(width: w, height: w * 1.313)
|
}
|
}
|