|
|
|
@ -18,9 +18,14 @@ class PersonalViewController: ViewController {
|
|
|
|
|
let layout = UICollectionViewCompositionalLayout { (sectionIndex, environment) -> NSCollectionLayoutSection? in
|
|
|
|
|
let viewModel = self.viewModel as? PersonalViewModel
|
|
|
|
|
|
|
|
|
|
if viewModel?.personInfoLikeType.value == .audio {
|
|
|
|
|
return self.createSingleColumnSection()
|
|
|
|
|
} else {
|
|
|
|
|
return self.createDoubleColumnSection()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self.createSingleColumnSection()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -84,13 +89,13 @@ class PersonalViewController: ViewController {
|
|
|
|
|
view.addSubview(noDataView)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectionView.rx.refresh.subscribe { refreshType in
|
|
|
|
|
collectionView.rx.refresh.subscribe { [weak self] refreshType in
|
|
|
|
|
|
|
|
|
|
switch refreshType.element {
|
|
|
|
|
case .refresh:
|
|
|
|
|
self.headerRefreshTrigger.onNext(())
|
|
|
|
|
self?.headerRefreshTrigger.onNext(())
|
|
|
|
|
case .loadMore where AuthManager.shared.token?.isValid == true:
|
|
|
|
|
self.footerRefreshTrigger.onNext(())
|
|
|
|
|
self?.footerRefreshTrigger.onNext(())
|
|
|
|
|
|
|
|
|
|
default: break
|
|
|
|
|
}
|
|
|
|
@ -98,6 +103,8 @@ class PersonalViewController: ViewController {
|
|
|
|
|
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -152,6 +159,16 @@ class PersonalViewController: ViewController {
|
|
|
|
|
let resuableView: PersonalHeaderView = collectionView.dequeueReusableSupplementaryView(ofKind: "UICollectionElementKindSectionHeader", withReuseIdentifier: "PersonalHeaderView", for: indexPath) as! PersonalHeaderView
|
|
|
|
|
self.personalHeaderView = resuableView
|
|
|
|
|
|
|
|
|
|
personalHeaderView?.segmentControl.titleBtnOnClick = { [weak self] (label, index) in
|
|
|
|
|
if index == 0 {
|
|
|
|
|
self?.personInfoLikeType.accept(.audio)
|
|
|
|
|
} else {
|
|
|
|
|
self?.personInfoLikeType.accept(.journal)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let section = dataSource.sectionModels.first.value
|
|
|
|
|
// resuableView.user = viewModel.us
|
|
|
|
|
|
|
|
|
@ -175,12 +192,12 @@ class PersonalViewController: ViewController {
|
|
|
|
|
// }.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resuableView.followingButton.rx.tap.subscribe { _ in
|
|
|
|
|
resuableView.followingButton.rx.tap.subscribe { [weak self] _ in
|
|
|
|
|
viewModel.followingButtonTrigger.accept(())
|
|
|
|
|
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
resuableView.messageButton.rx.tap.subscribe { _ in
|
|
|
|
|
resuableView.messageButton.rx.tap.subscribe { [weak self] _ in
|
|
|
|
|
viewModel.messageButtonTrigger.accept(())
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
@ -193,13 +210,12 @@ class PersonalViewController: ViewController {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
// let collectionViewDataSource = person.collectionViewDataSource()
|
|
|
|
|
//
|
|
|
|
|
// output.items.bind(to: collectionView.rx.items(dataSource: dataSource)).disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
output.items.bind(to: collectionView.rx.items(dataSource: dataSource)).disposed(by: rx.disposeBag)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
output.user.subscribe { user in
|
|
|
|
|
self.personalHeaderView?.user = user
|
|
|
|
|
output.user.subscribe { [weak self] user in
|
|
|
|
|
self?.personalHeaderView?.user = user
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -285,188 +301,12 @@ extension PersonalViewController {
|
|
|
|
|
let header = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: UICollectionView.elementKindSectionHeader, alignment: .top)
|
|
|
|
|
doubleColumnSection.boundarySupplementaryItems = [header]
|
|
|
|
|
|
|
|
|
|
doubleColumnSection.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 18, bottom: 0, trailing: 18)
|
|
|
|
|
|
|
|
|
|
return doubleColumnSection
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extension PersonalViewController {
|
|
|
|
|
//TODO
|
|
|
|
|
// static func tableViewDataSource(_ buttonTapHandler: @escaping (UITableViewCell, AudioTrack) -> Void) -> RxTableViewSectionedReloadDataSource<JournalSection> {
|
|
|
|
|
// return RxTableViewSectionedReloadDataSource<JournalSection>(
|
|
|
|
|
// configureCell: { dataSource, tableView, indexPath, item in
|
|
|
|
|
// let cell: SongViewCell = tableView.dequeueReusableCell(withIdentifier: "SongViewCell", for: indexPath) as! SongViewCell
|
|
|
|
|
//
|
|
|
|
|
//// cell.audioTrack = item
|
|
|
|
|
//
|
|
|
|
|
// cell.buttonTapCallback = {audioTrack in
|
|
|
|
|
// buttonTapHandler(cell, audioTrack)
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return cell
|
|
|
|
|
// }
|
|
|
|
|
// )
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extension PersonalViewController {
|
|
|
|
|
|
|
|
|
|
// static func collectionViewDataSource() -> RxCollectionViewSectionedReloadDataSource<MusicStyleSection> {
|
|
|
|
|
// return RxCollectionViewSectionedReloadDataSource<MusicStyleSection>(
|
|
|
|
|
// configureCell: { dataSource, collectionView, indexPath, item in
|
|
|
|
|
// // 配置和返回 cell
|
|
|
|
|
// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "JournalViewCell", for: indexPath) as! JournalViewCell
|
|
|
|
|
// // 配置 cell
|
|
|
|
|
// cell.titleLabel.text = item.title
|
|
|
|
|
// cell.volLabel.text = item.subTitle
|
|
|
|
|
//
|
|
|
|
|
// return cell
|
|
|
|
|
// }
|
|
|
|
|
// )
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PersonalView: UIView {
|
|
|
|
|
lazy var segmentControl: ScrollSegmentView = {
|
|
|
|
|
|
|
|
|
|
var style = SegmentStyle()
|
|
|
|
|
style.showLine = true
|
|
|
|
|
style.normalTitleColor = UIColor.secondaryText()
|
|
|
|
|
style.selectedTitleColor = UIColor.primaryText()
|
|
|
|
|
style.backgroundColor = UIColor.white
|
|
|
|
|
style.titleSelectFont = UIFont.systemFont(ofSize: 15, weight: .medium)
|
|
|
|
|
style.titleFont = UIFont.systemFont(ofSize: 15)
|
|
|
|
|
|
|
|
|
|
style.scrollLineHeight = 2
|
|
|
|
|
style.scrollLineColor = .primary()
|
|
|
|
|
style.coverBackgroundColor = .init(hex: 0x0d0d0d)
|
|
|
|
|
style.normalborderColor = UIColor.tertiaryText()
|
|
|
|
|
style.scrollTitle = false
|
|
|
|
|
style.showCover = false
|
|
|
|
|
style.normalborderColor = .clear
|
|
|
|
|
|
|
|
|
|
// style.scrollTitle = true
|
|
|
|
|
style.lineSpace = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let segmentControl = ScrollSegmentView.init(frame: CGRect.init(x: 0, y: 0, width: 200, height: 32), segmentStyle: style, titles: ["喜欢的单曲", "收藏期刊"])
|
|
|
|
|
|
|
|
|
|
// segmentControl.scrollView.backgroundColor = .red
|
|
|
|
|
|
|
|
|
|
return segmentControl
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let tableView: UITableView = {
|
|
|
|
|
let tableView = UITableView.init()
|
|
|
|
|
|
|
|
|
|
return tableView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
let collectionView: UICollectionView = {
|
|
|
|
|
let layout = UICollectionViewFlowLayout()
|
|
|
|
|
layout.minimumInteritemSpacing = 15
|
|
|
|
|
layout.minimumLineSpacing = 24
|
|
|
|
|
|
|
|
|
|
layout.sectionInset = UIEdgeInsets.init(top: 0, left: 18, bottom: 0, right: 18)
|
|
|
|
|
|
|
|
|
|
layout.itemSize = CGSize(width: (BaseDimensions.screenWidth - 18 * 2 - 15) / 2, height: 147)
|
|
|
|
|
|
|
|
|
|
let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: layout)
|
|
|
|
|
|
|
|
|
|
collectionView.register(JournalViewCell.self, forCellWithReuseIdentifier: "JournalViewCell")
|
|
|
|
|
|
|
|
|
|
return collectionView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentSearchType: SearchType = .audio {
|
|
|
|
|
didSet {
|
|
|
|
|
switch currentSearchType {
|
|
|
|
|
case .audio:
|
|
|
|
|
collectionView.isHidden = true
|
|
|
|
|
tableView.isHidden = false
|
|
|
|
|
case .journal:
|
|
|
|
|
collectionView.isHidden = false
|
|
|
|
|
tableView.isHidden = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
|
super.init(frame: frame)
|
|
|
|
|
|
|
|
|
|
makeUI()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func makeUI() {
|
|
|
|
|
segmentControl.titleBtnOnClick = { [weak self] (label, index) in
|
|
|
|
|
if index == 0 {
|
|
|
|
|
self?.currentSearchType = .audio
|
|
|
|
|
} else {
|
|
|
|
|
self?.currentSearchType = .journal
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
backgroundColor = .white
|
|
|
|
|
|
|
|
|
|
addSubview(segmentControl)
|
|
|
|
|
addSubview(tableView)
|
|
|
|
|
addSubview(collectionView)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func layoutSubviews() {
|
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
|
|
|
|
segmentControl.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(self).offset(18)
|
|
|
|
|
make.top.equalTo(self).offset(0)
|
|
|
|
|
make.height.equalTo(32)
|
|
|
|
|
make.width.equalTo(200)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tableView.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(self)
|
|
|
|
|
make.right.equalTo(self)
|
|
|
|
|
make.top.equalTo(segmentControl.snp.bottom).offset(24)
|
|
|
|
|
make.bottom.equalTo(self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
collectionView.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(self)
|
|
|
|
|
make.right.equalTo(self)
|
|
|
|
|
make.top.equalTo(segmentControl.snp.bottom).offset(24)
|
|
|
|
|
make.bottom.equalTo(self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PersonalHeaderView: UICollectionReusableView {
|
|
|
|
|
|
|
|
|
|