package com.base.locationsharewhite.ui.main

import android.content.Intent
import android.graphics.Color
import androidx.core.view.updatePadding
import com.base.locationsharewhite.databinding.ActivityMainBinding
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.ui.howuse.HowUseActivity
import com.base.locationsharewhite.ui.locationmap.LocationMapActivity
import com.base.locationsharewhite.ui.set.SettingActivity
import com.base.locationsharewhite.utils.BarUtils

class MainActivity : BaseActivity<ActivityMainBinding>() {

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


    override fun initView() {
        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
    }

    override fun initListener() {
        super.initListener()
        binding.llMapLocation.setOnClickListener {
            startActivity(Intent(this, LocationMapActivity::class.java))
        }
        binding.flMyLocationCode.setOnClickListener {
            startActivity(Intent(this, LocationCodeActivity::class.java))
        }
        binding.flShareMyLocation.setOnClickListener {
            startActivity(Intent(this, LocationShareActivity::class.java))
        }
        binding.flHowUse.setOnClickListener {
            startActivity(Intent(this, HowUseActivity::class.java))
        }
        binding.flSettings.setOnClickListener {
            startActivity(Intent(this, SettingActivity::class.java))
        }
    }

    override fun onResume() {
        super.onResume()
        val isRecreate = updateAppLanguage(MyApplication.mainLanguage) {
            MyApplication.mainLanguage = it
        }
        if (isRecreate) {
            return
        }
    }
}