|
@@ -14,22 +14,30 @@ class TSGenmojiItemCell: TSBaseCollectionCell ,TSSimpleConfigurableView {
|
|
|
didSet {
|
|
|
if let dataModel = data as? TSActionInfoModel{
|
|
|
self.dataModel = dataModel
|
|
|
- self.updataActionInfoModelView(model: dataModel)
|
|
|
- if let operation = TSGeneratePTPOperationQueue.shared.findOperation(uuid: dataModel.uuid) as? TSGeneratePTPOperation {
|
|
|
- DispatchQueue.main.async {
|
|
|
- operation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
|
|
|
- guard let self = self else { return }
|
|
|
- DispatchQueue.main.async {
|
|
|
- self.updataActionInfoModelView(model: actionInfoModel)
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var operation:TSGeneratePTPOperation?
|
|
|
+ var dataModel:TSActionInfoModel = TSActionInfoModel(){
|
|
|
+ didSet{
|
|
|
+ self.updataActionInfoModelView(model: dataModel)
|
|
|
+ if let operation = TSGeneratePTPOperationQueue.shared.findOperation(uuid: dataModel.uuid) as? TSGeneratePTPOperation {
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ operation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
|
|
|
+ guard let self = self else { return }
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self.updataActionInfoModelView(model: actionInfoModel)
|
|
|
}
|
|
|
}
|
|
|
+ self.operation = operation
|
|
|
}
|
|
|
+ }else{
|
|
|
+ self.operation?.currentActionInfoModelChanged = nil
|
|
|
+ self.operation = nil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- var dataModel:TSActionInfoModel = TSActionInfoModel()
|
|
|
+
|
|
|
lazy var textLabel: UILabel = {
|
|
|
let textLabel = UILabel.createLabel(
|
|
|
text: "Example".localized,
|
|
@@ -69,6 +77,7 @@ class TSGenmojiItemCell: TSBaseCollectionCell ,TSSimpleConfigurableView {
|
|
|
}else{
|
|
|
if kJudgeVipFreeType(vipFreeNumType: .picToPic){ return }
|
|
|
TSGeneratePTPOperationQueue.shared.creatOperation(uuid: dataModel.uuid).creatImage(oldModel: dataModel)
|
|
|
+ generateView.setProgress(progress: 0.0)
|
|
|
}
|
|
|
}
|
|
|
return generateView
|
|
@@ -101,21 +110,9 @@ class TSGenmojiItemCell: TSBaseCollectionCell ,TSSimpleConfigurableView {
|
|
|
super.renderView(with: object, component: component, attributes: attributes)
|
|
|
if let itemModel = object as? TSGenmojiCoLItemModel{
|
|
|
self.dataModel = itemModel.dataModel
|
|
|
- self.updataActionInfoModelView(model: itemModel.dataModel)
|
|
|
- if let operation = TSGeneratePTPOperationQueue.shared.findOperation(uuid: itemModel.dataModel.uuid) as? TSGeneratePTPOperation {
|
|
|
- DispatchQueue.main.async {
|
|
|
- operation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
|
|
|
- guard let self = self else { return }
|
|
|
- DispatchQueue.main.async {
|
|
|
- self.updataActionInfoModelView(model: actionInfoModel)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func updataActionInfoModelView(model:TSActionInfoModel){
|
|
|
|
|
|
if model.modelType == .example {
|
|
@@ -159,138 +156,3 @@ class TSGenmojiItemCell: TSBaseCollectionCell ,TSSimpleConfigurableView {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-//class TSGenmojiItemCell: TSBaseCollectionCell {
|
|
|
-// var itemModel:TSGenmojiCoLItemModel = TSGenmojiCoLItemModel()
|
|
|
-// lazy var textLabel: UILabel = {
|
|
|
-// let textLabel = UILabel.createLabel(
|
|
|
-// text: "Example".localized,
|
|
|
-// font: .font(size: 12),
|
|
|
-// textColor: .white
|
|
|
-// )
|
|
|
-// return textLabel
|
|
|
-// }()
|
|
|
-//
|
|
|
-// lazy var exampleView: UIView = {
|
|
|
-// let exampleView = UIView()
|
|
|
-// exampleView.backgroundColor = "#232323".uiColor.withAlphaComponent(0.3)
|
|
|
-//
|
|
|
-// exampleView.addSubview(textLabel)
|
|
|
-// textLabel.snp.makeConstraints { make in
|
|
|
-// make.top.edges.equalTo(UIEdgeInsets(top: 4, left: 6, bottom: 4, right: 6))
|
|
|
-// }
|
|
|
-// exampleView.isHidden = true
|
|
|
-// exampleView.cornerRadius = 10.0
|
|
|
-// return exampleView
|
|
|
-// }()
|
|
|
-//
|
|
|
-// lazy var showImageView: UIImageView = {
|
|
|
-// let showImageView = UIImageView.createImageView(imageName:"",contentMode: .scaleAspectFill)
|
|
|
-// showImageView.backgroundColor = .gray
|
|
|
-// showImageView.layer.cornerRadius = 18
|
|
|
-// return showImageView
|
|
|
-// }()
|
|
|
-//
|
|
|
-// lazy var generateView: TSImageGenerateView = {
|
|
|
-// let generateView = TSImageGenerateView()
|
|
|
-// generateView.isHidden = true
|
|
|
-// generateView.refreshHandel = { [weak self] in
|
|
|
-// guard let self = self else { return }
|
|
|
-// if itemModel.dataModel.upImageURLExpired { //任务已经过期了
|
|
|
-// self.actionHandler(any: "delete_task_expired")
|
|
|
-// }else{
|
|
|
-// if kJudgeVipFreeType(vipFreeNumType: .picToPic){ return }
|
|
|
-// TSGeneratePTPOperationQueue.shared.creatOperation(uuid: itemModel.dataModel.uuid).creatImage(oldModel: itemModel.dataModel)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return generateView
|
|
|
-// }()
|
|
|
-//
|
|
|
-// override func creatUI() {
|
|
|
-// debugPrint("TSGenmojiItemCell creatUI")
|
|
|
-// contentView.cornerRadius = 16.0
|
|
|
-// contentView.addSubview(showImageView)
|
|
|
-// showImageView.snp.makeConstraints { make in
|
|
|
-// make.top.equalTo(0)
|
|
|
-// make.leading.equalTo(0)
|
|
|
-// make.trailing.bottom.equalTo(0)
|
|
|
-// }
|
|
|
-//
|
|
|
-// contentView.addSubview(exampleView)
|
|
|
-// exampleView.snp.makeConstraints { make in
|
|
|
-// make.top.equalTo(8)
|
|
|
-// make.leading.equalTo(8)
|
|
|
-// make.height.equalTo(20)
|
|
|
-// }
|
|
|
-//
|
|
|
-// contentView.addSubview(generateView)
|
|
|
-// generateView.snp.makeConstraints { make in
|
|
|
-// make.edges.equalToSuperview()
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// override func renderView(with object: Any?, component: TSCollectionViewComponent, attributes: [String : Any]?) {
|
|
|
-// super.renderView(with: object, component: component, attributes: attributes)
|
|
|
-// debugPrint("TSGenmojiItemCell renderView")
|
|
|
-// if let itemModel = object as? TSGenmojiCoLItemModel{
|
|
|
-// self.itemModel = itemModel
|
|
|
-// self.updataActionInfoModelView(model: itemModel.dataModel)
|
|
|
-// if let operation = TSGeneratePTPOperationQueue.shared.findOperation(uuid: itemModel.dataModel.uuid) as? TSGeneratePTPOperation {
|
|
|
-// DispatchQueue.main.async {
|
|
|
-// operation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
|
|
|
-// guard let self = self else { return }
|
|
|
-// DispatchQueue.main.async {
|
|
|
-// self.updataActionInfoModelView(model: actionInfoModel)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// func updataActionInfoModelView(model:TSActionInfoModel){
|
|
|
-//
|
|
|
-// if model.modelType == .example {
|
|
|
-// model.actionStatus = .success
|
|
|
-// }
|
|
|
-// showImageView.image = nil
|
|
|
-//// dePrint("updataActionInfoModelView model.actionStatus 收到 = \(model.actionStatus)")
|
|
|
-// switch model.actionStatus {
|
|
|
-// case .pending,.running:
|
|
|
-// generateView.isHidden = false
|
|
|
-// generateView.setProgress(progress: model.percent)
|
|
|
-// case .success:
|
|
|
-// generateView.isHidden = true
|
|
|
-//
|
|
|
-// if itemModel.dataModel.modelType == .example {
|
|
|
-//
|
|
|
-// if itemModel.style == .ptpPicHistory {
|
|
|
-// textLabel.text = "Example".localized
|
|
|
-// }
|
|
|
-//
|
|
|
-// exampleView.isHidden = false
|
|
|
-// showImageView.image = UIImage(named: model.response.resultUrl)
|
|
|
-// }else{
|
|
|
-// exampleView.isHidden = true
|
|
|
-// showImageView.setAsyncImage(urlString: model.response.resultUrl,contentMode: .scaleAspectFill,backgroundColor: .white.withAlphaComponent(0.1))
|
|
|
-// }
|
|
|
-//
|
|
|
-// case .failed:
|
|
|
-// generateView.isHidden = false
|
|
|
-// if itemModel.dataModel.upImageURLExpired { //任务已经过期了
|
|
|
-// generateView.setTaskExpired()
|
|
|
-// }else{
|
|
|
-// generateView.setFail()
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// if generateView.isHidden == false {
|
|
|
-// generateView.setBgImageViewURLString(bgImageURLString: model.request.imageUrl)
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//}
|