package com.zxhy.fastfilemanagerpro.kokohome

import android.content.Context
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.zxhy.fastfilemanagerpro.R
import com.zxhy.fastfilemanagerpro.databinding.FragmentKoHomekoBinding
import com.zxhy.fastfilemanagerpro.kokolistfile.KoListFilekoActivity.Companion.EMPTY_FILE
import com.zxhy.fastfilemanagerpro.kokolistfile.KoListFilekoActivity.Companion.LARGE_FILE
import com.zxhy.fastfilemanagerpro.kokotools.DiskHelper

class KoHomekoFragment : Fragment() {

    private lateinit var binding: FragmentKoHomekoBinding
    private lateinit var context: Context
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val root = inflater.inflate(R.layout.fragment_ko_homeko, container, false)
        binding = FragmentKoHomekoBinding.bind(root)
        return root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        context = requireContext()
        val disk = DiskHelper.getMountInfoList(context)[0]
        binding.tvFree.text = disk.getFreeContent(context)
        binding.tvUsed.text = disk.getUsedContent(context)

        binding.tvScanEmpty.setOnClickListener {
            val bundle = Bundle().apply {
                putString("Tittle", EMPTY_FILE)
            }
            findNavController().navigate(R.id.koListFilekoActivity, bundle)
        }
        binding.tvScanLarge.setOnClickListener {
            val bundle = Bundle().apply {
                putString("Tittle", LARGE_FILE)
            }
            findNavController().navigate(R.id.koListFilekoActivity, bundle)
        }
        binding.tvScanDupImage.setOnClickListener {

        }
        binding.tvScanDupFiles.setOnClickListener {

        }

    }

}