123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- //
- // TSDiyVideoPromptElementView.swift
- // AIEmoji
- //
- // Created by nkl on 2025/7/29.
- //
- import Foundation
- class TSDiyTextPromptElementView: TSPromptTextView, TSDiyVideoElement {
- var type: TSDiyVideoElementType {
- .textPrompt
- }
- var param: String {
- ""
- }
-
- override init(randomTextArray: [String], textChangedBlock: @escaping (String) -> Void) {
- super.init(randomTextArray: randomTextArray, textChangedBlock: textChangedBlock)
-
- }
-
- override func makeConstraints() {
- super.makeConstraints()
- }
-
- @MainActor required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
- class TSDiyVideoPromptElementView: TSPromptTextView, TSDiyVideoElement {
- var dependElement: (any TSDiyVideoElement)?
- var type: TSDiyVideoElementType {
- .imagePrompt
- }
- var param: String { "" }
- var uploadClickAction: (() -> Void)?
- var deleteClickAction: (() -> Void)?
- lazy var uploadView: TSDiyVideoUploadImageView = {
- let upload = TSDiyVideoUploadImageView()
- upload.clickBgViewBlock = { [weak self] in
- guard let self = self else { return }
- uploadClickAction?()
- }
- upload.clickDeleteBlock = { [weak self] in
- guard let self = self else { return }
- deleteClickAction?()
- }
- return upload
- }()
- lazy var titleLabel: UILabel = {
- let title : UILabel = .createLabel()
- title.text = type.sectionTitle
- title.textColor = .white.withAlphaComponent(0.8)
- title.font = .font(size: 14,weight: .medium)
- return title
- }()
- override init(randomTextArray: [String], textChangedBlock: @escaping (String) -> Void) {
- super.init(randomTextArray: randomTextArray, textChangedBlock: textChangedBlock)
- self.inspirationBtn.isHidden = true
- }
- override func creatUI() {
- addChildren()
- super.creatUI()
- }
- @objc func pickSinglePhoto() {
- }
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- func addChildren() {
- contentView.addSubview(titleLabel)
- textBgView.addSubview(uploadView)
- }
- override func makeConstraints() {
- titleLabel.snp.makeConstraints { make in
- make.leading.equalToSuperview().offset(16)
- make.top.equalToSuperview().offset(22)
- }
- textBgView.snp.makeConstraints { make in
- make.top.equalTo(titleLabel.snp.bottom).offset(12)
- make.horizontalEdges.equalToSuperview().inset(16)
- make.bottom.equalToSuperview()
- }
- let itemWidth = k_ScreenWidth - 56
- let itemHeight = itemWidth * (230.0 / 320.0)
- uploadView.snp.makeConstraints { make in
- make.horizontalEdges.equalToSuperview()
- make.top.equalToSuperview().offset(12)
- make.height.equalTo(itemHeight)
- }
- customTextView.snp.makeConstraints { make in
- make.top.equalTo(uploadView.snp.bottom).offset(12)
- make.horizontalEdges.equalToSuperview().inset(16)
- make.bottom.equalTo(-52)
- make.height.equalTo(100)
- }
- // inspirationBtn.snp.makeConstraints { make in
- // make.height.equalTo(28)
- // make.leading.equalTo(16)
- // make.top.equalTo(customTextView.snp.bottom).offset(12)
- // make.bottom.equalTo(textBgView.snp.bottom).offset(-12)
- // }
- AIView.snp.remakeConstraints { make in
- make.height.equalTo(28)
- make.bottom.equalTo(-16)
- make.leading.equalToSuperview().offset(16)
- }
- clearBtn.snp.makeConstraints { make in
- make.width.height.equalTo(16)
- make.centerY.equalTo(inspirationBtn)
- make.trailing.equalTo(-16)
- }
- }
- }
|