//
//  DialogueViewController+initTableView.swift
//  MobilePortal
//
//  Created by caiyang on 2020/4/9.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

extension DialogueViewController {
    func addInitTableView() {
        addLeft(title: "您好，我是智能客服现在由我来为您解答问题")
//        addRight(title: "您好，我是智能")
//        addRight(title: "订单")
        self.delegate = DialogueViewControllerDelegate()
        self.delegate.dataSource = self.dataSource
        self.myTableView.delegate = self.delegate
        self.myTableView.dataSource = self.delegate
        self.myTableView.reloadData()
    }
    func addLeft(title:String){
        let leftModel = DialogueLeftTableViewCellModel()
        leftModel.className = "DialogueLeftTableViewCell"
        leftModel.titleStr = title
        leftModel.cellH = cellItemH
        self.cellItemListH = cellItemH+self.cellItemListH
        self.dataSource.add(leftModel)
    }
    func addRight(title:String){
        let rightModel = DialogueRightTableViewCellModel()
        rightModel.className = "DialogueRightTableViewCell"
        rightModel.titleStr = title
        rightModel.cellH = cellItemH
        self.cellItemListH = cellItemH+self.cellItemListH
        self.dataSource.add(rightModel)
    }
}
class DialogueViewControllerDelegate: BaseOneTableViewDelegate {
    var cellNum:Double!
    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0
    }
    
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        
        if (section == 0){
            return 0
        }
        return 0
    }
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        let tableCellModel:BaseCellModel = self.dataSource[indexPath.row] as! BaseCellModel
        if tableCellModel.className == "DialogueLeftSelectionTVC" {
            let model:DialogueLeftSelectionTVCModel = tableCellModel as! DialogueLeftSelectionTVCModel
            return model.leftCellH + 60
        }
        if tableCellModel.className == "DialogueLeftContentTVC" {
            let model:DialogueLeftContentTVCModel = tableCellModel as! DialogueLeftContentTVCModel
            return model.leftCellH + model.titleH + 60
        }
        return 90
    }
}
