|
@@ -7,10 +7,16 @@
|
|
|
|
|
|
class TSGenmojiGennerateCell : TSBaseCollectionCell{
|
|
|
lazy var robotImageView: UIImageView = {
|
|
|
- let robotImageView = UIImageView.createImageView(imageName: "genmoji_robot")
|
|
|
+ let robotImageView = UIImageView.createImageView(imageName: "aichat_avatar")
|
|
|
return robotImageView
|
|
|
}()
|
|
|
|
|
|
+
|
|
|
+ lazy var randomTextPicker: TSRandomTextPicker = {
|
|
|
+ let textPicker = TSRandomTextPicker(texts: kRandomTextArray)
|
|
|
+ return textPicker
|
|
|
+ }()
|
|
|
+
|
|
|
lazy var customTextView: TSCustomTextView = {
|
|
|
let customTextView = TSCustomTextView(
|
|
|
placeholder: "Type your idea here.",
|
|
@@ -38,6 +44,25 @@ class TSGenmojiGennerateCell : TSBaseCollectionCell{
|
|
|
}()
|
|
|
|
|
|
|
|
|
+ lazy var inspirationBtn: UIButton = {
|
|
|
+ let inspirationBtn = UIButton.createButton(
|
|
|
+ title: "Hint Inspiration".localized,
|
|
|
+ image: UIImage(named: "inspiration_yellow"),
|
|
|
+ backgroundColor:"#FECB34".uiColor.withAlphaComponent(0.1),
|
|
|
+ font: .font(size: 12),
|
|
|
+ titleColor: .themeColor,
|
|
|
+ corner: 8.0)
|
|
|
+ { [weak self] in
|
|
|
+ guard let self = self else { return }
|
|
|
+ customTextView.text = randomTextPicker.getRandomText()
|
|
|
+ textViewDidChange(customTextView)
|
|
|
+ }
|
|
|
+ inspirationBtn.contentEdgeInsets = UIEdgeInsets(top: 4, left: 7, bottom: 4, right: 7)
|
|
|
+ inspirationBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: -4, bottom: 0, right: 0)
|
|
|
+ inspirationBtn.isHidden = true
|
|
|
+ return inspirationBtn
|
|
|
+ }()
|
|
|
+
|
|
|
override func creatUI() {
|
|
|
|
|
|
contentView.addSubview(robotImageView)
|
|
@@ -55,6 +80,13 @@ class TSGenmojiGennerateCell : TSBaseCollectionCell{
|
|
|
make.height.equalTo(182.0*kDesignScale)
|
|
|
}
|
|
|
|
|
|
+ contentView.addSubview(inspirationBtn)
|
|
|
+ inspirationBtn.snp.makeConstraints { make in
|
|
|
+ make.height.equalTo(28)
|
|
|
+ make.bottom.equalTo(customTextView.snp.bottom).offset(-8)
|
|
|
+ make.trailing.equalTo(customTextView.snp.trailing).offset(-8)
|
|
|
+ }
|
|
|
+
|
|
|
contentView.addSubview(submitBtn)
|
|
|
submitBtn.snp.makeConstraints { make in
|
|
|
make.top.equalTo(customTextView.snp.bottom).offset(16)
|
|
@@ -76,20 +108,34 @@ class TSGenmojiGennerateCell : TSBaseCollectionCell{
|
|
|
super.renderView(with: object, component: component, attributes: attributes)
|
|
|
|
|
|
var title = "Generate"
|
|
|
- if kPurchaseDefault.isVip == false,
|
|
|
- let itemModel = object as? TSGenmojiCoLItemModel{
|
|
|
+ if let itemModel = object as? TSGenmojiCoLItemModel{
|
|
|
if itemModel.style == .generate{
|
|
|
title = "Generate (\(kPurchaseDefault.freeNum(type: .generatePic)))"
|
|
|
+ inspirationBtn.isHidden = true
|
|
|
}else if itemModel.style == .textPicGenerate{
|
|
|
title = "Generate (\(kPurchaseDefault.freeNum(type: .textGeneratePic)))"
|
|
|
+ inspirationBtn.isHidden = false
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if kPurchaseDefault.isVip == true {
|
|
|
+ title = "Generate"
|
|
|
+ }
|
|
|
submitBtn.setTitle(title, for: .normal)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
extension TSGenmojiGennerateCell: UITextViewDelegate{
|
|
|
+
|
|
|
+ func textViewDidBeginEditing(_ textView: UITextView) {
|
|
|
+ self.colComponent?.collectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .centeredVertically, animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
func textViewDidChange(_ textView: UITextView) {
|
|
|
submitBtn.isEnabled = textView.text.replacingOccurrences(of: " ", with: "") .count > 0
|
|
|
}
|