OOLinkeManViewController.swift 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // OOLinkeManViewController.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2017/11/23.
  6. // Copyright © 2017年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. class OOLinkeManViewController: UITableViewController {
  10. var currentPerson:OOPersonModel?
  11. private lazy var viewModel = {
  12. return OOLinkManViewModel()
  13. }()
  14. let presenter: Presentr = {
  15. let presenter = Presentr(presentationType: .alert)
  16. presenter.transitionType = TransitionType.coverHorizontalFromRight
  17. presenter.dismissOnSwipe = true
  18. return presenter
  19. }()
  20. private var OldBackColor:UIColor?
  21. override func viewWillAppear(_ animated: Bool) {
  22. // self.OldBackColor = self.navigationController?.navigationBar.overlay?.backgroundColor
  23. // self.navigationController?.navigationBar.lt_setBackgroundColor(backgroundColor: UIColor.clear)
  24. }
  25. override func viewWillDisappear(_ animated: Bool) {
  26. // self.navigationController?.navigationBar.lt_setBackgroundColor(backgroundColor: self.OldBackColor!)
  27. }
  28. override func viewDidLoad() {
  29. super.viewDidLoad()
  30. viewModel.currentPerson = currentPerson
  31. title = currentPerson?.name
  32. tableView.tableHeaderView = viewModel.tableHeaderView()
  33. tableView.contentInset = UIEdgeInsets(top: -64, left: 0, bottom: 0, right: 0)
  34. let rightSwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(toggleRightAction))
  35. rightSwipeGestureRecognizer.direction = .right
  36. tableView.addGestureRecognizer(rightSwipeGestureRecognizer)
  37. tableView.reloadData()
  38. }
  39. override func didReceiveMemoryWarning() {
  40. super.didReceiveMemoryWarning()
  41. // Dispose of any resources that can be recreated.
  42. }
  43. @objc func toggleRightAction(){
  44. guard let returnVC = self.navigationController?.popViewController(animated: true) else {
  45. self.dismiss(animated: true, completion: nil)
  46. return
  47. }
  48. }
  49. @IBAction func backPreVC(_ sender: UIBarButtonItem) {
  50. toggleRightAction()
  51. }
  52. // MARK: - Table view data source
  53. override func numberOfSections(in tableView: UITableView) -> Int {
  54. return viewModel.numberOfSections()
  55. }
  56. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  57. return viewModel.numberOfRowsInSection(section)
  58. }
  59. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  60. let cell = tableView.dequeueReusableCell(withIdentifier: "linkManInfoCell", for: indexPath) as! (OOLinkManInfoCell & Configurable)
  61. let item = viewModel.nodeForIndexPath(indexPath)
  62. cell.config(withItem: item)
  63. return cell
  64. }
  65. override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  66. let item = viewModel.nodeForIndexPath(indexPath)
  67. guard let actionURL = item?.actionURL else {
  68. return
  69. }
  70. let openURL = URL(string:actionURL)!
  71. if UIApplication.shared.canOpenURL(openURL) {
  72. // let cancelAction = self.noticeAlertAction("取消", handler: { (myAction) in
  73. // print("取消")
  74. // })
  75. // let okAction = self.noticeAlertAction("确定", handler: { (okAction) in
  76. // if #available(iOS 10.0, *) {
  77. // UIApplication.shared.open(openURL, options: [:], completionHandler: { (result) in
  78. // print(result)
  79. // })
  80. // } else {
  81. // UIApplication.shared.openURL(openURL)
  82. // }
  83. // })
  84. // self.showInfoNotice("拨打电话","确认要电话联系吗?", [cancelAction,okAction])
  85. }
  86. }
  87. }