package importantedto.appliededto.surgeonedto.promiseedto

import android.content.Intent
import android.graphics.Color
import android.net.Uri
import androidx.activity.addCallback
import com.base.datarecovery.databinding.ClassifyedtoBinding
import importantedto.afteredto.constitutionaledto.Murderedto
import importantedto.afteredto.constitutionaledto.Neckedto
import importantedto.concreteedto.cameedto.Hateedto.fcmNotification
import importantedto.concreteedto.cameedto.Hateedto.stayNotification
import importantedto.gallonedto.Transcendedto
import importantedto.growedto.umbrellaedto.Correctionedto.subscribeToTopic
import importantedto.growedto.umbrellaedto.Correctionedto.unsubscribeFromTopic
import importantedto.igneousedto.fulledto.saladedto.Rescueedto
import importantedto.igneousedto.fulledto.saladedto.Rescueedto.Companion.startJob
import importantedto.maidedto.witnessedto.nationalismedto.Yellowedto.showRateStarPopDialog

class Hatedto : Murderedto<ClassifyedtoBinding>() {

    override val binding: ClassifyedtoBinding by lazy {
        ClassifyedtoBinding.inflate(layoutInflater)
    }

    override fun initView() {
        Transcendedto.setStatusBarLightMode(this, true)
        Transcendedto.setStatusBarColor(this, Color.TRANSPARENT)

        binding.meedto.isChecked = stayNotification
        binding.tableedto.isChecked = fcmNotification
    }

    override fun initListener() {
        onBackPressedDispatcher.addCallback {
            finishToMain()
        }
        binding.personaledto.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }

        binding.meedto.setOnCheckedChangeListener { buttonView, isChecked ->
            stayNotification = isChecked
            if (isChecked) {
//                startStayNotification()
                startJob()
            } else {
//                val serviceIntent = Intent(this, Operationaledto::class.java)
//                stopService(serviceIntent)
                Rescueedto.isCancel = true
            }
        }
        binding.tableedto.setOnCheckedChangeListener { buttonView, isChecked ->
            fcmNotification = isChecked
            val topic = "${Neckedto.packageName}_push"
            if (isChecked) {
                subscribeToTopic(topic)
            } else {
                unsubscribeFromTopic(topic)
            }
        }

        binding.regularedto.setOnClickListener {
            val intent = Intent(
                Intent.ACTION_VIEW,
                Uri.parse(Neckedto.privacyPolicy)
            )
            startActivity(intent)
        }

        binding.vegetarianedto.setOnClickListener {
            showRateStarPopDialog(mustShow = true)
        }

    }
}