|
@@ -9,7 +9,7 @@ class TSAIDiyVideoTTVVC: TSAIDiyVideoTTBaseVC, UIPopoverPresentationControllerDe
|
|
|
lazy var aiModelView = TSAIModelElementView(frame: .zero)
|
|
|
|
|
|
lazy var promptTextView: TSDiyTextPromptElementView = {
|
|
|
- let promptTextView = TSDiyTextPromptElementView(randomTextArray: kRandomTextArray) { [weak self] _ in
|
|
|
+ let promptTextView = TSDiyTextPromptElementView(randomTextArray: kRandomImageToVideoArray) { [weak self] _ in
|
|
|
guard let self = self else { return }
|
|
|
}
|
|
|
promptTextView.textChangedBlock = { [weak self] text in
|
|
@@ -20,26 +20,39 @@ class TSAIDiyVideoTTVVC: TSAIDiyVideoTTBaseVC, UIPopoverPresentationControllerDe
|
|
|
promptTextView.sendBolck = { [weak self] text in
|
|
|
guard let self = self else { return }
|
|
|
self.viewModel.prompt = text
|
|
|
+ promptTextView.resignFirstResponder()
|
|
|
}
|
|
|
promptTextView.AIBolck = { [weak self] in
|
|
|
guard let self = self else { return }
|
|
|
- let vc = TSChatViewController()
|
|
|
- vc.viewModel.uiStyle = .perfectHint
|
|
|
-
|
|
|
- vc.textBlock = { [weak self] text, _ in
|
|
|
- guard let self = self else { return }
|
|
|
- promptTextView.setText(text: text)
|
|
|
- }
|
|
|
- kPushVC(target: self, modelVC: vc)
|
|
|
+// let vc = TSChatViewController()
|
|
|
+// vc.viewModel.uiStyle = .perfectHint
|
|
|
+//
|
|
|
+// vc.textBlock = { [weak self] text, _ in
|
|
|
+// guard let self = self else { return }
|
|
|
+// promptTextView.setText(text: text)
|
|
|
+// }
|
|
|
+// kPushVC(target: self, modelVC: vc)
|
|
|
+ kPushVC(target: self, modelVC: aiVc)
|
|
|
}
|
|
|
return promptTextView
|
|
|
}()
|
|
|
+
|
|
|
+ lazy var aiVc : TSChatViewController = {
|
|
|
+ let vc = TSChatViewController()
|
|
|
+ vc.viewModel.uiStyle = .perfectHint
|
|
|
+ vc.textBlock = { [weak self] text, _ in
|
|
|
+ guard let self = self else { return }
|
|
|
+ promptTextView.setText(text: text)
|
|
|
+ }
|
|
|
+ return vc
|
|
|
+ }()
|
|
|
+
|
|
|
lazy var style = TSDiyStyleElementView()
|
|
|
lazy var resolution = TSResolutionElementView(aiType: viewModel.selectedAiModelType)
|
|
|
lazy var length = TSVideoLengthElementView(aiType: viewModel.selectedAiModelType)
|
|
|
lazy var movement = TSMovementElementView(aiType: viewModel.selectedAiModelType)
|
|
|
lazy var aspectRadio = TSAspectRatioElementView(aiType: viewModel.selectedAiModelType)
|
|
|
-
|
|
|
+
|
|
|
var viewModel: TSAIDiyVideoTTVViewModel = .init()
|
|
|
|
|
|
override var videoGenerateModel: TSAIDiyVideoGenerateModel {
|
|
@@ -62,7 +75,7 @@ class TSAIDiyVideoTTVVC: TSAIDiyVideoTTBaseVC, UIPopoverPresentationControllerDe
|
|
|
resolution,
|
|
|
length,
|
|
|
movement,
|
|
|
- aspectRadio
|
|
|
+ aspectRadio,
|
|
|
]
|
|
|
}
|
|
|
|
|
@@ -72,6 +85,9 @@ class TSAIDiyVideoTTVVC: TSAIDiyVideoTTBaseVC, UIPopoverPresentationControllerDe
|
|
|
addActions()
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func addObservers() {
|
|
|
viewModel.$selectedAiModelType.receive(on: DispatchQueue.main).sink { [weak self] type in
|
|
|
self?.aiModelView.updateType(type: type)
|
|
@@ -81,34 +97,39 @@ class TSAIDiyVideoTTVVC: TSAIDiyVideoTTBaseVC, UIPopoverPresentationControllerDe
|
|
|
}
|
|
|
|
|
|
func addActions() {
|
|
|
- aiModelView.addTapAction { [weak self] in
|
|
|
- guard let self = self else { return }
|
|
|
- // 初始化内容控制器
|
|
|
- let contentVC = TSDiyVideoPopoverViewController()
|
|
|
- contentVC.currentType = self.viewModel.selectedAiModelType
|
|
|
- contentVC.onSelected = { [weak self] type in
|
|
|
- guard let self = self else { return }
|
|
|
- viewModel.selectedAiModelType = type
|
|
|
- }
|
|
|
- // 设置模态呈现样式为Popover
|
|
|
- contentVC.modalPresentationStyle = .popover
|
|
|
-
|
|
|
- // 配置Popover属性
|
|
|
- if let popoverPresentationController = contentVC.popoverPresentationController {
|
|
|
- popoverPresentationController.delegate = self
|
|
|
- popoverPresentationController.sourceView = self.aiModelView
|
|
|
- popoverPresentationController.sourceRect = .init(origin: .init(x: self.aiModelView.bounds.origin.x, y: self.aiModelView.bounds.origin.y + 100), size: self.aiModelView.bounds.size)
|
|
|
- popoverPresentationController.permittedArrowDirections = []
|
|
|
- popoverPresentationController.backgroundColor = .fromHex("#222222")
|
|
|
- }
|
|
|
-
|
|
|
- // 呈现Popover
|
|
|
- self.present(contentVC, animated: true, completion: nil)
|
|
|
- }
|
|
|
+// aiModelView.addTapAction { [weak self] in
|
|
|
+// guard let self = self else { return }
|
|
|
+// // 初始化内容控制器
|
|
|
+// let contentVC = TSDiyVideoPopoverViewController()
|
|
|
+// contentVC.currentType = self.viewModel.selectedAiModelType
|
|
|
+// contentVC.onSelected = { [weak self] type in
|
|
|
+// guard let self = self else { return }
|
|
|
+// viewModel.selectedAiModelType = type
|
|
|
+// }
|
|
|
+// // 设置模态呈现样式为Popover
|
|
|
+// contentVC.modalPresentationStyle = .popover
|
|
|
+//
|
|
|
+// // 配置Popover属性
|
|
|
+// if let popoverPresentationController = contentVC.popoverPresentationController {
|
|
|
+// popoverPresentationController.delegate = self
|
|
|
+// popoverPresentationController.sourceView = self.aiModelView
|
|
|
+// popoverPresentationController.sourceRect = .init(origin: .init(x: self.aiModelView.bounds.origin.x, y: self.aiModelView.bounds.origin.y + 100), size: self.aiModelView.bounds.size)
|
|
|
+// popoverPresentationController.permittedArrowDirections = []
|
|
|
+// popoverPresentationController.backgroundColor = .fromHex("#222222")
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 呈现Popover
|
|
|
+// self.present(contentVC, animated: true, completion: nil)
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
// 关键: 确保在iPhone上以Popover形式显示而非全屏
|
|
|
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
|
|
|
return .none
|
|
|
}
|
|
|
+
|
|
|
+ override func viewWillDisappear(_ animated: Bool) {
|
|
|
+ super.viewWillDisappear(animated)
|
|
|
+ promptTextView.customTextView.resignFirstResponder()
|
|
|
+ }
|
|
|
}
|