//
//  LNGameMateListViewController.swift
//  Lanu
//
//  Created by OneeChan on 2025/11/16.
//

import Foundation
import UIKit
import SnapKit


extension UIView {
    func pushToGameMateList(topCategory: LNGameTypeItemVO, category: LNGameCategoryItemVO, filter: LNGameMateFilter) {
        let vc = LNGameMateListViewController(topCategory: topCategory, category: category, filter: filter)
        navigationController?.pushViewController(vc, animated: true)
    }
}

class LNGameMateListViewController: LNViewController {
    private let topCategory: LNGameTypeItemVO
    private let category: LNGameCategoryItemVO
    private let listView = LNGameMateListView()
    
    init(topCategory: LNGameTypeItemVO, category: LNGameCategoryItemVO, filter: LNGameMateFilter) {
        self.topCategory = topCategory
        self.category = category
        super.init(nibName: nil, bundle: nil)
        
        listView.reloadList(newTopCategory: topCategory.code, newCategory: category.code, filter: filter)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupViews()
    }
}

extension LNGameMateListViewController {
    private func setupViews() {
        title = category.name
        view.backgroundColor = .primary_1
        
        view.addSubview(listView)
        listView.snp.makeConstraints { make in
            make.horizontalEdges.equalToSuperview()
            make.bottom.equalToSuperview()
            make.top.equalToSuperview().offset(12)
        }
    }
}
