123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- //
- // CommunityFeaturedTopicsHeaderView.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/6/16.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- class CommunityFeaturedTopicsHeaderView: BaseView {
-
- override func setupViews() {
- self.backgroundColor = UIColor.clear
-
- addSubview(numberPeopleLabel)
- addSubview(topicLabel)
- addSubview(focusButton)
- addSubview(bottomView)
- }
-
- override func setupLayouts() {
- numberPeopleLabel.snp_makeConstraints { (make) in
- make.top.equalTo(92+kSafeStatusBarHeight)
- make.left.equalTo(14)
- make.height.equalTo(19)
- make.right.equalTo(-14)
- }
- topicLabel.snp_makeConstraints { (make) in
- make.top.equalTo(numberPeopleLabel.snp_bottom).offset(8)
- make.left.equalTo(14)
- make.right.lessThanOrEqualTo(focusButton.snp_left).offset(-5)
- make.height.equalTo(33)
- }
- focusButton.snp_makeConstraints { (make) in
- make.centerY.equalTo(topicLabel)
- make.right.equalTo(-14)
- make.height.equalTo(28)
- make.width.equalTo(80)
- }
- }
-
- private lazy var numberPeopleLabel: UILabel = {
- let numberPeopleLabel = UILabel()
- numberPeopleLabel.text = "8888位彩虹居民参与此话题"
- numberPeopleLabel.textColor = kffffffColor
- numberPeopleLabel.font = kRegularFont13
- return numberPeopleLabel
- }()
-
- private lazy var topicLabel: UILabel = {
- let topicLabel = UILabel()
- topicLabel.textColor = kffffffColor
- topicLabel.font = kMediumFont24
- return topicLabel
- }()
-
- typealias FollowClosureName = () -> Void
- var followClosureName : FollowClosureName?
-
- private lazy var focusButton: UIButton = {
- let focusButton = UIButton(type: UIButton.ButtonType.custom)
- focusButton.setTitleColor(kffffffColor, for: UIControl.State.selected)
- focusButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
- focusButton.setTitle("关注话题", for: UIControl.State.normal)
- focusButton.setTitle("已关注", for: UIControl.State.selected)
- focusButton.titleLabel?.font = kRegularFont13
- focusButton.setBackgroundImage(UIImage.imageWithColor(color: kThemeColor), for: UIControl.State.normal)
- focusButton.setBackgroundImage(UIImage.imageWithColor(color: UIColor.clear), for: UIControl.State.selected)
- focusButton.layer.borderWidth = 0.5
- focusButton.cornerRadius = 14
- focusButton.masksToBounds = true
- focusButton.rx.tap.subscribe(onNext: { [weak self] (data) in
- if let followClosureName = self?.followClosureName {
- followClosureName()
- }
- }).disposed(by: disposeBag)
-
- return focusButton
- }()
-
- private lazy var bottomView: UIView = {
- let bottomView = UIView(frame: CGRect(x: 0, y: 180+kSafeStatusBarHeight, width: kScreenWidth, height: 20))
- bottomView.backgroundColor = .white
- let shapeLayer = CAShapeLayer()
- bottomView.layer.mask = nil
- let bezierPath = UIBezierPath(roundedRect: bottomView.bounds,byRoundingCorners: [.topLeft,.topRight],cornerRadii: CGSize(width: 8,height: 8))
- shapeLayer.path = bezierPath.cgPath
- bottomView.layer.mask = shapeLayer
- return bottomView
- }()
-
- var communityTopicDetailModel : CommunityTopicDetailModel? {
- didSet {
- numberPeopleLabel.text = "\(communityTopicDetailModel?.followCount ?? "0")位彩虹居民参与此话题"
- topicLabel.text = communityTopicDetailModel?.name
- CommunityFollowTopicViewModel.shared.followTopicButton(communityTopicDetailModel: communityTopicDetailModel!, button: focusButton)
- }
- }
- }
|