package com.zswc.creativity.activity

import android.os.Bundle
import com.qmuiteam.qmui.kotlin.onClick
import com.zswc.creativity.R
import com.zswc.creativity.adapter.MyWalletAdapter
import com.zswc.creativity.base.MBRActivity
import com.zswc.creativity.databinding.ActivityMyWalletBinding
import com.zswc.creativity.model.User
import com.zswc.creativity.vmodel.MyWalletVModel

class MyWalletActivity : MBRActivity<MyWalletVModel, MyWalletAdapter, ActivityMyWalletBinding>() {

    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
        vm.money.value = User.get()?.money

    }

    override fun listeners() {
        super.listeners()

        binding.tvAll.onClick {
            vm.status="0"
            vm.all.value=true
            vm.income.value=false
            vm. pay.value=false
            vm.withdrawal.value=false
            binding.tvAll.setBackgroundResource(R.drawable.bg_click_on)
            binding.tvIncome.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvPay.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvWithdrawal.setBackgroundResource(R.drawable.bg_click_off)
            onRefresh()

        }
        binding.tvIncome.onClick {
            vm.status="1"
            vm.all.value=false
            vm.income.value=true
            vm. pay.value=false
            vm.withdrawal.value=false
            binding.tvAll.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvIncome.setBackgroundResource(R.drawable.bg_click_on)
            binding.tvPay.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvWithdrawal.setBackgroundResource(R.drawable.bg_click_off)
            onRefresh()
        }
        binding.tvPay.onClick {
            vm.status="2"
            vm.all.value=false
            vm.income.value=false
            vm. pay.value=true
            vm.withdrawal.value=false
            binding.tvAll.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvIncome.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvPay.setBackgroundResource(R.drawable.bg_click_on)
            binding.tvWithdrawal.setBackgroundResource(R.drawable.bg_click_off)
            onRefresh()
        }
        binding.tvWithdrawal.onClick {
            vm.status="3"
            vm.all.value=false
            vm.income.value=false
            vm. pay.value=false
            vm.withdrawal.value=true
            binding.tvAll.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvIncome.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvPay.setBackgroundResource(R.drawable.bg_click_off)
            binding.tvWithdrawal.setBackgroundResource(R.drawable.bg_click_on)
            onRefresh()
        }

    }

    override fun vmClass(): Class<MyWalletVModel> {
        return MyWalletVModel::class.java
    }

    override fun binding(): ActivityMyWalletBinding {
        return ActivityMyWalletBinding.inflate(layoutInflater)
    }

    override fun initAdapter(): MyWalletAdapter {
        return MyWalletAdapter(vm)
    }

    override fun transluent(): Boolean {
        return true
    }

    override fun title(): String? {
        return null
    }

    override val isRxbus: Boolean
        get() = true

}
