杨锴
2024-08-30 50260473dbb1bf4596f9f6ead4a265ca7ee4d5b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//
//  HomeItemDetailVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/14.
//
 
import UIKit
import JQTools
 
class HomeItemDetailVC: BaseVC {
 
                @IBOutlet weak var slider_voice: UISlider!
                @IBOutlet weak var view_function: UIView!
                @IBOutlet weak var btn_play: UIButton!
                @IBOutlet weak var label_title: UILabel!
                @IBOutlet weak var label_subtitle: UILabel!
                @IBOutlet weak var btn_like: UIButton!
                @IBOutlet weak var label_commentNum: UILabel!
                @IBOutlet weak var view_coutdown: UIView!
                @IBOutlet weak var img_countdonw: UIImageView!
                @IBOutlet weak var label_countdown: UILabel!
 
    override func viewDidLoad() {
        super.viewDidLoad()
                                title = "心泉·疗愈"
 
                                if AudioPlayer.getSharedInstance().times.value != nil{
                                                startMiniRunloop()
                                }else{
                                                endMiniRunloop()
                                }
    }
 
                override func viewDidAppear(_ animated: Bool) {
                                super.viewDidAppear(animated)
 
                                //如果从支付过来的,移除支付
                                navigationController!.viewControllers.removeAll { vc in
                                                if vc is PaymentOrderResultVC || vc is PaymentOrderVC{
                                                                return true
                                                }
                                                return false
                                }
                }
 
                override func setUI() {
 
                                let collect_bitem = UIBarButtonItem(image: UIImage(named: "btn_collect"), style: .plain, target: self, action: #selector(collectionAction))
                                collect_bitem.tintColor = .white
                                let share_bitem = UIBarButtonItem(image: UIImage(named: "btn_share"), style: .plain, target: self, action: #selector(shareAction))
                                share_bitem.tintColor = .white
                                share_bitem.imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 15)
                                navigationItem.rightBarButtonItems = [share_bitem,collect_bitem]
 
 
                                let v1 = UIView()
                                v1.backgroundColor = UIColor(hexStr: "#B6DC90")
                                v1.bounds = CGRect(x: 0, y: 0, width: 17, height: 17)
                                v1.jq_borderWidth = 2
                                v1.jq_borderColor = .white
                                v1.jq_cornerRadius = 8.5
 
                                slider_voice.setThumbImage(v1.qmui_snapshotLayerImage(), for: .normal)
                                slider_voice.setThumbImage(v1.qmui_snapshotLayerImage(), for: .highlighted)
                                view_coutdown.isHidden = true
 
                                view_function.jq_gradientColor(colorArr: [UIColor.black.withAlphaComponent(0.15).cgColor,UIColor.clear.cgColor], cornerRadius: 0, startPoint: CGPoint(x: 0, y: 1), endPoint: CGPoint(x: 0, y: 0), bounds: nil, locations: nil)
 
                }
 
                override func setRx() {
                                AudioPlayer.getSharedInstance().times.subscribe {[weak self] t in
                                                guard let weakSelf = self else { return }
                                                guard let time = t,time > 0 else {weakSelf.endMiniRunloop();return}
                                                let turple = Date.jq_formateToTime_tuple(time)
                                                weakSelf.label_countdown.text = String(format: "%02ld:%02ld", (turple.hour * 60 + turple.minute),turple.second)
 
                                                if weakSelf.view_coutdown.isHidden{
                                                                weakSelf.startMiniRunloop()
                                                                weakSelf.view_coutdown.isHidden = false
                                                }
 
                                }.disposed(by: disposeBag)
                }
 
                override func viewWillAppear(_ animated: Bool) {
                                super.viewWillAppear(animated)
                                (navigationItem.leftBarButtonItem?.customView as? UIButton)?.setImage(UIImage(named: "btn_back")?.withTintColor(.white), for: .normal)
                }
 
 
                private func startMiniRunloop(){
                                // 创建旋转动画
                                let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
                                rotationAnimation.fromValue = 0
                                rotationAnimation.toValue = CGFloat.pi * 2
                                rotationAnimation.duration = 3 // 动画持续时间
                                rotationAnimation.repeatCount = .greatestFiniteMagnitude // 无限重复
                                img_countdonw.layer.add(rotationAnimation, forKey: nil)
                                self.view_coutdown.isHidden = false
                }
 
                private func endMiniRunloop(){
                                img_countdonw.layer.removeAllAnimations()
                                self.view_coutdown.isHidden = true
                }
 
                @IBAction func playAction(_ sender: UIButton) {
 
                }
 
                @IBAction func timeAction(_ sender: UIButton) {
                                CountdownChooseListView.show {[weak self] times in
                                                guard let weakSelf = self else { return }
                                                AudioPlayer.getSharedInstance().setTimer(times: times * 60)
 
//                                                if times <= 0{
//                                                                weakSelf.timer = nil
//                                                                weakSelf.times = -1
//                                                                weakSelf.endMiniRunloop()
//                                                                return
//                                                }
//
//                                                weakSelf.times = times * 60
//                                                if weakSelf.timer == nil{
//                                                                weakSelf.timer = Timer(timeInterval: 1, repeats: true, block: { timer in
//
//                                                                                weakSelf.times -= 1
//
//                                                                                if weakSelf.times <= 0{
//                                                                                                //todo
//                                                                                }
//                                                                })
//                                                                weakSelf.timer?.fire()
//                                                                RunLoop.current.add(weakSelf.timer!, forMode: .default)
//                                                                weakSelf.startMiniRunloop()
//                                                }
                                }
                }
 
                @IBAction func commentAction(_ sender: TapBtn) {
                                let vc = CommentListVC()
                                vc.modalPresentationStyle = .custom
                                present(vc, animated: true)
                }
 
                @IBAction func beLikeAction(_ sender: UIButton) {
 
                }
 
                
                @IBAction func playWayAction(_ sender: UIButton) {
 
                }
 
                @IBAction func settingAction(_ sender: UIButton) {
                                PlaySettingView.show()
                }
 
                @objc func collectionAction(){
 
                }
 
                @objc func shareAction(){
                                ShareView.show()
                }
 
                override func viewDidLayoutSubviews() {
                                super.viewDidLayoutSubviews()
                }
 
 
                override var preferredStatusBarStyle: UIStatusBarStyle{
                                return .lightContent
                }
}