// // MPPositive_AddSongsViewController.swift // relax.offline.mp3.music // // Created by Mr.Zhou on 2024/9/24. // import UIKit class MPPositive_AddSongsViewController: MPPositive_BaseViewController { //分页栏View lazy var segmentView:JXSegmentedView = { var jxSegmentView = JXSegmentedView() jxSegmentView.backgroundColor = .init(hex: "1A1A1A") return jxSegmentView }() //数据源 private lazy var dataSource:JXSegmentedTitleDataSource = { var dataSource = JXSegmentedTitleDataSource() dataSource.titles = ["Love Songs".localizableString(), "Offline Songs".localizableString()] //标题未选中状态 dataSource.titleNormalColor = .init(hex: "#666666") dataSource.titleNormalFont = .systemFont(ofSize: 16*width, weight: .regular) //标题选中状态 dataSource.titleSelectedColor = .init(hex: "#80F988") dataSource.titleSelectedFont = .systemFont(ofSize: 16*width, weight: .bold) //是否颜色过度 dataSource.isTitleColorGradientEnabled = true dataSource.isSelectedAnimable = true dataSource.isItemTransitionEnabled = true return dataSource }() //指示器 private lazy var indicator:JXSegmentedIndicatorLineView = { let indicator = JXSegmentedIndicatorLineView() indicator.indicatorWidth = 16*width indicator.indicatorHeight = 3*width indicator.indicatorCornerRadius = 1.5*width indicator.indicatorColor = .init(hex: "#80F988") indicator.indicatorPosition = .bottom return indicator }() //分页内容承载框 fileprivate lazy var listContainerView:JXSegmentedListContainerView = { let listContainerView = JXSegmentedListContainerView(dataSource: self) listContainerView.backgroundColor = .clear return listContainerView }() var list:MPPositive_CustomPlayListModel! init(playList:MPPositive_CustomPlayListModel) { super.init(nibName: nil, bundle: nil) self.list = playList } required init?(coder: NSCoder) { super.init(coder: coder) } override func viewDidLoad() { super.viewDidLoad() setTitle("Add Songs") setPopBtn() configure() } private func configure() { //添加分页 segmentView.indicators = [indicator] segmentView.dataSource = dataSource view.addSubview(segmentView) segmentView.snp.makeConstraints { make in make.top.equalTo(navView.snp.bottom) make.left.right.equalToSuperview() make.height.equalTo(60*width) } view.addSubview(listContainerView) listContainerView.snp.makeConstraints { (make) in make.left.right.bottom.equalToSuperview().priority(999) make.top.equalTo(segmentView.snp.bottom).priority(999) } segmentView.contentScrollView = listContainerView.scrollView segmentView.listContainer = listContainerView } } //MARK: - JXSegmentedTitleDataSource extension MPPositive_AddSongsViewController: JXSegmentedListContainerViewDataSource, JXSegmentedViewDelegate { func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int { return dataSource.titles.count } func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> any JXSegmentedListContainerViewListDelegate { let showView:MPPositive_AddSongsShowView = .init(frame: listContainerView.frame, playList: list) showView.selectedIndex = index return showView } }