//
//  VoiceDialogueVC+initTableView.swift
//  MobilePortal
//
//  Created by caiyang on 2020/5/18.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

extension VoiceDialogueVC {

    func addInitTableView() {
        addLeft(title: "您好，小彩为您服务！")
        //        addRight(title: "您好，我是智能")
//        addRight(title: "订单")
        self.delegate = VoiceDialogueVCDelegate()
        self.delegate.dataSource = self.dataSource
        self.myTableView.delegate = self.delegate
        self.myTableView.dataSource = self.delegate
        self.myTableView.reloadData()
    }
    func addLeft(title:String) {
        let leftModel = VoiceDialogueLeftTVCModel()
        leftModel.className = "VoiceDialogueLeftTVC"
        leftModel.titleStr = title
        leftModel.cellH = cellItemH
        self.cellItemListH = cellItemH+self.cellItemListH
        self.dataSource.add(leftModel)
    }
    func addRight(title:String) {
        let rightModel = VoiceDialogueRightTVCModel()
        rightModel.className = "VoiceDialogueRightTVC"
        rightModel.titleStr = title
        rightModel.cellH = cellItemH
        rightModel.block = {[weak self] in
            self?.actionHttpGCD()
        }
        self.cellItemListH = cellItemH+self.cellItemListH
        self.dataSource.add(rightModel)
    }
}
class VoiceDialogueVCDelegate: 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
        }
        if tableCellModel.className == "VoiceDialogueLeftAppTVC" {
            return 130
        }
        return 90
    }
}
