|
@@ -6,4 +6,134 @@
|
|
|
// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
// 星球活动のCell
|
|
|
|
|
|
-import Foundation
|
|
|
+import UIKit
|
|
|
+import RxSwift
|
|
|
+import RxCocoa
|
|
|
+
|
|
|
+class MessageActivityTableCell: UITableViewCell {
|
|
|
+
|
|
|
+ let disposeBag = DisposeBag()
|
|
|
+
|
|
|
+ typealias ActivityClosure = () -> Void
|
|
|
+ var activityClosure : ActivityClosure?
|
|
|
+
|
|
|
+ class func cellWith(tableView:UITableView,indexPath:IndexPath) -> MessageActivityTableCell {
|
|
|
+ let ID = "MessageActivityTableCell"
|
|
|
+ tableView.register(MessageActivityTableCell.self, forCellReuseIdentifier: ID)
|
|
|
+ let cell : MessageActivityTableCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! MessageActivityTableCell
|
|
|
+ cell.indexPath = indexPath
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+
|
|
|
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
|
+ super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
|
+ setupViews()
|
|
|
+ setupLayouts()
|
|
|
+ }
|
|
|
+
|
|
|
+ required init?(coder aDecoder: NSCoder) {
|
|
|
+ fatalError("init(coder:) has not been implemented")
|
|
|
+ }
|
|
|
+
|
|
|
+ var indexPath: IndexPath? {
|
|
|
+ didSet {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //MRAK: - 设置View
|
|
|
+ private func setupViews() {
|
|
|
+ self.selectionStyle = .none
|
|
|
+ backgroundColor = kf7f8faColor
|
|
|
+
|
|
|
+ addSubview(timeLabel)
|
|
|
+ addSubview(activityView)
|
|
|
+ activityView.addSubview(actImageView)
|
|
|
+ activityView.addSubview(titleLabel)
|
|
|
+ activityView.addSubview(subLabel)
|
|
|
+ activityView.addSubview(itemButton)
|
|
|
+ }
|
|
|
+
|
|
|
+ private func setupLayouts() {
|
|
|
+ timeLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(16)
|
|
|
+ make.centerX.equalToSuperview()
|
|
|
+ make.width.equalTo(90)
|
|
|
+ make.height.equalTo(20)
|
|
|
+ }
|
|
|
+ activityView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(timeLabel.snp_bottom).offset(16)
|
|
|
+ make.left.equalTo(23)
|
|
|
+ make.right.equalTo(-23)
|
|
|
+ make.height.equalTo(160)
|
|
|
+ }
|
|
|
+ actImageView.snp.makeConstraints { (make) in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
+ titleLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(103)
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.height.equalTo(21)
|
|
|
+ }
|
|
|
+ subLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(6)
|
|
|
+ make.left.equalTo(titleLabel.snp_left)
|
|
|
+ make.right.equalTo(titleLabel.snp_right)
|
|
|
+ make.height.equalTo(17)
|
|
|
+ }
|
|
|
+ itemButton.snp.makeConstraints { (make) in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private lazy var timeLabel: UILabel = {
|
|
|
+ let timeLabel = UILabel()
|
|
|
+ timeLabel.backgroundColor = kRGBAColor(r: 0/255.0, g: 0/255.0, b: 0/255.0, a: 0.1)
|
|
|
+ timeLabel.text = "05-16 20:03"
|
|
|
+ timeLabel.textColor = kffffffColor
|
|
|
+ timeLabel.font = kRegularFont12
|
|
|
+ timeLabel.textAlignment = .center
|
|
|
+ return timeLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var activityView: UIView = {
|
|
|
+ let activityView = UIView()
|
|
|
+ return activityView
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var actImageView : UIImageView = {
|
|
|
+ let actImageView = UIImageView()
|
|
|
+ actImageView.image = kImage(name: "page05")
|
|
|
+ return actImageView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var titleLabel: UILabel = {
|
|
|
+ let titleLabel = UILabel()
|
|
|
+ titleLabel.text = "我就是一个用来测一测的Title"
|
|
|
+ titleLabel.textColor = kffffffColor
|
|
|
+ titleLabel.font = kRegularFont15
|
|
|
+ titleLabel.textAlignment = .left
|
|
|
+ return titleLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var subLabel: UILabel = {
|
|
|
+ let subLabel = UILabel()
|
|
|
+ subLabel.text = "活动时间:2019/5/19~2019/5/20"
|
|
|
+ subLabel.textColor = kffffffColor
|
|
|
+ subLabel.font = kRegularFont12
|
|
|
+ subLabel.textAlignment = .left
|
|
|
+ return subLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var itemButton: UIButton = {
|
|
|
+ let itemButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ itemButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let activityClosure = self?.activityClosure {
|
|
|
+ activityClosure()
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return itemButton
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|