package com.doverfuelingsolutions.issp.view.fragment

import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import com.doverfuelingsolutions.issp.R
import com.doverfuelingsolutions.issp.view.widget.FragmentToolbar
import com.doverfuelingsolutions.issp.utils.StringUtil
import com.doverfuelingsolutions.issp.view.MainActivity
import com.doverfuelingsolutions.issp.view.util.LoadingDialogBuilder

open class FragmentBasic : Fragment() {

    open val title: String = StringUtil.get(R.string.app_name)
    open val countdownTime: Int = 60
    open val useActionBar: Boolean = true
    open val showButtonBack: Boolean = true
    open val showButtonHome: Boolean = true

    fun loading(@StringRes string: Int) = loading(StringUtil.get(string))
    private fun loading(msg: String): AlertDialog {
        return LoadingDialogBuilder(requireContext())
            .setLoadingText(msg)
            .setCancelable(true)
            .show()
    }

    fun home() {
        (requireActivity() as MainActivity).fragmentRouter.popBottom()
    }

    fun back() {
        (requireActivity() as MainActivity).fragmentRouter.pop()
    }
}