JCJChatInfoViewController.swift 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // JCJChatInfoViewController.swift
  3. // JChat
  4. //
  5. // Created by deng on 2017/3/16.
  6. // Copyright © 2017年 HXHG. All rights reserved.
  7. //
  8. import UIKit
  9. import JMessage
  10. class JCJChatInfoViewController: UIViewController {
  11. override func viewDidLoad() {
  12. super.viewDidLoad()
  13. _init()
  14. }
  15. fileprivate lazy var tableview: UITableView = UITableView(frame: .zero, style: .grouped)
  16. fileprivate lazy var tagArray = ["JChat 版本", "SDK 版本", "官方网站"]
  17. fileprivate lazy var version: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
  18. fileprivate lazy var bundleVersion: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String
  19. //MARK: - private func
  20. private func _init() {
  21. self.title = "关于JChat"
  22. view.backgroundColor = .white
  23. tableview.delegate = self
  24. tableview.dataSource = self
  25. tableview.backgroundColor = UIColor(netHex: 0xe8edf3)
  26. tableview.frame = CGRect(x: 0, y: 0, width: view.width, height: view.height)
  27. tableview.register(JCJChatInfoCell.self, forCellReuseIdentifier: "JCJChatInfoCell")
  28. tableview.separatorStyle = .none
  29. view.addSubview(tableview)
  30. }
  31. }
  32. extension JCJChatInfoViewController: UITableViewDelegate, UITableViewDataSource {
  33. func numberOfSections(in tableView: UITableView) -> Int {
  34. return 2
  35. }
  36. public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  37. if section == 0 {
  38. return 1
  39. }
  40. return tagArray.count
  41. }
  42. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  43. if indexPath.section == 0 {
  44. return 140
  45. }
  46. return 45
  47. }
  48. func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
  49. return 0.0001
  50. }
  51. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  52. if section == 0 {
  53. return 0.0001
  54. }
  55. return 4.5
  56. }
  57. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  58. if indexPath.section == 0 {
  59. return tableView.dequeueReusableCell(withIdentifier: "JCJChatInfoCell", for: indexPath)
  60. }
  61. var cell = tableView.dequeueReusableCell(withIdentifier: "JCMineInfoCell")
  62. if cell == nil {
  63. cell = JCTableViewCell.init(style: .value1, reuseIdentifier: "JCMineInfoCell")
  64. }
  65. return cell!
  66. }
  67. func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
  68. cell.selectionStyle = .none
  69. if indexPath.section == 1 {
  70. cell.accessoryType = .none
  71. cell.detailTextLabel?.font = UIFont.systemFont(ofSize: 14)
  72. cell.textLabel?.font = UIFont.systemFont(ofSize: 16)
  73. cell.textLabel?.layer.masksToBounds = true
  74. switch indexPath.row {
  75. case 0:
  76. cell.detailTextLabel?.text = "v\(version).\(bundleVersion)"
  77. case 1:
  78. cell.detailTextLabel?.text = "v\(JMESSAGE_VERSION)"
  79. case 2:
  80. cell.selectionStyle = .default
  81. cell.accessoryType = .disclosureIndicator
  82. default:
  83. break
  84. }
  85. cell.textLabel?.text = tagArray[indexPath.row]
  86. }
  87. }
  88. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  89. tableView.deselectRow(at: indexPath, animated: true)
  90. if indexPath.row == 2 {
  91. UIApplication.shared.openURL(URL(string: "https://www.jiguang.cn/")!)
  92. }
  93. }
  94. }