// // AddRemarkView.swift // ADHTuanCan // // Created by 敖德亨 on 2023/10/30. // import UIKit class AddRemarkView: UIView { @IBOutlet weak var blackView: UIView! @IBOutlet weak var titleLab: UILabel! @IBOutlet weak var remarkTextView: UITextView! var dataModel : MealFoodMsgModel? var callBackBlock : (()->Void)? lazy var hud : MCHud! = { return MCHud() }() @IBAction func cancelAction(_ sender: UIButton) { self.hidden() } @IBAction func sureAction(_ sender: UIButton) { if self.remarkTextView.text.count == 0{ self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入备注信息", Etext: "Please enter remarks")) return } self.dataModel?.comment = self.remarkTextView.text if self.callBackBlock != nil{ self.callBackBlock!() } self.hidden() } /// 展示 public func showWithString(model : MealFoodMsgModel!){ self.dataModel = model self.titleLab.text = LanguagesUtil.createTextBy(Ctext: "为\(model.name ?? "")添加备注", Etext: "Add remarks for \(model.name ?? "")") self.remarkTextView.text = "\(model.comment ?? "")" self.remarkTextView.becomeFirstResponder() kAppDelegateWindow.addSubview(self) self.blackView.alpha = 0 self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT) UIView.animate(withDuration: 0.5) { self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT) self.layoutIfNeeded() } DELAY(0.5) { self.blackView.alpha = 0.3 } } /// 隐藏 public func hidden(){ self.blackView.alpha = 0 UIView.animate(withDuration: 0.5) { self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT) self.layoutIfNeeded() } DELAY(0.5) { self.removeFromSuperview() } } }