Blame view

App/firstInput/VCSendTraoDoi.swift 4.27 KB
d774f0637   Trịnh Văn Quân   fisrt comit
1
  import UIKit
1341bf603   Trịnh Văn Quân   version 1.1
2
  import GeneralUtils
fbd62afcf   Trịnh Văn Quân   version 1.2.2
3
  import Alamofire
d774f0637   Trịnh Văn Quân   fisrt comit
4
5
6
7
  
  class VCSendTraoDoi: UIViewController {
      @IBOutlet weak var edtTenCty: UITextField!
      @IBOutlet weak var edtPhone: UITextField!
fbd62afcf   Trịnh Văn Quân   version 1.2.2
8
9
      @IBOutlet weak var edtAdress: UITextViewCustom!
      @IBOutlet weak var vTopLogo: VTopLogo!
d774f0637   Trịnh Văn Quân   fisrt comit
10
11
12
13
14
15
16
17
18
      static func getInstance() -> VCSendTraoDoi {
          let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
          let vcOpen = storyboard.instantiateViewController(withIdentifier: "VCSendTraoDoi") as! VCSendTraoDoi
          return vcOpen
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
  //        registerKeyBoardEvent()
fbd62afcf   Trịnh Văn Quân   version 1.2.2
19
20
21
22
          addInputAccessoryForTextFields([edtTenCty, edtPhone, edtAdress], dismissable: true, previousNextable: true)
          vTopLogo.leftBtnClick = {
              self.btnCancelClick(self.vTopLogo)
          }
d774f0637   Trịnh Văn Quân   fisrt comit
23
24
25
26
27
28
29
      }
  
      @IBAction func btnCancelClick(_ sender: Any) {
          _ = getVcRoot()?.changeCurrentController(VCInputId.getInstance())
      }
  
      @IBAction func btnSendClick(_ sender: Any) {
fbd62afcf   Trịnh Văn Quân   version 1.2.2
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
          let companyName = self.edtTenCty.text;
          let phoneNumber = self.edtPhone.text;
          let address = self.edtAdress.text;
          let parameters: Parameters = [
                  "companyName": companyName,
                  "phoneNumber": phoneNumber,
                  "address": address,
          ]
  
          NetWorkUtils.excutePostTypeFormURLEncoded(parameters: parameters, url: Constants.PathManager.ROOT_SERVER + "api/worker/generate_id",
                  isShowProgress: true, vc: self, responseStringParam: { (response) in
              guard let value  = response.value else { return }
              let json = JSON.parse(value)
              if let isSuccess = json["iSuccess"].bool, isSuccess, let id = json["data"]["id"].string {
                  self.getVcRoot()?.changeCurrentController(VCNoiDungTraoDoi.getInstance(id: id));
                  return
              }
          })
  
  
  
  //        _ = getVcRoot()?.changeCurrentController(VCNoiDungTraoDoi.getInstance())
d774f0637   Trịnh Văn Quân   fisrt comit
52
53
54
55
56
57
58
59
60
61
62
63
64
      }
  
  //    @IBAction func edtActionTrigerClick(_ sender: Any) {
  //    }
  
      override func viewDidDisappear(_ animated: Bool) {
          super.viewDidDisappear(animated)
  //        unregisterKeyBoardEvent()
      }
  
      func getVcRoot() -> VCRoot? {
          return self.parent as? VCRoot
      }
fbd62afcf   Trịnh Văn Quân   version 1.2.2
65

d774f0637   Trịnh Văn Quân   fisrt comit
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
      //region ======= keyboard process ====
      private func registerKeyBoardEvent() {
          NotificationCenter.default.setObserver(self, selector: #selector(VCInputId.keyboardWillShow(_:)), name: NSNotification.Name.UIKeyboardWillShow.rawValue, object: nil);
          NotificationCenter.default.setObserver(self, selector: #selector(VCInputId.keyboardWillHide(_:)), name: NSNotification.Name.UIKeyboardWillHide.rawValue, object: nil);
      }
  
      private func unregisterKeyBoardEvent() {
          NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
          NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
      }
  
      func keyboardWillShow(_ notification: Notification) {
  //        guard let userInfo = notification.userInfo else {
  //            return
  //        }
  //        guard let keyboardFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as AnyObject).cgRectValue else {
  //            return
  //        }
  //        guard let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as AnyObject).doubleValue else {
  //            return
  //        }
  //        topMargin.constant = 50 - keyboardFrame.height
  //        UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.5, options: .curveLinear, animations: { () -> Void in
  //            self.view.layoutIfNeeded()
  //        }, completion: nil)
      }
  
      func keyboardWillHide(_ notification: Notification) {
  //        guard let userInfo = notification.userInfo else {
  //            return
  //        }
  //        guard let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as AnyObject).doubleValue else {
  //            return
  //        }
  //        topMargin.constant = 50
  //        UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.5, options: .curveLinear, animations: { () -> Void in
  //            self.view.layoutIfNeeded()
  //        }, completion: nil)
      }
      //endregion
  }