Chris лет назад: 5
Родитель
Сommit
e5df72c34b

+ 2 - 0
RainbowPlanet/Podfile

@@ -54,6 +54,8 @@ target 'RainbowPlanet' do
   pod 'DPScrollNumberLabel'
   # 左右Label
   pod 'FlickerNumber'
+  # Label扩展
+  pod 'YYText'
   # 生成二维码
   pod 'EFQRCode'
   

+ 13 - 1
RainbowPlanet/Podfile.lock

@@ -25,6 +25,8 @@ PODS:
   - Cache (5.2.0)
   - DeviceKit (2.0.0)
   - DPScrollNumberLabel (0.0.2)
+  - EFQRCode (5.0.0):
+    - swift_qrcodejs (~> 1.1.1)
   - FlickerNumber (1.1)
   - FMDB (2.7.5):
     - FMDB/standard (= 2.7.5)
@@ -55,6 +57,7 @@ PODS:
     - RxSwift (>= 4.4.2, ~> 4.4)
   - RxSwift (4.5.0)
   - SnapKit (4.2.0)
+  - swift_qrcodejs (1.1.1)
   - SwiftyJSON (5.0.0)
   - SwiftyMediator/Core (0.2.0)
   - SwiftyMediator/Routable (0.2.0):
@@ -83,6 +86,7 @@ PODS:
   - VODUpload (1.5.1):
     - AliyunOSSiOS
   - WebViewJavascriptBridge (6.0.3)
+  - YYText (1.0.7)
   - ZipArchive (1.4.0)
 
 DEPENDENCIES:
@@ -96,6 +100,7 @@ DEPENDENCIES:
   - Cache
   - DeviceKit
   - DPScrollNumberLabel
+  - EFQRCode
   - FlickerNumber
   - FMDB
   - FSPagerView
@@ -129,6 +134,7 @@ DEPENDENCIES:
   - UMCShare/UI
   - VODUpload
   - WebViewJavascriptBridge
+  - YYText
   - ZipArchive (= 1.4.0)
 
 SPEC REPOS:
@@ -143,6 +149,7 @@ SPEC REPOS:
     - Cache
     - DeviceKit
     - DPScrollNumberLabel
+    - EFQRCode
     - FlickerNumber
     - FMDB
     - FSPagerView
@@ -164,6 +171,7 @@ SPEC REPOS:
     - RxCocoa
     - RxSwift
     - SnapKit
+    - swift_qrcodejs
     - SwiftyJSON
     - SwiftyMediator
     - UMCAnalytics
@@ -174,6 +182,7 @@ SPEC REPOS:
     - UMCShare
     - VODUpload
     - WebViewJavascriptBridge
+    - YYText
     - ZipArchive
 
 SPEC CHECKSUMS:
@@ -187,6 +196,7 @@ SPEC CHECKSUMS:
   Cache: 807c5d86d01a177f06ede9865add3aea269bbfd4
   DeviceKit: 72d36709552d4b3582abd76a53949148acad9811
   DPScrollNumberLabel: 5124eaccf3029bb84116de391e1273cba676f4f5
+  EFQRCode: 07437cfbce3a1e497397a4f3d766c980d8972608
   FlickerNumber: bce41da51904d533393d69e9734df6281ab1c646
   FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
   FSPagerView: 816a18842306973cc7cc6df8a5332272f7815c30
@@ -208,6 +218,7 @@ SPEC CHECKSUMS:
   RxCocoa: cbf70265dc65a981d4ac982e513c10cf23df24a0
   RxSwift: f172070dfd1a93d70a9ab97a5a01166206e1c575
   SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a
+  swift_qrcodejs: 0bacbfe321a99954c7b8e04c75562007ea4e4f7c
   SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7
   SwiftyMediator: 73d97b2387f03c4f0320c1fbdf615e5fbb98871d
   UMCAnalytics: ff58714ada407682c4a07548156f94bcec92f055
@@ -218,8 +229,9 @@ SPEC CHECKSUMS:
   UMCShare: 552b29753f1b4da87b51d96545ed19e6263df397
   VODUpload: d180069b5fcee002079a892de2f310bacdb8e355
   WebViewJavascriptBridge: 7f5bc4d3581e672e8f32bd0f812d54bc69bb8e29
+  YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
   ZipArchive: e25a4373192673e3229ac8d6e9f64a3e5713c966
 
-PODFILE CHECKSUM: a224330b1afa4c6586b4a2138a27df46bbc0b074
+PODFILE CHECKSUM: 9fd2e931ae0f743f25523cd5d5a37deb91708a9b
 
 COCOAPODS: 1.7.1

