|
|
|
@ -9,6 +9,7 @@ import UIKit
|
|
|
|
|
import RxSwift
|
|
|
|
|
import RxCocoa
|
|
|
|
|
import RxDataSources
|
|
|
|
|
import FSPopoverView
|
|
|
|
|
|
|
|
|
|
class MessageViewController: ViewController, UIScrollViewDelegate {
|
|
|
|
|
|
|
|
|
@ -21,7 +22,8 @@ class MessageViewController: ViewController, UIScrollViewDelegate {
|
|
|
|
|
var tableView: UITableView = {
|
|
|
|
|
let tableView = UITableView.init()
|
|
|
|
|
tableView.register(MessageCellView.self, forCellReuseIdentifier: "MessageCellView")
|
|
|
|
|
|
|
|
|
|
tableView.register(MessageActivitiesViewCell.self, forCellReuseIdentifier: "MessageActivitiesViewCell")
|
|
|
|
|
|
|
|
|
|
return tableView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
@ -34,22 +36,65 @@ class MessageViewController: ViewController, UIScrollViewDelegate {
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private let menuView: FSPopoverListView = {
|
|
|
|
|
let menuView = FSPopoverListView.init(scrollDirection: .horizontal)
|
|
|
|
|
do {
|
|
|
|
|
let features: [PopoverMenu] = [.blockList, .delete]
|
|
|
|
|
let items: [FSPopoverListItem] = features.map { feature in
|
|
|
|
|
let item = FSPopoverListTextItem(scrollDirection: .horizontal)
|
|
|
|
|
item.title = feature.title
|
|
|
|
|
item.titleFont = UIFont.systemFont(ofSize: 12)
|
|
|
|
|
item.isSeparatorHidden = false
|
|
|
|
|
item.titleColor = .white
|
|
|
|
|
item.contentInset = .init(top: 9, left: 15, bottom: 9, right: 15)
|
|
|
|
|
item.selectedHandler = { item in
|
|
|
|
|
guard let item = item as? FSPopoverListTextItem else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
print(item.title ?? "")
|
|
|
|
|
}
|
|
|
|
|
item.updateLayout()
|
|
|
|
|
return item
|
|
|
|
|
}
|
|
|
|
|
items.last?.isSeparatorHidden = true
|
|
|
|
|
menuView.shadowOpacity = 0
|
|
|
|
|
menuView.shadowRadius = 0
|
|
|
|
|
menuView.shadowColor = .clear
|
|
|
|
|
menuView.items = items
|
|
|
|
|
menuView.cornerRadius = 3
|
|
|
|
|
menuView.transitioningDelegate = nil
|
|
|
|
|
|
|
|
|
|
menuView.arrowSize = CGSize.init(width: 18, height: 5)
|
|
|
|
|
menuView.backgroundColor = .primaryText()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return menuView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func makeUI() {
|
|
|
|
|
super.makeUI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.navigationItem.title = "消息列表"
|
|
|
|
|
tableView.rx.setDelegate(self).disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.addSubview(messageTopView)
|
|
|
|
|
view.addSubview(tableView)
|
|
|
|
|
view.addSubview(noDataView)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func bindViewModel() {
|
|
|
|
@ -70,7 +115,32 @@ class MessageViewController: ViewController, UIScrollViewDelegate {
|
|
|
|
|
|
|
|
|
|
let output = viewModel.transform(input: input)
|
|
|
|
|
|
|
|
|
|
let dataSource = MessageViewController.tableViewDataSource()
|
|
|
|
|
let dataSource = RxTableViewSectionedReloadDataSource<MessageSection>(
|
|
|
|
|
configureCell: { dataSource, tableView, indexPath, item in
|
|
|
|
|
|
|
|
|
|
switch dataSource[indexPath] {
|
|
|
|
|
case .messageItem(let message):
|
|
|
|
|
let cell: MessageCellView = tableView.dequeueReusableCell(withIdentifier: "MessageCellView", for: indexPath) as! MessageCellView
|
|
|
|
|
cell.message = message
|
|
|
|
|
|
|
|
|
|
cell.rx.longPressGesture().when(.recognized)
|
|
|
|
|
.subscribe { longPress in
|
|
|
|
|
|
|
|
|
|
self.menuView.present(fromView: cell.nameLabel, displayIn: self.view)
|
|
|
|
|
}.disposed(by: self.rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cell
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case .activitiesItem(let message):
|
|
|
|
|
let cell: MessageActivitiesViewCell = tableView.dequeueReusableCell(withIdentifier: "MessageActivitiesViewCell", for: indexPath) as! MessageActivitiesViewCell
|
|
|
|
|
|
|
|
|
|
return cell
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.tableViewItems.bind(to: tableView.rx.items(dataSource: dataSource)).disposed(by: rx.disposeBag)
|
|
|
|
@ -81,6 +151,7 @@ class MessageViewController: ViewController, UIScrollViewDelegate {
|
|
|
|
|
|
|
|
|
|
self?.navigator.show(segue: .commentList(viewModel: commentListViewModel), sender: self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,23 +186,10 @@ class MessageViewController: ViewController, UIScrollViewDelegate {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension MessageViewController {
|
|
|
|
|
//TODO
|
|
|
|
|
static func tableViewDataSource() -> RxTableViewSectionedReloadDataSource<MessageSection> {
|
|
|
|
|
return RxTableViewSectionedReloadDataSource<MessageSection>(
|
|
|
|
|
configureCell: { dataSource, tableView, indexPath, item in
|
|
|
|
|
let cell: MessageCellView = tableView.dequeueReusableCell(withIdentifier: "MessageCellView", for: indexPath) as! MessageCellView
|
|
|
|
|
cell.message = item
|
|
|
|
|
|
|
|
|
|
return cell
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -386,6 +444,8 @@ class MessageActivitiesViewCell: UITableViewCell {
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
|
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
|
|
|
|
|
|
|
|