package com.all.pdfreader.pdf.reader.ui.fragment

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.all.pdfreader.pdf.reader.databinding.FragmentToolsBinding
import com.all.pdfreader.pdf.reader.model.PdfPickerSource
import com.all.pdfreader.pdf.reader.ui.act.PdfPickerActivity
import com.all.pdfreader.pdf.reader.ui.act.PictureSelectorActivity

class ToolsFrag : BaseFrag() {
    override val TAG: String = "ToolsFrag"
    private lateinit var binding: FragmentToolsBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View {
        binding = FragmentToolsBinding.inflate(layoutInflater)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    private fun initView() {
        binding.mergeBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.MERGE)
            startActivity(intent)
        }
        binding.splitBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.SPLIT)
            startActivity(intent)
        }
        binding.lockBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.LOCK)
            startActivity(intent)
        }
        binding.unLockBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.UNLOCK)
            startActivity(intent)
        }
        binding.imgToPdfBtn.setOnClickListener {
            val intent = Intent(requireActivity(), PictureSelectorActivity::class.java)
            startActivity(intent)
        }
        binding.pdfToImgBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.PDF_TO_IMAGES)
            startActivity(intent)
        }
        binding.pdfToLongImgBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.TO_LONG_IMAGE)
            startActivity(intent)
        }
        binding.printBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.PRINT)
            startActivity(intent)
        }
    }
}