123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // IMChatPrivateSetViewController.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/11/13.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- import RongIMLib
- class IMChatPrivateSetViewController: BaseViewController {
- /// 会话目标
- var targetId : String?
-
- /// 会话类型
- var type : RCConversationType?
-
- typealias BackClosure = () -> Void
- var backClosure : BackClosure?
-
- let sections = [["置顶聊天","屏蔽消息"],
- ["清空聊天记录"]]
-
- override func viewDidLoad() {
- super.viewDidLoad()
- setupViews()
- setupLayouts()
- }
-
- override func setupViews() {
- navigationBar.title = "聊天信息"
- view.addSubview(tableView)
- }
-
- override func setupLayouts() {
- tableView.snp.makeConstraints { (make) in
- make.right.left.bottom.equalToSuperview()
- make.top.equalTo(kNavBarTotalHeight)
- }
- }
-
- private lazy var tableView: UITableView = {
- let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
- tableView.backgroundColor = kf7f8faColor
- tableView.delegate = self
- tableView.dataSource = self
- tableView.rowHeight = 48
- tableView.separatorStyle = .none
- return tableView
- }()
-
- override func didMove(toParent parent: UIViewController?) {
- if !(parent != nil) {
-
- }
- }
-
- }
- extension IMChatPrivateSetViewController: UITableViewDelegate,UITableViewDataSource {
-
- func numberOfSections(in tableView: UITableView) -> Int {
- return sections.count
- }
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return sections[section].count
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- switch indexPath.section {
- case 0:
- let cell = IMChatPrivateSetOneTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
- cell.title = sections[indexPath.section][indexPath.row]
- cell.type = type
- cell.targetId = targetId
-
- return cell
- case 1:
- let cell = IMChatPrivateSetTwoTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
- cell.title = sections[indexPath.section][indexPath.row]
- cell.type = type
- cell.targetId = targetId
- return cell
- default:
- return UITableViewCell()
- }
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- switch indexPath.section {
- case 1:
- RCIMClient.shared()?.clearHistoryMessages(type!, targetId: targetId!, recordTime: 0, clearRemote: true, success: { [weak self] in
- DispatchQueue.main.async {
- if let backClosure = self?.backClosure {
- backClosure()
- }
- SwiftProgressHUD.shared().showText("清理成功!")
- }
- }, error: { (errorCode) in
- DispatchQueue.main.async {
- SwiftProgressHUD.shared().showText("清理失败!")
- }
- })
- break
- default:
- break
- }
- }
-
-
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- return nil
- }
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 10
- }
-
- func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
- return nil
- }
-
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
- return 0.0000001
- }
- }
|