package com.tools.device.devcheck.dashboard

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.tools.device.devcheck.R
import com.tools.device.devcheck.databinding.FragmentNetworkBinding
import com.tools.device.devcheck.dialog.ShowLoadFragment

class NetworkFragment : Fragment() {

    private var status=1//0:未连接，1：已连接
private lateinit var binding:FragmentNetworkBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        // Inflate the layout for this fragment
        binding = FragmentNetworkBinding.inflate(inflater, container, false)
//        binding.signalStrength.setStrength(4)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        if(status==0){
            binding.noConnect.visibility=View.VISIBLE
            binding.connectData.visibility=View.GONE
            binding.wifiDev1.text="Disconnected"
            binding.wifiList.visibility=View.GONE
            binding.llPubShow.visibility=View.GONE
        }else{
            binding.noConnect.visibility=View.GONE
            binding.connectData.visibility=View.VISIBLE
            binding.wifiDev1.text="Connected"
            binding.wifiList.visibility=View.VISIBLE
            binding.llPubShow.visibility=View.VISIBLE
        }
        binding.pubShow.setOnClickListener{
            val tag = "showLoadFragment"
            if (requireActivity().supportFragmentManager.findFragmentByTag(tag) == null) {
                val showLoadFragment = ShowLoadFragment()
                showLoadFragment.show(requireActivity().supportFragmentManager, tag)
            }
        }
    }

    companion object {

        @JvmStatic
        fun newInstance() =
            NetworkFragment().apply {
                arguments = Bundle().apply {

                }
            }
    }
}