//
//  FriendMainSearchController.swift

//
//  Created by Leon on 2025/8/15.
//

import UIKit

class FriendMainSearchController: CLViewController<FriendMainSearchView> {
    var viewModel = FriendsSearchViewModel()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setupViews()
        setupDats()
        setupEvents()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        container.searchField.becomeFirstResponder()
    }

    private func setupViews() {
        navigationView.backButton.isHidden = true
        navigationView.isHidden = true
    }

    private func setupDats() {
        container.messageListVc.viewModel = viewModel
        container.friendsListVc.viewModel = viewModel
    }

    private func setupEvents() {
        container.cancelButton.addTarget(self, action: #selector(tapCancel), for: .touchUpInside)
    }

    @objc private func tapCancel() {
        close()
    }
}