+ 3 - 0
RainbowPlanet/RainbowPlanet/Macro/RainbowPlanet-Bridging-Header.h

@@ -30,6 +30,9 @@
 #import "UICollectionViewLeftAlignedLayout.h"
 #import "FMLinkLabel.h"
 
+#import "YYText.h"
+#import "NSAttributedString+YYText.h"
+#import "YYLabel.h"
 
 // FIXME: 自定义键盘--待转swift
 #import "LXKeyBoard.h"

+ 111 - 33
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -64,8 +64,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
             topicView.topicArray = self.videoItemMdl?.topic
             topicView.reloadData()
             
-            
-//            content    string    内容
+            contentLabel.text = self.videoItemMdl?.content
         }
     }
     
@@ -85,7 +84,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         cell.indexPath = indexPath
         return cell
     }
-    //MARK: - indexPath
+    //MARK: indexPath
     var indexPath: IndexPath?{
         didSet {
             
@@ -136,6 +135,13 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         // 话题View
         addSubview(topicView)
         
+        // 视频内容
+        addSubview(contentScrollView)
+        contentScrollView.addSubview(contentLabel)
+        
+        // 视频标题
+        addSubview(videoTitleLabel)
+        
         addSubview(personBackView)
         personBackView.addSubview(avatarButton)
         personBackView.addSubview(personLabel)
@@ -145,13 +151,8 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         rainbowBeanView.addSubview(beanIconImageView)
         rainbowBeanView.addSubview(beanLabel)
         
-        addSubview(videoTitleLabel)
-        
-        
         addSubview(playStatusImageView)
         
-        
-        
     }
     
     private func setupLayouts() {
@@ -239,14 +240,31 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
             make.height.equalTo(45)
         }
         
+        // 视频内容
+        contentScrollView.snp.makeConstraints { (make) in
+            make.bottom.equalTo(topicView.snp_top)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(44)
+        }
+        
+        contentLabel.snp.makeConstraints { (make) in
+            make.edges.equalToSuperview()
+        }
+        
+        // 视频标题
+        videoTitleLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(23)
+            make.bottom.equalTo(contentScrollView.snp_top).offset(-10)
+        }
         
         // personView
         personBackView.snp.makeConstraints { (make) in
             make.left.equalTo(14)
             make.height.equalTo(30)
-            
-            // FIXME:待调整底约束
-            make.bottom.equalToSuperview().offset(-200)
+            make.bottom.equalTo(videoTitleLabel.snp_top).offset(-20)
         }
         avatarButton.snp.makeConstraints { (make) in
             make.left.top.equalToSuperview()
@@ -269,9 +287,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         rainbowBeanView.snp.makeConstraints { (make) in
             make.left.equalTo(14)
             make.height.equalTo(24)
-            
-            // FIXME:待调整底约束
-            make.bottom.equalToSuperview().offset(-250)
+            make.bottom.equalTo(personBackView.snp_top).offset(-10)
         }
         beanIconImageView.snp.makeConstraints { (make) in
             make.left.equalTo(6)
@@ -284,16 +300,6 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
             make.right.equalTo(-6)
         }
         
-        videoTitleLabel.snp.makeConstraints { (make) in            
-            make.left.equalTo(14)
-            make.right.equalTo(-14)
-            
-            // FIXME:待调整底约束
-            make.bottom.equalToSuperview().offset(-150)
-        }
-        
-        
-        
         //
         playStatusImageView.snp.makeConstraints { (make) in
             make.center.equalToSuperview()
@@ -303,13 +309,62 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         
     }
     
-    // 视频播放View
+    func addSeeMoreButton(_ label: YYLabel, textStr: String?) {
+        label.attributedText = NSAttributedString(string: textStr ?? "", attributes: [
+            NSAttributedString.Key.font: kRegularFont14!
+            ])
+        
+        let moreString = " 展开"
+        var text = NSMutableAttributedString(string: "... \(moreString)")
+        let expandRange = (text.string as NSString).range(of: moreString)
+        
+        text.addAttribute(.foregroundColor, value: UIColor.blue, range: expandRange)
+        text.addAttribute(.foregroundColor, value: UIColor.darkText, range: NSRange(location: 0, length: expandRange.location))
+        
+        //添加点击事件
+        let hi = YYTextHighlight()
+        text.yy_setTextHighlight(hi, range: (text.string as NSString).range(of: moreString))
+        hi.tapAction = {
+            [weak self] (containerView, text, range, rect) in
+            //点击展开
+            self?.setTextFrame(true)
+        }
+        
+        text.yy_font = kRegularFont14
+        
+        let seeMore = YYLabel()
+        seeMore.attributedText = text
+        seeMore.sizeToFit()
+        
+        let truncationToken = NSAttributedString.yy_attachmentString(withContent: seeMore, contentMode: UIView.ContentMode.center, attachmentSize: seeMore.frame.size, alignTo: text.yy_font!, alignment: YYTextVerticalAlignment.top)
+        
+        label.truncationToken = truncationToken
+    }
+    
+    func setTextFrame(_ isExpand: Bool) {
+        if isExpand {
+            expandString()
+            contentScrollView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 200)
+            contentLabel.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 200)
+        } else {
+            contentScrollView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 30)
+            contentLabel.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 30)
+        }
+    }
+    
+    func expandString() {
+        let attri = contentLabel.attributedText as? NSMutableAttributedString
+        contentLabel.attributedText = attri
+    }
+    
+    // MARK: 视频播放View
     private lazy var videoPlayView: CommunityVideoPlayView = {
         let videoPlayView = CommunityVideoPlayView()
         videoPlayView.isUserInteractionEnabled = true
         return videoPlayView
     }()
     
