package com.kdanmobile.reader.screen.view

import android.content.Context
import android.support.constraint.ConstraintLayout
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.CompoundButton
import com.kdanmobile.reader.R
import kotlinx.android.synthetic.main.view_screen_setting.view.*

class ScreenSettingView : ConstraintLayout {
    var onCheckedChangeListener: CompoundButton.OnCheckedChangeListener? = null
        set(value) {
            field = value
            rowSwitchView_lockScreenSleepEnable?.onCheckedChangeListener = value
        }

    var isLockScreenSleepEnable: Boolean = false
        set(value) {
            field = value
            rowSwitchView_lockScreenSleepEnable?.isChecked = value
        }

    constructor(context: Context) : super(context) {
        initView()
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        initView()
    }

    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
        initView()
    }

    private fun initView() {
        LayoutInflater.from(context).inflate(R.layout.view_screen_setting, this)
    }
}