package app.furmeet.events.system

import android.content.res.ColorStateList
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import app.furmeet.events.bff.R
import app.furmeet.events.bff.databinding.ActivityScheduleBinding
import app.furmeet.events.bff.databinding.ActivityWebViewBinding

class WebViewActivity : TranslatableAppCompatActivityWithScheduleServiceWrapped() {
    lateinit var binding: ActivityWebViewBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityWebViewBinding.inflate(layoutInflater)
        val view = binding.root
        setContentView(view)
        setSupportActionBar(binding.toolbar)
        setContentView(view)
        if(!intent.hasExtra("url") || !intent.hasExtra("title")){
            finish()
            return
        }
        supportActionBar!!.title = intent.getStringExtra("title")
        supportActionBar!!.setDisplayHomeAsUpEnabled(true)
        scheduleManager.convention.colorScheme?.primaryRegular?.let {
            window!!.statusBarColor = it
            binding.toolbar.backgroundTintList = ColorStateList.valueOf(it)
        }
        binding.webView.settings.javaScriptEnabled = true
        binding.webView.loadUrl(intent.getStringExtra("url")!!)
    }
}