//
|
// CourseInfoVC.swift
|
// WanPai
|
//
|
// Created by 无故事王国 on 2023/6/21.
|
//
|
|
import UIKit
|
import JQTools
|
import SPPageMenu
|
import FFPage
|
import QMUIKit
|
|
class CourseInfoVC: BaseVC {
|
|
private struct MentalInfo {
|
var img:UIImage!
|
var t1:String!
|
var t2:String!
|
}
|
|
@IBOutlet weak var scrollView: CourseInfoScrollView!
|
@IBOutlet weak var view_container: UIView!
|
@IBOutlet weak var img_header: UIImageView!
|
@IBOutlet weak var label_stu_hei: UILabel!
|
@IBOutlet weak var label_stu_wei: UILabel!
|
@IBOutlet weak var label_stu_BMI: UILabel!
|
@IBOutlet weak var view_menu: UIView!
|
@IBOutlet weak var btn_record: UIButton!
|
@IBOutlet weak var view_schedule: UIView!
|
@IBOutlet weak var tableView: UITableView!
|
@IBOutlet weak var mentalCollectionView: UICollectionView!
|
@IBOutlet weak var cons_mentalViewHei: NSLayoutConstraint!
|
@IBOutlet weak var exerciseCollectionView: UICollectionView!
|
|
private var mentals = [MentalInfo]()
|
|
private var pageMenu:SPPageMenu = {
|
let pageMenu = SPPageMenu(frame: .zero, trackerStyle: .line)
|
// 追踪线
|
pageMenu.trackerWidth = 56
|
pageMenu.setTrackerHeight(3, cornerRadius: 1.5)
|
pageMenu.tracker.backgroundColor = .clear
|
pageMenu.trackerFollowingMode = .always
|
pageMenu.contentInset = UIEdgeInsets(top: 0, left: 19, bottom: 0, right: 19)
|
|
// 分割线
|
pageMenu.dividingLine.backgroundColor = .clear
|
pageMenu.dividingLineHeight = 1
|
|
// item
|
pageMenu.spacing = 27.0
|
pageMenu.permutationWay = .scrollAdaptContent
|
pageMenu.setItems(["荷兰足球队","全科体育课"], selectedItemIndex: 0)
|
|
// 字体
|
pageMenu.selectedItemTitleFont = UIFont.systemFont(ofSize: 18, weight: .medium)
|
pageMenu.unSelectedItemTitleFont = UIFont.systemFont(ofSize: 18,weight: .medium)
|
// 颜色
|
pageMenu.selectedItemTitleColor = UIColor(hexStr: "#6CC366")
|
pageMenu.unSelectedItemTitleColor = UIColor(hexStr: "#A4A4A4")
|
|
return pageMenu
|
}()
|
|
private lazy var leftBtn:QMUIButton = {
|
let btn = QMUIButton(type: .custom)
|
btn.setTitle("添加学员", for: .normal)
|
btn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
|
btn.setTitleColor(.white, for: .normal)
|
btn.setImage(UIImage(named: "btn_add_shadow"), for: .normal)
|
btn.imagePosition = .left
|
btn.spacingBetweenImageAndTitle = 0
|
btn.imageEdgeInsets = UIEdgeInsets(top: 2, left: 0, bottom: 0, right: 0)
|
btn.addTarget(self, action: #selector(addStudentAction), for: .touchUpInside)
|
return btn
|
}()
|
|
lazy var pageViewController:FFPageViewController = {
|
let pageVC = FFPageViewController()
|
pageVC.view.backgroundColor = .clear
|
pageVC.scrollview.backgroundColor = .clear
|
|
pageVC.scrollview.bounces = false
|
return pageVC
|
}()
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
label_stu_hei.attributedText = setAttribute(t1: "0", t2: "cm")
|
label_stu_wei.attributedText = setAttribute(t1: "0", t2: "kg")
|
label_stu_BMI.attributedText = setAttribute(t1: "0.0", t2: "正常")
|
}
|
|
|
override func setUI() {
|
scrollView.contentInset = UIEdgeInsets( top: JQ_ScreenW * 0.6794 - JQ_NavBarHeight, left: 0, bottom: 0, right: 0)
|
scrollView.delegate = self
|
scrollView.bringSubviewToFront(img_header)
|
|
pageMenu.frame = CGRect(origin: .zero, size: CGSize(width: JQ_ScreenW, height: 25))
|
pageMenu.delegate = self
|
view_menu.addSubview(pageMenu)
|
scrollView.bounces = false
|
scrollView.contentInsetAdjustmentBehavior = .never
|
|
let attribute = AttributedStringbuilder()
|
attribute.add(string: "预约记录", withFont: UIFont.systemFont(ofSize: 14), withColor: Def_ThemeColor)
|
attribute.underLine(color: Def_ThemeColor)
|
btn_record.titleLabel?.attributedText = attribute.mutableAttributedString
|
|
|
view_schedule.addSubview(pageViewController.view)
|
addChild(pageViewController)
|
pageViewController.delegate = self
|
view_schedule.insertSubview(pageViewController.view, at: 0)
|
pageViewController.didMove(toParent: self)
|
pageViewController.view.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 50)
|
|
tableView.delegate = self
|
tableView.dataSource = self
|
tableView.isScrollEnabled = false
|
tableView.separatorStyle = .none
|
tableView.register(UINib(nibName: "CourseBookingTCell", bundle: nil), forCellReuseIdentifier: "_CourseBookingTCell")
|
|
mentalCollectionView.delegate = self
|
mentalCollectionView.dataSource = self
|
mentalCollectionView.contentInset = UIEdgeInsets(top: 0, left: 58, bottom: 0, right: 58)
|
mentalCollectionView.tag = 1000
|
mentalCollectionView.isScrollEnabled = false
|
mentalCollectionView.register(UINib(nibName: "StudentMedalCCell", bundle: nil), forCellWithReuseIdentifier: "_StudentMedalCCell")
|
|
exerciseCollectionView.delegate = self
|
exerciseCollectionView.dataSource = self
|
exerciseCollectionView.tag = 1001
|
exerciseCollectionView.register(UINib(nibName: "StudentVideoCCell", bundle: nil), forCellWithReuseIdentifier: "_StudentVideoCCell")
|
|
|
mentals.append(MentalInfo(img: UIImage(named: "icon_coupon_1"), t1: "COURSE", t2: "俱乐部之星"))
|
mentals.append(MentalInfo(img: UIImage(named: "icon_coupon_2"), t1: "EVENTS", t2: "运动大人"))
|
mentals.append(MentalInfo(img: UIImage(named: "icon_coupon_3"), t1: "ON_LINE", t2: "社区之王"))
|
mentals.append(MentalInfo(img: UIImage(named: "icon_coupon_4"), t1: "APPOINTMENT", t2: "深度玩家"))
|
mentals.append(MentalInfo(img: UIImage(named: "icon_coupon_5"), t1: "EVENTS", t2: "月度冠军"))
|
mentals.append(MentalInfo(img: UIImage(named: "icon_coupon_6"), t1: "MORE", t2: "更多"))
|
|
cons_mentalViewHei.constant = ceil(Double(mentals.count) / 3) * 91 + floor(Double(mentals.count) / 3) * 30
|
|
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftBtn)
|
|
}
|
|
private func setAttribute(t1:String,t2:String)->NSMutableAttributedString{
|
let color:UIColor = UIColor(hexStr: "#2F5264")
|
let a1 = AttributedStringbuilder()
|
a1.add(string: t1, withFont: UIFont.systemFont(ofSize: 26), withColor: color)
|
.add(string: t2, withFont: UIFont.systemFont(ofSize: 16), withColor: color)
|
return a1.mutableAttributedString
|
}
|
|
override func viewDidLayoutSubviews() {
|
super.viewDidLayoutSubviews()
|
view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 42)
|
}
|
|
@objc func addStudentAction() {
|
let vc = AddStudentVC()
|
push(vc: vc)
|
}
|
|
@IBAction func exchangeAction(_ sender: UIButton) {
|
let vc = StudentExchangeVC()
|
push(vc: vc)
|
}
|
|
@IBAction func reportAction(_ sender: UIButton) {
|
let vc = StudentReportVC()
|
push(vc: vc)
|
}
|
|
|
@IBAction func detailAction(_ sender: UIButton) {
|
let vc = StudentCourseDetailVC()
|
push(vc: vc)
|
}
|
|
@IBAction func bookingRecordAction(_ sender: UIButton) {
|
let vc = CourseBookingListVC()
|
push(vc: vc)
|
}
|
|
|
@IBAction func remarkAction(_ sender: UIButton) {
|
let vc = StudentRemarkListVC()
|
push(vc: vc)
|
}
|
|
override var preferredStatusBarStyle: UIStatusBarStyle{
|
return .darkContent
|
}
|
|
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
let offsetX = min(1,max(0,-(scrollView.contentOffset.y / 177.0)))
|
leftBtn.alpha = offsetX
|
}
|
}
|
|
extension CourseInfoVC:UITableViewDelegate{
|
|
}
|
|
extension CourseInfoVC:UITableViewDataSource{
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_CourseBookingTCell") as! CourseBookingTCell
|
|
return cell
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return 1
|
}
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
return 70
|
}
|
}
|
|
|
extension CourseInfoVC:UICollectionViewDelegate{
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
if collectionView.tag == 1000{
|
let vc = StudentMentalListVC()
|
push(vc: vc)
|
}else{
|
let vc = CourseVideoDetailVC()
|
vc.title = "课后练习"
|
push(vc: vc)
|
}
|
}
|
}
|
|
extension CourseInfoVC:UICollectionViewDataSource{
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return mentals.count
|
}
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
if collectionView.tag == 1000{
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_StudentMedalCCell", for: indexPath) as! StudentMedalCCell
|
cell.img.image = mentals[indexPath.row].img
|
cell.t1.text = mentals[indexPath.row].t1
|
cell.t2.text = mentals[indexPath.row].t2
|
return cell
|
} else{
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_StudentVideoCCell", for: indexPath) as! StudentVideoCCell
|
return cell
|
}
|
}
|
}
|
|
extension CourseInfoVC:UICollectionViewDelegateFlowLayout{
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
if collectionView.tag == 1000{
|
return 30
|
}else {
|
return 12
|
}
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
if collectionView.tag == 1000{
|
return 30
|
}else {
|
return 0
|
}
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
if collectionView.tag == 1000{
|
let CellW = (JQ_ScreenW - 116 - 62 * 2) / 3
|
return CGSize(width: CellW, height: 91)
|
}else {
|
let CellW = (JQ_ScreenW - 44 - 13) / 2
|
return CGSize(width: CellW, height: 166)
|
}
|
}
|
}
|
|
extension CourseInfoVC:SPPageMenuDelegate{
|
func pageMenu(_ pageMenu: SPPageMenu, itemSelectedAt index: Int) {
|
|
}
|
}
|
|
|
extension CourseInfoVC:FFPageViewControllerDelegate{
|
|
func pageViewController(_ pageViewController: FFPageViewController, currentPageChanged currentPage: Int) {
|
|
}
|
|
func totalPagesOfpageViewController(_ pageViewConteoller: FFPageViewController) -> UInt {
|
return 10
|
}
|
|
func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController {
|
|
return CourseInfoScheduleVC()
|
}
|
}
|
|
public class CourseInfoScrollView:UIScrollView{
|
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
for subView in subviews{
|
let p = subView.convert(point, to: self)
|
let hitTestView = subView.hitTest(p, with: event)
|
return hitTestView
|
}
|
return nil
|
}
|
}
|