|
@@ -5,8 +5,32 @@
|
|
|
// Created by 100Years on 2025/1/17.
|
|
|
//
|
|
|
|
|
|
-class TSGenmojiItemCell: TSBaseCollectionCell {
|
|
|
- var itemModel:TSGenmojiCoLItemModel = TSGenmojiCoLItemModel()
|
|
|
+
|
|
|
+class TSGenmojiItemCell: TSBaseCollectionCell ,TSSimpleConfigurableView {
|
|
|
+
|
|
|
+ var delegate: (any TSSmalCoacopods.TSSimpleCollectionViewDelegate)?
|
|
|
+ var indexPath: IndexPath?
|
|
|
+ var data: Any? {
|
|
|
+ didSet {
|
|
|
+ debugPrint("TSGenmojiItemCell renderView")
|
|
|
+ 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 dataModel:TSActionInfoModel = TSActionInfoModel()
|
|
|
lazy var textLabel: UILabel = {
|
|
|
let textLabel = UILabel.createLabel(
|
|
|
text: "Example".localized,
|
|
@@ -41,17 +65,18 @@ class TSGenmojiItemCell: TSBaseCollectionCell {
|
|
|
generateView.isHidden = true
|
|
|
generateView.refreshHandel = { [weak self] in
|
|
|
guard let self = self else { return }
|
|
|
- if itemModel.dataModel.upImageURLExpired { //任务已经过期了
|
|
|
+ if 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)
|
|
|
+ TSGeneratePTPOperationQueue.shared.creatOperation(uuid: dataModel.uuid).creatImage(oldModel: dataModel)
|
|
|
}
|
|
|
}
|
|
|
return generateView
|
|
|
}()
|
|
|
|
|
|
override func creatUI() {
|
|
|
+ debugPrint("TSGenmojiItemCell creatUI")
|
|
|
contentView.cornerRadius = 16.0
|
|
|
contentView.addSubview(showImageView)
|
|
|
showImageView.snp.makeConstraints { make in
|
|
@@ -73,26 +98,6 @@ class TSGenmojiItemCell: TSBaseCollectionCell {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- override func renderView(with object: Any?, component: TSCollectionViewComponent, attributes: [String : Any]?) {
|
|
|
- super.renderView(with: object, component: component, attributes: attributes)
|
|
|
- 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 {
|
|
@@ -107,9 +112,9 @@ class TSGenmojiItemCell: TSBaseCollectionCell {
|
|
|
case .success:
|
|
|
generateView.isHidden = true
|
|
|
|
|
|
- if itemModel.dataModel.modelType == .example {
|
|
|
+ if dataModel.modelType == .example {
|
|
|
|
|
|
- if itemModel.style == .ptpPicHistory {
|
|
|
+ if dataModel.modelType == .example {
|
|
|
textLabel.text = "Example".localized
|
|
|
}
|
|
|
|
|
@@ -122,7 +127,7 @@ class TSGenmojiItemCell: TSBaseCollectionCell {
|
|
|
|
|
|
case .failed:
|
|
|
generateView.isHidden = false
|
|
|
- if itemModel.dataModel.upImageURLExpired { //任务已经过期了
|
|
|
+ if dataModel.upImageURLExpired { //任务已经过期了
|
|
|
generateView.setTaskExpired()
|
|
|
}else{
|
|
|
generateView.setFail()
|
|
@@ -136,3 +141,138 @@ class TSGenmojiItemCell: TSBaseCollectionCell {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+//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)
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//}
|