Music_Player3/relax.offline.mp3.music/MP/MPPositive/ViewControllers/Center(个人曲库页)/MPPositive_AddSongsViewController.swift
2024-09-26 14:07:13 +08:00

97 lines
3.6 KiB
Swift

//
// 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
}
}