AddRemarkView.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // AddRemarkView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/30.
  6. //
  7. import UIKit
  8. class AddRemarkView: UIView {
  9. @IBOutlet weak var blackView: UIView!
  10. @IBOutlet weak var titleLab: UILabel!
  11. @IBOutlet weak var remarkTextView: UITextView!
  12. var dataModel : MealFoodMsgModel?
  13. var callBackBlock : (()->Void)?
  14. lazy var hud : MCHud! = {
  15. return MCHud()
  16. }()
  17. @IBAction func cancelAction(_ sender: UIButton) {
  18. self.hidden()
  19. }
  20. @IBAction func sureAction(_ sender: UIButton) {
  21. if self.remarkTextView.text.count == 0{
  22. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入备注信息", Etext: "Please enter remarks"))
  23. return
  24. }
  25. self.dataModel?.comment = self.remarkTextView.text
  26. if self.callBackBlock != nil{
  27. self.callBackBlock!()
  28. }
  29. self.hidden()
  30. }
  31. /// 展示
  32. public func showWithString(model : MealFoodMsgModel!){
  33. self.dataModel = model
  34. self.titleLab.text = LanguagesUtil.createTextBy(Ctext: "为\(model.name ?? "")添加备注", Etext: "Add remarks for \(model.name ?? "")")
  35. self.remarkTextView.text = "\(model.comment ?? "")"
  36. self.remarkTextView.becomeFirstResponder()
  37. kAppDelegateWindow.addSubview(self)
  38. self.blackView.alpha = 0
  39. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  40. UIView.animate(withDuration: 0.5) {
  41. self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  42. self.layoutIfNeeded()
  43. }
  44. DELAY(0.5) {
  45. self.blackView.alpha = 0.3
  46. }
  47. }
  48. /// 隐藏
  49. public func hidden(){
  50. self.blackView.alpha = 0
  51. UIView.animate(withDuration: 0.5) {
  52. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  53. self.layoutIfNeeded()
  54. }
  55. DELAY(0.5) {
  56. self.removeFromSuperview()
  57. }
  58. }
  59. }