//
//  QSLFeedbackVC.swift
//  QuickSearchLocation
//
//  Created by Destiny on 2025/10/23.
//

import UIKit
import IQKeyboardManagerSwift

class QSLFeedbackVC: QSLBaseController {
    
    override func viewWillAppear(_ animated:Bool) {
        //super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(false, animated: animated)
    }

    override func viewDidLoad() {
        self.title = "意见反馈"
        super.viewDidLoad()
        self.setUI()
    }
    
    @objc func bottomButtonAction(){
        if(self.phoneTextField.text?.count ?? 0 > 300){
            QSLLoading.error(text: "字数超出300")
            return
        }
        
        if(self.phoneTextField.text?.count ?? 0 == 0){
            QSLLoading.error(text: "请先输入内容")
            return
        }
        QSLLoading.show()
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
            QSLLoading.success(text: "提交成功")
            self.navigationController?.popViewController(animated: true)
        }
    }
    
    func setUI(){
        self.view.backgroundColor = .white
        self.view.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(20.rpx)
            make.top.equalTo(15.rpx)
            make.right.equalTo(-20.rpx)
            make.height.equalTo(20.rpx)
        }
        
        self.view.addSubview(phoneTextField)
        phoneTextField.snp.makeConstraints { make in
            make.left.equalTo(20.rpx)
            make.top.equalTo(titleLabel.snp.bottom).offset(15.rpx)
            make.right.equalTo(-20.rpx)
            make.height.equalTo(130.rpx)
        }
        
        self.view.addSubview(bottomButton)
        bottomButton.snp.makeConstraints { make in
            make.left.equalTo(28.rpx)
            make.right.equalTo(-28.rpx)
            make.height.equalTo(44.rpx)
            make.top.equalTo(phoneTextField.snp.bottom).offset(20.rpx)
        }
    }
    
    lazy var titleLabel: UILabel = {
      
        let label = UILabel()
        label.text("意见或建议：")
        label.mediumFont(16)
        label.textColor = QSLColor.Color_202020
        return label
    }()
    
    lazy var phoneTextField: IQTextView = {
       
        let textField = IQTextView()
        textField.backgroundColor = QSLColor.backGroundColor
        textField.textColor = QSLColor.Color_202020
        textField.font = UIFont.textF(14)

        let subcribeText = NSMutableAttributedString(string: "请详细描述您的问题")
        subcribeText.font(14)
        subcribeText.color(QSLColor.Color_888)
        textField.attributedPlaceholder = subcribeText
        
        return textField
    }()
    
    lazy var bottomButton: UIButton = {
        let btn = UIButton()
        btn.addRadius(radius: 22.rpx)
        btn.gradientBackgroundColor(color1: .hexStringColor(hexString: "#15CBA1"), color2: .hexStringColor(hexString: "#1FE0BA"), width: QSLConst.qsl_kScreenW - 32.rpx, height: 44.rpx, direction: .horizontal)
        btn.title("提交")
        btn.mediumFont(16)
        btn.textColor(.white)
        btn.setImageTitleLayout(.imgLeft, spacing: 0)
        btn.addTarget(self, action: #selector(bottomButtonAction), for: .touchUpInside)
        return btn
    }()
    
    
    

}