+    // MARK: 顶部导航View
     private lazy var navBackView: UIView = {
         let navBackView = UIView()
         navBackView.backgroundColor = UIColor.clear
@@ -352,6 +407,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         return shareBtnLeft
     }()
     
+    // MARK: 底部View
     private lazy var bottomCommentView: UIView = {
         let bottomCommentView = UIView()
         bottomCommentView.backgroundColor = UIColor.clear
@@ -436,11 +492,40 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         return textBtn
     }()
     
+    // MARK: 话题View
     private lazy var topicView: CommunityVideoTopicView = {
         let topicView = CommunityVideoTopicView()
         return topicView
     }()
     
+    // MARK: 视频内容content
+    private lazy var contentScrollView :UIScrollView =  {
+        let contentScrollView = UIScrollView()
+        contentScrollView.bounces = false
+        // 设置初始contentSize
+        contentScrollView.contentSize = CGSize.init(width: kScreenWidth-28.0, height: 44.0)
+        contentScrollView.showsHorizontalScrollIndicator = false
+        contentScrollView.showsVerticalScrollIndicator = false
+        return contentScrollView
+    }()
+    
+    private lazy var contentLabel: YYLabel = {
+        let contentLabel = YYLabel()
+        contentLabel.numberOfLines = 0;
+        contentLabel.textColor = kffffffColor
+//        contentLabel.font = kRegularFont15
+        return contentLabel
+    }()
+    
+    // MARK: 视频Title
+    private lazy var videoTitleLabel: UILabel = {
+        let videoTitleLabel = UILabel()
+        videoTitleLabel.textColor = kffffffColor
+        videoTitleLabel.font = kMediumFont16
+        return videoTitleLabel
+    }()
+    
+    // MARK: 个人信息View
     private lazy var personBackView: UIView = {
         let personBackView = UIView()
         return personBackView
@@ -482,6 +567,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         return followButton
     }()
     
+    // MARK: 彩虹豆View
     private lazy var rainbowBeanView: UIView = {
         let rainbowBeanView = UIView()
         rainbowBeanView.backgroundColor = kRGBAColor(r: 0/255.0, g: 0/255.0, b: 0/255.0, a: 0.3)
@@ -503,14 +589,6 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         return beanLabel
     }()
     
-    private lazy var videoTitleLabel: UILabel = {
-        let videoTitleLabel = UILabel()
-        videoTitleLabel.textColor = kffffffColor
-        videoTitleLabel.font = kMediumFont16
-        return videoTitleLabel
-    }()
-    
-    
     // 播放暂停icon
     private lazy var playStatusImageView: UIImageView = {
         let playStatusImageView = UIImageView()

+ 0 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoPlayView.swift

@@ -12,7 +12,6 @@ class CommunityVideoPlayView: UIView {
     
     var assetURLString: String? {
         didSet {
-            
             if let url = URL(string: assetURLString ?? "") {
                 asset = AVAsset(url: url)
             }

+ 4 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoListController.swift

@@ -43,6 +43,10 @@ class CommunityVideoListController: BaseViewController {
         playFirstVideoWhenViewDidAppeared()
     }
     
+    override func viewWillDisappear(_ animated: Bool) {
+        pauseCurrentVideo()
+    }
+    
     func setUpAppStatusNotification() {
         observe = NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: OperationQueue.main, using: {
             [weak self] (notification) in