package com.kdanmobile.reader.screen.data

import android.content.Context
import android.content.SharedPreferences

class ViewerSettingSharePrefs(val context: Context, sharedPrefsFileName: String) {
    companion object {
        const val readMode = "READ_MODE"
        const val cropMode = "CROP_MODE"
        const val stateBar = "STATE_BAR"
        const val turnPageDirection = "TURN_PAGE_DIRECTION"
        const val turnPageBtn = "TURN_PAGE_BUTTON"
        const val screenSleep = "SCREEN_SLEEP"
        const val commentTool = "COMMENT_TOOL"
        const val botaTool = "BOTA_TOOL"
    }

    private var sharedPreferences: SharedPreferences = context.getSharedPreferences(sharedPrefsFileName, Context.MODE_PRIVATE)

    fun getReadMode(): Int {
        return sharedPreferences.getInt(readMode, 0)
    }

    fun setReadMode(showMode: Int) {
        sharedPreferences.edit().putInt(readMode, showMode).apply()
    }

    fun isCropModeEnable(): Boolean {
        return sharedPreferences.getBoolean(cropMode, false)
    }

    fun setCropModeEnable(enable: Boolean) {
        sharedPreferences.edit().putBoolean(cropMode, enable).apply()
    }

    fun isShowStateBarEnable(): Boolean {
        return sharedPreferences.getBoolean(stateBar, true)
    }

    fun setShowStateBarEnable(enable: Boolean) {
        sharedPreferences.edit().putBoolean(stateBar, enable).apply()
    }

    fun getTurnPageDirection(): Int {
        return sharedPreferences.getInt(turnPageDirection, 0)
    }

    fun setTurnPageDirection(direction: Int) {
        sharedPreferences.edit().putInt(turnPageDirection, direction).apply()
    }

    fun isShowTurnPageButtonEnable(): Boolean {
        return sharedPreferences.getBoolean(turnPageBtn, true)
    }

    fun setShowTurnPageButtonEnable(enable: Boolean) {
        sharedPreferences.edit().putBoolean(turnPageBtn, enable).apply()
    }

    fun isLockScreenSleepEnable(): Boolean {
        return sharedPreferences.getBoolean(screenSleep, true)
    }

    fun setLockScreenSleepEnable(enable: Boolean) {
        sharedPreferences.edit().putBoolean(screenSleep, enable).apply()
    }

    fun isShowCommentToolEnable(): Boolean {
        return sharedPreferences.getBoolean(commentTool, false)
    }

    fun setShowCommentToolEnable(enable: Boolean) {
        sharedPreferences.edit().putBoolean(commentTool, enable).apply()
    }

    fun isShowBOTAToolEnable(): Boolean {
        return sharedPreferences.getBoolean(botaTool, false)
    }

    fun setShowBOTAToolEnable(enable: Boolean) {
        sharedPreferences.edit().putBoolean(botaTool, enable).apply()
    }
}