package com.ccwangluo.accelerator.ui.home

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.LinearInterpolator
import android.view.animation.RotateAnimation
import com.ccwangluo.accelerator.databinding.FragmentQuickBinding
import com.ccwangluo.accelerator.ui.view.MemberDialog
import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.utils.TitleBar


class QuickFragment : XPageFragment() {
    private var _binding: FragmentQuickBinding? = null
    private val binding get() = _binding!!

    override fun initTitleBar(): TitleBar? {
        //不使用@Page标注的一定要注意覆盖这个方法
        return null
    }

    override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
        _binding = FragmentQuickBinding.inflate(inflater!!, container, false)
        return binding.root
    }

    override fun initViews() {
        //
    }

    override fun initListeners() {
        binding.btnExpend.setOnClickListener {
            if (binding.expandableLayout1.isExpanded) {
                binding.expandableLayout1.toggle()
                binding.expandableLayout2.expand()
                binding.btnExpendBg.setBackgroundResource(com.ccwangluo.accelerator.R.mipmap.quick_arrow_up)
            } else {
                binding.expandableLayout1.expand()
                binding.expandableLayout2.toggle()
                binding.btnExpendBg.setBackgroundResource(com.ccwangluo.accelerator.R.mipmap.quick_arrow_down)
            }
        }
        binding.btnQuick.setOnClickListener {
//            if (!LoginUtils.hasToken()) {
//                LoginUtils.login(this, {
//
//                })
//                return@setOnClickListener
//            } else {
//                val token = LoginUtils.token
//                println(token)
//            }
//
//            if (!SysUtils.getConnectivityStatus(attachContext!!)) {
//                binding.quickTopToast.visibility = View.VISIBLE
//                binding.quickTopToastTx.setText("网络异常,请检查网络后重试")
//                return@setOnClickListener
//            }

            //用户是否有使用时长
//            if (){
//
//            }
            MemberDialog(this).show<MemberDialog>()

//            startAnim()


        }
    }

    companion object {
        fun newInstance(): QuickFragment {
            val fragment = QuickFragment()
            return fragment
        }
    }

}