package com.zxhy.hfilemanagermaster

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.WindowManager
import androidx.activity.enableEdgeToEdge
import androidx.annotation.ColorRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.findNavController
import com.example.hfilemanagermaster.R
import com.example.hfilemanagermaster.databinding.ActivityOverviewBinding

class OverviewActivity : AppCompatActivity() {
    private lateinit var binding: ActivityOverviewBinding

    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        binding = ActivityOverviewBinding.inflate(layoutInflater)
        setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        window.statusBarColor = ContextCompat.getColor(this, R.color.color_B7FF03)
        binding.ivManager.isSelected = true


        binding.ivManager.setOnClickListener {
            binding.fragmentContainerView.findNavController().navigate(R.id.managerFragment)
            showManager()
        }

        binding.ivTools.setOnClickListener {
            binding.fragmentContainerView.findNavController().navigate(R.id.toolsFragment)
            showTools()
        }
    }

    fun setStatusBarColor(@ColorRes id: Int) {
        window.statusBarColor = ContextCompat.getColor(this, id)

        binding.ivTools.isSelected = true
        binding.ivManager.isSelected = false
    }

    fun showManager() {
        window.statusBarColor = ContextCompat.getColor(this, R.color.color_B7FF03)
        binding.ivManager.isSelected = true
        binding.ivTools.isSelected = false
    }

    fun showTools() {
        binding.ivTools.isSelected = true
        binding.ivManager.isSelected = false
        window.statusBarColor = ContextCompat.getColor(this, R.color.white)
    }
}