//
//  YHMySettingViewController.swift
//  galaxy
//
//  Created by edy on 2024/2/6.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit
import SnapKit
import NEConversationUIKit

class YHMySettingViewController: YHBaseViewController, ConstraintRelatableTarget {
    
    lazy var tableView: UITableView = {
        let tableView = UITableView(frame: CGRect.zero, style:.plain)
        if #available(iOS 11.0, *) {
            tableView.contentInsetAdjustmentBehavior = .never
        }
        tableView.backgroundColor = .clear
        tableView.separatorStyle = .none
        tableView.register(YHMySettingCell.self, forCellReuseIdentifier: YHMySettingCell.cellReuseIdentifier)
        tableView.delegate = self
        tableView.dataSource = self
        return tableView
    }()
    
    lazy var items: [PersonalModuleItem] = {
        return [PersonalModuleItem(title: "调整颜色".local.local),
                PersonalModuleItem(title: "深色模式".local),
                PersonalModuleItem(title: "个人信息收集清单".local),
                PersonalModuleItem(title: "第三方信息共享清单".local),
                PersonalModuleItem(title: "关于我们".local)]
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initView()
    }
    
    func initView() {
        
        self.gk_navTitle = "设置".local
        self.view.backgroundColor = .white
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
            make.left.right.bottom.equalToSuperview()
        }
    }
}

extension YHMySettingViewController : UITableViewDelegate, UITableViewDataSource {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return items.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: YHMySettingCell.cellReuseIdentifier, for: indexPath) as! YHMySettingCell
        let item : PersonalModuleItem = items[indexPath.row];
        cell.titleLabel.text = item.title
        return cell
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 53.0
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        if (indexPath.row >= items.count) { return }
        
    }
}

