|
@@ -39,12 +39,13 @@ class CommunityRecommendController: BaseViewController {
|
|
|
var heightModel1 = HeightModel()
|
|
|
/// 最后滚动的位置
|
|
|
var lastContentOffset : CGFloat = 0
|
|
|
+
|
|
|
+ var emptyView : DIYEmptyView?
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
setupViews()
|
|
|
- setupLayouts()
|
|
|
setupData()
|
|
|
}
|
|
|
|
|
@@ -54,14 +55,29 @@ class CommunityRecommendController: BaseViewController {
|
|
|
navigationBar.addSubview(avatarButton)
|
|
|
navigationBar.addSubview(nameButton)
|
|
|
navigationBar.addSubview(followButton)
|
|
|
- navigationBar.wr_setRightButton(image: kImage(name: "nav_share_black")!)
|
|
|
view.addSubview(commentView)
|
|
|
view.addSubview(tableView)
|
|
|
view.addSubview(sharedButton)
|
|
|
+ emptyView = DIYEmptyView.emptyActionView(withImageStr: "default_page_content", titleStr: nil, detailStr: "内容飞走了, 去看看别的吧", btnTitleStr: "去首页") {
|
|
|
+ [weak self] in
|
|
|
+ self?.tabBarController?.selectedIndex = 0
|
|
|
+ self?.navigationController?.popToRootViewController(animated: true)
|
|
|
+ }
|
|
|
+ emptyView?.actionBtnHorizontalMargin = 58
|
|
|
+ emptyView?.contentViewY = kScaleValue(value: 164 + kNavBarTotalHeight)
|
|
|
+ emptyView?.subViewMargin = 20
|
|
|
+ emptyView?.actionBtnFont = kBoldFont16
|
|
|
+ emptyView?.actionBtnHeight = 32
|
|
|
+ emptyView?.actionBtnCornerRadius = 32/2
|
|
|
+ emptyView?.actionBtnTitleColor = kffffffColor
|
|
|
+ emptyView?.actionBtnBackGroundColor = kThemeColor
|
|
|
+ self.view.ly_emptyView = emptyView
|
|
|
+ self.view.ly_showEmpty()
|
|
|
|
|
|
}
|
|
|
|
|
|
override func setupLayouts() {
|
|
|
+ navigationBar.wr_setRightButton(image: kImage(name: "nav_share_black")!)
|
|
|
|
|
|
avatarButton.snp.makeConstraints { (make) in
|
|
|
make.left.equalTo(navigationBar.leftButton.snp_right)
|
|
@@ -318,6 +334,7 @@ extension CommunityRecommendController {
|
|
|
/// 帖子内容
|
|
|
func communityPostDetailApi() {
|
|
|
SwiftMoyaNetWorkServiceCommunity.shared().communityPostDetailApi(id: id) { [weak self] (communityPostDetailModel) -> (Void) in
|
|
|
+ self?.view.ly_hideEmpty()
|
|
|
self?.communityPostDetailModel = communityPostDetailModel as? CommunityPostDetailModel
|
|
|
self?.communityPostsApi(page:1)
|
|
|
self?.avatarButton.kf.setImage(with: kURLImage(name: self?.communityPostDetailModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
|
|
@@ -343,7 +360,12 @@ extension CommunityRecommendController {
|
|
|
if !(self?.communityPostDetailModel?.imgs?.isEmpty ?? true) {
|
|
|
let height = getImageHeight(imgStr: (self?.communityPostDetailModel?.imgs?[0])!)
|
|
|
let width = getImageWidth(imgStr: (self?.communityPostDetailModel?.imgs?[0])!)
|
|
|
- self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth*height/width)
|
|
|
+ let scaleHeight = kScreenWidth*height/width
|
|
|
+ if scaleHeight >= (500 * kScaleWidth) {
|
|
|
+ self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: 500 * kScaleWidth)
|
|
|
+ }else {
|
|
|
+ self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth*height/width)
|
|
|
+ }
|
|
|
self?.communityPostDetailTableViewHeaderView.tableView = self?.tableView
|
|
|
self?.tableView.tableHeaderView = self?.communityPostDetailTableViewHeaderView
|
|
|
|
|
@@ -360,6 +382,7 @@ extension CommunityRecommendController {
|
|
|
self?.communityPostDetailTableViewHeaderView.communityPostDetailModel = self?.communityPostDetailModel
|
|
|
|
|
|
}
|
|
|
+ self?.setupLayouts()
|
|
|
|
|
|
self?.tableView.reloadData()
|
|
|
self?.readVirueRecordAddApi()
|