|
@@ -7,30 +7,29 @@
|
|
|
// 编辑视频--选择音乐のView
|
|
|
|
|
|
import UIKit
|
|
|
-import FWPopupView
|
|
|
import RxSwift
|
|
|
import SwiftyMediator
|
|
|
import JXSegmentedView
|
|
|
|
|
|
-class PublishMusicChooseView: FWPopupView {
|
|
|
+class PublishMusicChooseView: BaseView {
|
|
|
|
|
|
- let disposeBag = DisposeBag()
|
|
|
-
|
|
|
- var originVolumn: CGFloat?
|
|
|
- var backVolumn: CGFloat?
|
|
|
+ @objc public var attachedView: UIView?
|
|
|
+ @objc public var originVolumn: CGFloat = 0
|
|
|
+ @objc public var backVolumn: CGFloat = 0
|
|
|
|
|
|
typealias RecommendClosure = () -> Void
|
|
|
var recommendClosure : RecommendClosure?
|
|
|
|
|
|
- var curMusicUrl: String?
|
|
|
+ @objc public var curMusicUrl: String? {
|
|
|
+ didSet {
|
|
|
+ // 获取分类列表
|
|
|
+ self.communityGetMusicCategoryApi()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
|
- setupViews()
|
|
|
- setupLayouts()
|
|
|
|
|
|
- // 获取分类列表
|
|
|
- self.communityGetMusicCategoryApi()
|
|
|
}
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
@@ -55,15 +54,7 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func setupViews() {
|
|
|
- frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight - kSafeTabBarHeight - kSafeStatusBarHeight - 22)
|
|
|
-
|
|
|
- // 添加毛玻璃效果,需使用frame设置位置
|
|
|
- let blurEffect = UIBlurEffect(style: .dark)
|
|
|
- let blurEffectView = UIVisualEffectView(effect: blurEffect)
|
|
|
- blurEffectView.frame = CGRect(x: CGFloat(0), y: 0, width: kScreenWidth, height: kScreenHeight - kSafeTabBarHeight - kSafeStatusBarHeight - 22)
|
|
|
- addSubview(blurEffectView)
|
|
|
-
|
|
|
+ override func setupViews() {
|
|
|
self.backgroundColor = UIColor.clear
|
|
|
|
|
|
configRectCorner(corner: [.topLeft,.topRight], radii: CGSize(width: 8, height: 8))
|
|
@@ -79,7 +70,7 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
addSubview(v_lineLabel)
|
|
|
}
|
|
|
|
|
|
- func setupLayouts() {
|
|
|
+ override func setupLayouts() {
|
|
|
|
|
|
cancelButton.snp.makeConstraints { (make) in
|
|
|
make.top.equalTo(2)
|
|
@@ -136,6 +127,12 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
lazy var cancelButton: UIButton = {
|
|
|
let cancelButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
cancelButton.setImage(kImage(name: "video_btn_close_white"), for: .normal)
|
|
|
+ cancelButton.rx.tap.subscribe(onNext: { [weak self] in
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "EditCloseMusicChooseViewNoti"), object: nil)
|
|
|
+
|
|
|
+ MusicPlayManager.shared().destroyPlayer()
|
|
|
+ MusicPlayManager.shared().curPlayingId = -1
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
return cancelButton
|
|
|
}()
|
|
|
|
|
@@ -152,6 +149,9 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
recommendButton.setTitle("点击推荐", for: UIControl.State.normal)
|
|
|
recommendButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
recommendButton.titleLabel?.font = kMediumFont14
|
|
|
+ recommendButton.rx.tap.subscribe(onNext: { [weak self] in
|
|
|
+ Mediator.push(PublishRouterModuleType.pushMucisChooseView)
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
return recommendButton
|
|
|
}()
|
|
|
|
|
@@ -166,6 +166,9 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
musicButton.setTitle("配乐", for: UIControl.State.normal)
|
|
|
musicButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
musicButton.titleLabel?.font = kMediumFont17
|
|
|
+ musicButton.rx.tap.subscribe(onNext: { [weak self] in
|
|
|
+
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
return musicButton
|
|
|
}()
|
|
|
|
|
@@ -174,6 +177,11 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
volumnButton.setTitle("音量", for: UIControl.State.normal)
|
|
|
volumnButton.setTitleColor(k999999Color, for: UIControl.State.normal)
|
|
|
volumnButton.titleLabel?.font = kRegularFont16
|
|
|
+ volumnButton.rx.tap.subscribe(onNext: { [weak self] in
|
|
|
+ _ = PublishMusicVolumnView.publishMusicVolumnView(attachedView: self?.attachedView ?? UIView(), oriVolumn: self?.originVolumn ?? 0, backVolumn: self?.backVolumn ?? 0)
|
|
|
+
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "EditCloseMusicChooseViewNoti"), object: nil)
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
return volumnButton
|
|
|
}()
|
|
|
|
|
@@ -187,8 +195,7 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
//MARK: -
|
|
|
//1.初始化JXSegmentedView
|
|
|
lazy var segmentedView: JXSegmentedView = {
|
|
|
-// let segmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 48, width: kScreenWidth, height: 44))
|
|
|
- let segmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 48, width: kScreenWidth, height: 44+100))
|
|
|
+ let segmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 48, width: kScreenWidth, height: 44))
|
|
|
segmentedView.delegate = self
|
|
|
segmentedView.dataSource = segmentedDataSource
|
|
|
segmentedView.indicators = [indicator]
|
|
@@ -236,59 +243,9 @@ class PublishMusicChooseView: FWPopupView {
|
|
|
let listContainerView = JXSegmentedListContainerView(dataSource: self)
|
|
|
listContainerView.didAppearPercent = 0.01
|
|
|
listContainerView.defaultSelectedIndex = 0
|
|
|
-// listContainerView.frame = CGRect(x: 0, y: 48+44, width: kScreenWidth, height: kScreenHeight - kSafeTabBarHeight - kSafeStatusBarHeight - 103 - 114)
|
|
|
-
|
|
|
- listContainerView.frame = CGRect(x: 0, y: 48+44+100, width: kScreenWidth, height: kScreenHeight - kSafeTabBarHeight - kSafeStatusBarHeight - 103 - 114-100)
|
|
|
+ listContainerView.frame = CGRect(x: 0, y: 48+44, width: kScreenWidth, height: kScreenHeight - kSafeTabBarHeight - kSafeStatusBarHeight - 103 - 114)
|
|
|
return listContainerView
|
|
|
}()
|
|
|
-
|
|
|
- /// 初始化View
|
|
|
- @objc class func publishMusicChooseView(attachedView:UIView, curMusicUrl:String, oriVolumn:CGFloat, backVolumn:CGFloat) -> PublishMusicChooseView {
|
|
|
- let view = PublishMusicChooseView()
|
|
|
- view.attachedView = attachedView
|
|
|
- view.originVolumn = oriVolumn
|
|
|
- view.backVolumn = backVolumn
|
|
|
- view.curMusicUrl = curMusicUrl
|
|
|
- let vProperty = FWPopupViewProperty()
|
|
|
- vProperty.popupCustomAlignment = .bottomCenter
|
|
|
- vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
|
|
- vProperty.popupAnimationType = .frame
|
|
|
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.2)
|
|
|
- // 用户点击外部遮罩层页面是否可以消失
|
|
|
- vProperty.touchWildToHide = "0"
|
|
|
- view.vProperty = vProperty
|
|
|
- view.show()
|
|
|
-
|
|
|
- view.cancelButton.rx.tap.subscribe(onNext: { (data) in
|
|
|
- view.hide()
|
|
|
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "EditCloseMusicChooseViewNoti"), object: nil)
|
|
|
-
|
|
|
- MusicPlayManager.shared().destroyPlayer()
|
|
|
- MusicPlayManager.shared().curPlayingId = -1
|
|
|
-
|
|
|
- }).disposed(by: view.disposeBag)
|
|
|
-
|
|
|
-
|
|
|
- view.recommendButton.rx.tap.subscribe(onNext: { (data) in
|
|
|
- Mediator.push(PublishRouterModuleType.pushMucisChooseView)
|
|
|
-
|
|
|
- }).disposed(by: view.disposeBag)
|
|
|
-
|
|
|
- view.musicButton.rx.tap.subscribe(onNext: { (data) in
|
|
|
-
|
|
|
- }).disposed(by: view.disposeBag)
|
|
|
-
|
|
|
- view.volumnButton.rx.tap.subscribe(onNext: { (data) in
|
|
|
- view.hide(popupDidDisappearBlock: { (view1) in
|
|
|
- _ = PublishMusicVolumnView.publishMusicVolumnView(attachedView: attachedView, oriVolumn: oriVolumn, backVolumn: backVolumn)
|
|
|
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "EditCloseMusicChooseViewNoti"), object: nil)
|
|
|
- })
|
|
|
-
|
|
|
- }).disposed(by: view.disposeBag)
|
|
|
-
|
|
|
- return view
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// MARK: - JXSegmentedViewDelegate
|
|
@@ -361,7 +318,6 @@ extension PublishMusicChooseView :JXSegmentedListContainerViewDataSource {
|
|
|
|
|
|
MusicPlayManager.shared().destroyPlayer()
|
|
|
MusicPlayManager.shared().curPlayingId = -1
|
|
|
- self.hide()
|
|
|
}
|
|
|
}
|
|
|
|