package com.base.browserwhite.ui.activity.bookmark

import android.annotation.SuppressLint
import android.graphics.Color
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import com.base.browserwhite.bean.BookmarkBean
import com.base.browserwhite.databinding.ActivityBookmarkEditBinding
import com.base.browserwhite.ui.activity.BaseActivity
import com.base.browserwhite.utils.BarUtils

class BookmarkEditActivity : BaseActivity<ActivityBookmarkEditBinding>() {

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

    @SuppressLint("SetTextI18n")
    override fun initView() {

        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.WHITE)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())

        binding.editName.setText(editBookmark?.name)
        binding.editUrl.setText(editBookmark?.url)
        binding.ivSelectorNav.isSelected = true
        if (editBookmark?.folder.equals("")) {
            binding.tvFolder.text = "Root Folder"
        } else {
            binding.tvFolder.text = editBookmark?.folder
        }
    }

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

    companion object {
        var editBookmark: BookmarkBean? = null
    }

}