//
//  WP_FeedVC.swift
//  WallpaperHD_Live
//
//  Created by 忆海16 on 2024/7/22.
//

import UIKit
import SVProgressHUD

class WP_FeedVC: WP_RootVC,UITextViewDelegate {
    @IBOutlet weak var feedTextV: UITextView!
    
    
    @IBOutlet weak var sureBtn: UIButton!
    
    let placeholderLabel = UILabel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // 添加占位符Label
        placeholderLabel.text = "Please enter the content..."
        placeholderLabel.textColor = UIColor.lightGray
        placeholderLabel.frame = CGRect(x: 5, y: 8, width: feedTextV.frame.width - 10, height: 20)
        feedTextV.addSubview(placeholderLabel)
       
        feedTextV.layer.cornerRadius = 10
        feedTextV.layer.borderColor = UIColor.black.cgColor
        feedTextV.layer.borderWidth = 1
        sureBtn.layer.cornerRadius = 10
        feedTextV.delegate = self
    }
    
    func textViewDidChange(_ textView: UITextView) {
        placeholderLabel.isHidden = !textView.text.isEmpty
    }

    @IBAction func back(_ sender: Any) {
        self.navigationController?.popViewController(animated: true)
        
    }
    
    
    
    @IBAction func sure(_ sender: Any) {
        if feedTextV.text.count <= 0 {
            SVProgressHUD.showInfo(withStatus: "Please enter your feedback")
            DispatchQueue.global().asyncAfter(deadline: .now() + 1.0) {
            SVProgressHUD.dismiss()
            }
        }else{
            SVProgressHUD.showSuccess(withStatus: "Thank you for your valuable feedback")
            DispatchQueue.global().asyncAfter(deadline: .now() + 1.0) {
            SVProgressHUD.dismiss()
            }
            self.feedTextV.text = ""
            self.navigationController?.popViewController(animated: true)
        }
        
    }
    
}
