|
@@ -14,7 +14,7 @@ class TSPTPGeneratorVC: TSAIPhotoGeneratorBaseVC {
|
|
var promptSort:String
|
|
var promptSort:String
|
|
var imageUrl:String
|
|
var imageUrl:String
|
|
var upLoadImage:UIImage
|
|
var upLoadImage:UIImage
|
|
-
|
|
|
|
|
|
+ var progressState = TSProgressState.none
|
|
init(prompt:String,promptSort:String,imageUrl:String,upLoadImage:UIImage,complete:@escaping ((TSGenmojiModel)->Void)) {
|
|
init(prompt:String,promptSort:String,imageUrl:String,upLoadImage:UIImage,complete:@escaping ((TSGenmojiModel)->Void)) {
|
|
self.prompt = prompt
|
|
self.prompt = prompt
|
|
self.promptSort = promptSort
|
|
self.promptSort = promptSort
|
|
@@ -50,29 +50,32 @@ class TSPTPGeneratorVC: TSAIPhotoGeneratorBaseVC {
|
|
}
|
|
}
|
|
|
|
|
|
override func closePage() {
|
|
override func closePage() {
|
|
-
|
|
|
|
- TSCustomAlertController.show(in: self, config: TSCustomAlertController.AlertConfig(
|
|
|
|
- message: "As you leave, your generation will be interrupted and no result.".localized,
|
|
|
|
- messageColor: .white,
|
|
|
|
- messageFont: .systemFont(ofSize: 16),
|
|
|
|
-
|
|
|
|
- cancelTitle: "Leave".localized,
|
|
|
|
- cancelColor: .white,
|
|
|
|
-
|
|
|
|
- confirmTitle: "Wait".localized,
|
|
|
|
- confirmColor: .themeColor,
|
|
|
|
-
|
|
|
|
- cancelAction: { [weak self] in
|
|
|
|
- guard let self = self else { return }
|
|
|
|
- print("用户点击了Leave")
|
|
|
|
- viewModel.cancelAllRequest()
|
|
|
|
- self.dismiss(animated: true, completion: nil)
|
|
|
|
- },
|
|
|
|
- confirmAction: {
|
|
|
|
- print("用户点击了Stay")
|
|
|
|
- }
|
|
|
|
- ))
|
|
|
|
-
|
|
|
|
|
|
+ if progressState.isResult {
|
|
|
|
+ viewModel.cancelAllRequest()
|
|
|
|
+ self.dismiss(animated: true, completion: nil)
|
|
|
|
+ }else{
|
|
|
|
+ TSCustomAlertController.show(in: self, config: TSCustomAlertController.AlertConfig(
|
|
|
|
+ message: "As you leave, your generation will be interrupted and no result.".localized,
|
|
|
|
+ messageColor: .white,
|
|
|
|
+ messageFont: .systemFont(ofSize: 16),
|
|
|
|
+
|
|
|
|
+ cancelTitle: "Leave".localized,
|
|
|
|
+ cancelColor: .white,
|
|
|
|
+
|
|
|
|
+ confirmTitle: "Wait".localized,
|
|
|
|
+ confirmColor: .themeColor,
|
|
|
|
+
|
|
|
|
+ cancelAction: { [weak self] in
|
|
|
|
+ guard let self = self else { return }
|
|
|
|
+ print("用户点击了Leave")
|
|
|
|
+ viewModel.cancelAllRequest()
|
|
|
|
+ self.dismiss(animated: true, completion: nil)
|
|
|
|
+ },
|
|
|
|
+ confirmAction: {
|
|
|
|
+ print("用户点击了Stay")
|
|
|
|
+ }
|
|
|
|
+ ))
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//重试
|
|
//重试
|
|
@@ -124,7 +127,9 @@ extension TSPTPGeneratorVC {
|
|
|
|
|
|
}
|
|
}
|
|
extension TSPTPGeneratorVC {
|
|
extension TSPTPGeneratorVC {
|
|
|
|
+
|
|
func upDateView(state:TSProgressState,model:TSGenmojiModel?){
|
|
func upDateView(state:TSProgressState,model:TSGenmojiModel?){
|
|
|
|
+ progressState = state
|
|
switch state {
|
|
switch state {
|
|
case .failed(let errorStr):
|
|
case .failed(let errorStr):
|
|
showError(text: errorStr)
|
|
showError(text: errorStr)
|
|
@@ -187,7 +192,6 @@ extension TSPTPGeneratorVC {
|
|
bottomView.isHidden = false
|
|
bottomView.isHidden = false
|
|
netWorkImageView.isHidden = false
|
|
netWorkImageView.isHidden = false
|
|
|
|
|
|
-
|
|
|
|
self.netWorkImageView.setAsyncImage(urlString: model.response.resultUrl,placeholder:kPlaceholderImage,backgroundColor:netWorkImageView.backgroundColor!){ [weak self] image in
|
|
self.netWorkImageView.setAsyncImage(urlString: model.response.resultUrl,placeholder:kPlaceholderImage,backgroundColor:netWorkImageView.backgroundColor!){ [weak self] image in
|
|
guard let self = self else { return }
|
|
guard let self = self else { return }
|
|
|
|
|