Blame view

App/createNew/VCChonMucChup.swift 3.17 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
d774f0637   Trịnh Văn Quân   fisrt comit
3
4
5
6
  
  class VCChonMucChup: UIViewController, IVCLoadDataTableViewUIThread {
      @IBOutlet weak var topMargin: NSLayoutConstraint!
      @IBOutlet weak var tableView: UITableViewLoadDataFromUIThread!
1341bf603   Trịnh Văn Quân   version 1.1
7
      @IBOutlet weak var vTopLogo: VTopLogo!
fbd62afcf   Trịnh Văn Quân   version 1.2.2
8
9
      @IBOutlet weak var btnNext: UIButtonCustomGradientBg!
      var cTruong: CongTruong?
d774f0637   Trịnh Văn Quân   fisrt comit
10
11
12
13
14
15
  
      static func getInstance() -> VCChonMucChup {
          let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
          let vcOpen = storyboard.instantiateViewController(withIdentifier: "VCChonMucChup") as! VCChonMucChup
          return vcOpen
      }
fbd62afcf   Trịnh Văn Quân   version 1.2.2
16
17
18
19
20
      static func openControllerFromEdit(_ viewController: UIViewController, cTruong: CongTruong?) {
          let vcOpen = getInstance()
          vcOpen.cTruong = cTruong;
          viewController.present(vcOpen, animated: true, completion: nil)
      }
d774f0637   Trịnh Văn Quân   fisrt comit
21
22
23
  
      override func viewDidLoad() {
          super.viewDidLoad()
1341bf603   Trịnh Văn Quân   version 1.1
24
25
26
          vTopLogo.leftBtnClick = {
              self.btnLeftClick(self.vTopLogo)
          }
454c1bb6f   Trịnh Văn Quân   version 1.2.1
27
          tableView.emptyText = LocalizedString("list_empty")
d774f0637   Trịnh Văn Quân   fisrt comit
28
29
30
31
          CellChonMucChup.registerClass(tableView: tableView, forCellReuseIdentifier: "CellChonMucChup")
          self.tableView.separatorStyle = UITableViewCellSeparatorStyle.singleLine
          self.tableView.rowHeight = UITableViewAutomaticDimension
          self.tableView.estimatedRowHeight = 150
fbd62afcf   Trịnh Văn Quân   version 1.2.2
32
33
34
          if self.cTruong != nil {
              btnNext.isHidden = true;
          }
d774f0637   Trịnh Văn Quân   fisrt comit
35
36
37
38
39
40
41
42
43
44
45
46
      }
  
      override func viewWillAppear(_ animated: Bool) {
          super.viewWillAppear(animated)
          tableView.initAndLoadData(self)
      }
  
      @IBAction func btnRightClick(_ sender: Any) {
          _ = getVcRoot()?.changeCurrentController(VCConfirmMucDaChon.getInstance())
      }
  
      @IBAction func btnLeftClick(_ sender: Any) {
fbd62afcf   Trịnh Văn Quân   version 1.2.2
47
48
49
50
51
          if self.cTruong != nil {
              dismiss(animated: true)
          } else {
              _ = getVcRoot()?.changeCurrentController(VCNhapMucChup.getInstance())
          }
d774f0637   Trịnh Văn Quân   fisrt comit
52
53
54
55
56
      }
  
      //region ============== TableView Data =========
  
      func loadDataOnUI(complete: @escaping ([Any]?) -> ()) {
fbd62afcf   Trịnh Văn Quân   version 1.2.2
57
58
59
60
61
          if let cTruong = self.cTruong {
              complete(cTruong.shootItems);
          } else {
              complete(getVcRoot()?.mucChups)
          }
d774f0637   Trịnh Văn Quân   fisrt comit
62
63
64
65
66
67
68
69
70
71
72
73
74
      }
  
      func getAllCell() -> [BaseCell] {
          var baseCells: [BaseCell] = [BaseCell]();
          baseCells.append(BaseCell(type: 0, identifier: "CellChonMucChup"))
          return baseCells
      }
  
      func getTypeOfData(baseobj: Any) -> Int {
          return 0
      }
  
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
1341bf603   Trịnh Văn Quân   version 1.1
75
          if let mucChup = self.tableView.getItem(indexPath) as? ShootItem {
defd9642e   Trịnh Văn Quân   version 1.2
76
77
              if mucChup.willShoot == 1 {
                  mucChup.willShoot = nil
d774f0637   Trịnh Văn Quân   fisrt comit
78
              } else {
defd9642e   Trịnh Văn Quân   version 1.2
79
                  mucChup.willShoot = 1
d774f0637   Trịnh Văn Quân   fisrt comit
80
81
82
83
84
85
86
87
88
89
              }
              self.tableView.reloadRows(at: [indexPath], with: .none)
          }
      }
  
      //endregion
  
      func getVcRoot() -> VCRootCreateNew? {
          return self.parent as? VCRootCreateNew
      }
fbd62afcf   Trịnh Văn Quân   version 1.2.2
90
91
92
93
94
95
96
      override var prefersStatusBarHidden: Bool {
          return true
      }
  
      override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
          return UIInterfaceOrientationMask.portrait
      }
d774f0637   Trịnh Văn Quân   fisrt comit
97
  }