|
@@ -10,7 +10,8 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
|
|
|
|
public var colComponent:TSCollectionViewComponent?
|
|
public var colComponent:TSCollectionViewComponent?
|
|
public var colAttributes:[String : Any]?
|
|
public var colAttributes:[String : Any]?
|
|
-
|
|
|
|
|
|
+ public var cancellable: [AnyCancellable] = []
|
|
|
|
+
|
|
override init(frame: CGRect) {
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
super.init(frame: frame)
|
|
creatUI()
|
|
creatUI()
|
|
@@ -35,7 +36,6 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
|
|
|
|
lazy var ringView: TSRingToneCellView = {
|
|
lazy var ringView: TSRingToneCellView = {
|
|
let ringToneView = TSRingToneCellView()
|
|
let ringToneView = TSRingToneCellView()
|
|
-// ringToneView.backgroundColor = .clear
|
|
|
|
ringToneView.clickPlayHandel = { [weak self] isplay in
|
|
ringToneView.clickPlayHandel = { [weak self] isplay in
|
|
guard let self = self else { return }
|
|
guard let self = self else { return }
|
|
|
|
|
|
@@ -43,7 +43,6 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
if TSBusinessAudioPlayer.shared.isLoading{
|
|
if TSBusinessAudioPlayer.shared.isLoading{
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
if TSBusinessAudioPlayer.shared.isPlaying{
|
|
if TSBusinessAudioPlayer.shared.isPlaying{
|
|
TSBusinessAudioPlayer.shared.stop()
|
|
TSBusinessAudioPlayer.shared.stop()
|
|
}else{
|
|
}else{
|
|
@@ -53,14 +52,24 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
}else{
|
|
}else{
|
|
TSBusinessAudioPlayer.shared.playUrlString(modelUrlString,indexPath: indexPath)
|
|
TSBusinessAudioPlayer.shared.playUrlString(modelUrlString,indexPath: indexPath)
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
return ringToneView
|
|
return ringToneView
|
|
}()
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
+ lazy var generateView: TSRingToneGenerateView = {
|
|
|
|
+ let generateView = TSRingToneGenerateView()
|
|
|
|
+ generateView.isHidden = true
|
|
|
|
+ generateView.refreshHandel = { [weak self] in
|
|
|
|
+ guard let self = self else { return }
|
|
|
|
+ guard let oldModel = model else { return }
|
|
|
|
+ TSGenerateRintoneOperationQueue.shared.creatOperation(uuid: oldModel.uuid).creatRintone(oldModel: oldModel, prompt: oldModel.request.prompt, promptSort: oldModel.request.promptSort)
|
|
|
|
+ }
|
|
|
|
+ return generateView
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
lazy var exampleView: UIView = {
|
|
lazy var exampleView: UIView = {
|
|
let exampleView = UIView()
|
|
let exampleView = UIView()
|
|
exampleView.backgroundColor = "#7E57F4".uiColor
|
|
exampleView.backgroundColor = "#7E57F4".uiColor
|
|
@@ -92,6 +101,45 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
var model:TSActionInfoModel?{
|
|
var model:TSActionInfoModel?{
|
|
didSet{
|
|
didSet{
|
|
guard let model = model else { return }
|
|
guard let model = model else { return }
|
|
|
|
+ cancellable.removeAll()
|
|
|
|
+ if let rintoneOperation = TSGenerateRintoneOperationQueue.shared.findOperation(uuid: model.uuid) as? TSGenerateRintoneOperation {
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ rintoneOperation.currentActionInfoModelChanged =
|
|
|
|
+
|
|
|
|
+ // rintoneOperation.$currentActionInfoModel.sink
|
|
|
|
+ { [weak self] actionInfoModel in
|
|
|
|
+ guard let self = self else { return }
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ self.updataActionInfoModelView(model: actionInfoModel)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // .store(in: &cancellable)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updataActionInfoModelView(model: model)
|
|
|
|
+
|
|
|
|
+ dePrint("model actionStatus 收到=\(model.actionStatus)")
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func updataActionInfoModelView(model:TSActionInfoModel){
|
|
|
|
+
|
|
|
|
+ if model.modelType == .example {
|
|
|
|
+ model.actionStatus = .success
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ switch model.actionStatus {
|
|
|
|
+ case .pending,.running:
|
|
|
|
+ generateView.isHidden = false
|
|
|
|
+ generateView.setProgress(progress: model.percent)
|
|
|
|
+ case .success:
|
|
|
|
+ cancellable.removeAll()
|
|
|
|
+ generateView.isHidden = true
|
|
|
|
+
|
|
ringView.timeLab.text = Float(model.request.duration).floatToMinuteSecond()
|
|
ringView.timeLab.text = Float(model.request.duration).floatToMinuteSecond()
|
|
ringView.nameLab.text = model.response.title
|
|
ringView.nameLab.text = model.response.title
|
|
ringView.setCoverImageView(urlString: model.response.coverUrl)
|
|
ringView.setCoverImageView(urlString: model.response.coverUrl)
|
|
@@ -99,42 +147,30 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
vipView.isHidden = true
|
|
vipView.isHidden = true
|
|
|
|
|
|
self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
|
|
self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
|
|
|
|
+
|
|
|
|
+ case .failed:
|
|
|
|
+ cancellable.removeAll()
|
|
|
|
+ generateView.isHidden = false
|
|
|
|
+ generateView.setFail()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
var ringModel:TSRingModel?{
|
|
var ringModel:TSRingModel?{
|
|
didSet{
|
|
didSet{
|
|
guard let ringModel = ringModel else { return }
|
|
guard let ringModel = ringModel else { return }
|
|
|
|
+
|
|
|
|
+ cancellable.removeAll()
|
|
|
|
+
|
|
ringView.timeLab.text = Float(ringModel.duration).floatToMinuteSecond()
|
|
ringView.timeLab.text = Float(ringModel.duration).floatToMinuteSecond()
|
|
ringView.nameLab.text = ringModel.title
|
|
ringView.nameLab.text = ringModel.title
|
|
ringView.setCoverImageView(urlString: "")
|
|
ringView.setCoverImageView(urlString: "")
|
|
exampleView.isHidden = true
|
|
exampleView.isHidden = true
|
|
|
|
+ generateView.isHidden = true
|
|
vipView.isHidden = !ringModel.vip
|
|
vipView.isHidden = !ringModel.vip
|
|
self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
|
|
self.changePlayerState(state: TSBusinessAudioPlayer.shared.currentPlayerState)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-// override var isSelected: Bool{
|
|
|
|
-// didSet{
|
|
|
|
-// debugPrint("isSelected = \(isSelected),indexPath = \(indexPath)")
|
|
|
|
-// ringView.isloading = isSelected
|
|
|
|
-// if isSelected, self.ringView.isPlay == false{
|
|
|
|
-//
|
|
|
|
-// if let model = model{
|
|
|
|
-// TSBusinessAudioPlayer.shared.playUrlString(model.response.musicUrl)
|
|
|
|
-// }else if let ringModel = ringModel{
|
|
|
|
-// TSBusinessAudioPlayer.shared.playUrlString(ringModel.audioUrl)
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// }else{
|
|
|
|
-// TSBusinessAudioPlayer.shared.stop()
|
|
|
|
-// backgroundColor = .cardColor
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
var playSelf:Bool{
|
|
var playSelf:Bool{
|
|
return TSBusinessAudioPlayer.shared.isPlayURLString(string: modelUrlString,indexPath: indexPath)
|
|
return TSBusinessAudioPlayer.shared.isPlayURLString(string: modelUrlString,indexPath: indexPath)
|
|
}
|
|
}
|
|
@@ -178,7 +214,12 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
make.width.height.equalTo(24)
|
|
make.width.height.equalTo(24)
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ contentView.addSubview(generateView)
|
|
|
|
+ generateView.snp.makeConstraints { make in
|
|
|
|
+ make.edges.equalToSuperview()
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func dealThings(){
|
|
func dealThings(){
|
|
@@ -189,9 +230,24 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// NotificationCenter.default.addObserver(forName: .kGenerateRintoneOperationChanged, object: nil, queue: nil) { notification in
|
|
|
|
+// if let model = self.model,
|
|
|
|
+// let userInfo = notification.userInfo as? [String: Any],
|
|
|
|
+// let uuid = userInfo["uuid"] as? String,
|
|
|
|
+// model.uuid == uuid,
|
|
|
|
+// let state = userInfo["state"] as? TSProgressState,
|
|
|
|
+// let actionInfo = userInfo["actionInfo"] as? TSActionInfoModel
|
|
|
|
+// {
|
|
|
|
+// self.updataActionInfoModelView(model: actionInfo)
|
|
|
|
+// }
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ override func prepareForReuse() {
|
|
|
|
+ super.prepareForReuse()
|
|
|
|
+ cancellable.removeAll()
|
|
|
|
+ }
|
|
func changePlayerState(state:TSBusinessAudioPlayer.PlayerState){
|
|
func changePlayerState(state:TSBusinessAudioPlayer.PlayerState){
|
|
if playSelf == false {
|
|
if playSelf == false {
|
|
self.ringView.isPlay = false
|
|
self.ringView.isPlay = false
|
|
@@ -236,13 +292,6 @@ extension TSAIRintoneHistoryCell : TSComponentView {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-// public var indexPath:IndexPath?{
|
|
|
|
-// if let attributes = colAttributes , let IndexPath = attributes[kIndexPath] as? IndexPath{
|
|
|
|
-// return IndexPath
|
|
|
|
-// }
|
|
|
|
-// return nil
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
public var itemActionHandler: ((Any?, IndexPath) -> Void)?{
|
|
public var itemActionHandler: ((Any?, IndexPath) -> Void)?{
|
|
if let colComponent = colComponent,let itemActionHandler = colComponent.itemActionHandler {
|
|
if let colComponent = colComponent,let itemActionHandler = colComponent.itemActionHandler {
|
|
return itemActionHandler
|
|
return itemActionHandler
|