@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "SENSELESS_COMPARISON", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uni.UNIHelloUniAppX
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.unicloud.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlin.properties.Delegates
import io.dcloud.uniapp.extapi.getScreenBrightness as uni_getScreenBrightness
import io.dcloud.uniapp.extapi.setKeepScreenOn as uni_setKeepScreenOn
import io.dcloud.uniapp.extapi.setScreenBrightness as uni_setScreenBrightness
open class GenPagesAPIScreenBrightnessScreenBrightness : BasePage {
    constructor(__ins: ComponentInternalInstance, __renderer: String?) : super(__ins, __renderer) {
        onLoad(fun(_: OnLoadOptions) {
            stat_instance.onLoad(this)
        }
        , __ins)
        onPageShow(fun() {
            stat_instance.onShow(this)
        }
        , __ins)
        onPageHide(fun() {
            stat_instance.onHide(this)
        }
        , __ins)
        onUnload(fun() {
            stat_instance.onUnload(this)
        }
        , __ins)
    }
    companion object {
        @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
        var setup: (__props: GenPagesAPIScreenBrightnessScreenBrightness) -> Any? = fun(__props): Any? {
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenPagesAPIScreenBrightnessScreenBrightness
            val _cache = __ins.renderCache
            val brightnessInput = ref<String>("0.66")
            val setBrightnessSuccessText = ref<String>("尚未调用")
            val setBrightnessFailText = ref<String>("尚未调用")
            val setBrightnessCompleteText = ref<String>("尚未调用")
            val getBrightnessValueText = ref<String>("尚未读取")
            val getBrightnessFailText = ref<String>("尚未调用")
            val getBrightnessCompleteText = ref<String>("尚未调用")
            val keepScreenOnStateText = ref<String>("未设置")
            val keepScreenOnSuccessText = ref<String>("尚未调用")
            val keepScreenOnFailText = ref<String>("尚未调用")
            val keepScreenOnCompleteText = ref<String>("尚未调用")
            val logs = ref(_uA<String>())
            fun gen_appendLog_fn(text: String) {
                logs.value.unshift("" + Date.now() + " " + text)
                if (logs.value.length > 8) {
                    logs.value.pop()
                }
            }
            val appendLog = ::gen_appendLog_fn
            fun describeSetScreenBrightnessComplete(result: Any): String {
                if (result is UniError) {
                    return "" + (result as UniError).errMsg + " (" + (result as UniError).errCode + ")"
                }
                return "已完成"
            }
            fun describeGetScreenBrightnessComplete(result: Any): String {
                if (result is UniError) {
                    return "" + (result as UniError).errMsg + " (" + (result as UniError).errCode + ")"
                }
                return "已完成"
            }
            fun describeSetKeepScreenOnComplete(result: Any): String {
                if (result is UniError) {
                    return "" + (result as UniError).errMsg + " (" + (result as UniError).errCode + ")"
                }
                return "已完成"
            }
            fun gen_setBrightnessWithValue_fn(value: Number) {
                uni_setScreenBrightness(SetScreenBrightnessOptions(value = value, success = fun(_){
                    setBrightnessSuccessText.value = "设置成功，value=" + value
                    setBrightnessFailText.value = "本次未触发"
                    appendLog("setScreenBrightness success value=" + value)
                }
                , fail = fun(err){
                    setBrightnessFailText.value = "" + err.errMsg + " (" + err.errCode + ")"
                    appendLog("setScreenBrightness fail " + err.errMsg)
                }
                , complete = fun(result){
                    setBrightnessCompleteText.value = describeSetScreenBrightnessComplete(result)
                }
                ))
            }
            val setBrightnessWithValue = ::gen_setBrightnessWithValue_fn
            fun gen_setPresetBrightness_fn(value: Number) {
                brightnessInput.value = "" + value
                setBrightnessWithValue(value)
            }
            val setPresetBrightness = ::gen_setPresetBrightness_fn
            fun gen_setCustomBrightness_fn() {
                val value = parseFloat(brightnessInput.value)
                if (isNaN(value)) {
                    setBrightnessFailText.value = "输入值不是有效数字，未发起调用"
                    setBrightnessCompleteText.value = "未调用"
                    appendLog("setScreenBrightness skip invalid input")
                    return
                }
                setBrightnessWithValue(value)
            }
            val setCustomBrightness = ::gen_setCustomBrightness_fn
            fun gen_setOverflowBrightness_fn() {
                brightnessInput.value = "1.5"
                setBrightnessWithValue(1.5)
            }
            val setOverflowBrightness = ::gen_setOverflowBrightness_fn
            fun gen_getCurrentBrightness_fn() {
                uni_getScreenBrightness(GetScreenBrightnessOptions(success = fun(result){
                    getBrightnessValueText.value = "" + result.value
                    getBrightnessFailText.value = "本次未触发"
                    appendLog("getScreenBrightness success value=" + result.value)
                }
                , fail = fun(err){
                    getBrightnessFailText.value = "" + err.errMsg + " (" + err.errCode + ")"
                    appendLog("getScreenBrightness fail " + err.errMsg)
                }
                , complete = fun(result){
                    getBrightnessCompleteText.value = describeGetScreenBrightnessComplete(result)
                }
                ))
            }
            val getCurrentBrightness = ::gen_getCurrentBrightness_fn
            fun gen_updateKeepScreenOn_fn(keepScreenOn: Boolean) {
                uni_setKeepScreenOn(SetKeepScreenOnOptions(keepScreenOn = keepScreenOn, success = fun(result){
                    keepScreenOnStateText.value = if (keepScreenOn) {
                        "已开启常亮"
                    } else {
                        "已关闭常亮"
                    }
                    keepScreenOnSuccessText.value = result.errMsg
                    keepScreenOnFailText.value = "本次未触发"
                    appendLog("setKeepScreenOn success keepScreenOn=" + keepScreenOn)
                }
                , fail = fun(err){
                    keepScreenOnFailText.value = "" + err.errMsg + " (" + err.errCode + ")"
                    appendLog("setKeepScreenOn fail " + err.errMsg)
                }
                , complete = fun(result){
                    keepScreenOnCompleteText.value = describeSetKeepScreenOnComplete(result)
                }
                ))
            }
            val updateKeepScreenOn = ::gen_updateKeepScreenOn_fn
            onUnmounted(fun(){
                uni_setKeepScreenOn(SetKeepScreenOnOptions(keepScreenOn = false, success = fun(_){}, fail = fun(_){}, complete = fun(_){}))
            }
            )
            return fun(): Any? {
                return _cE("scroll-view", _uM("class" to "page-scroll"), _uA(
                    _cE("view", _uM("class" to "page-body"), _uA(
                        _cE("view", _uM("class" to "panel"), _uA(
                            _cE("text", _uM("class" to "panel-title"), "接口说明"),
                            _cE("text", _uM("class" to "panel-text"), "`uni.setScreenBrightness`：设置当前页面亮度，示例覆盖 value、success、fail、complete。"),
                            _cE("text", _uM("class" to "panel-text"), "`uni.getScreenBrightness`：读取当前亮度，示例覆盖 success、fail、complete。"),
                            _cE("text", _uM("class" to "panel-text"), "`uni.setKeepScreenOn`：设置常亮，示例覆盖 keepScreenOn、success、fail、complete。Web 平台使用 Screen Wake Lock API。")
                        )),
                        _cE("view", _uM("class" to "panel"), _uA(
                            _cE("text", _uM("class" to "panel-title"), "setScreenBrightness 示例（Web不支持）"),
                            _cE("text", _uM("class" to "panel-text"), "自定义亮度值：" + _tD(unref(brightnessInput)), 1),
                            _cE("text", _uM("class" to "panel-text"), "Android/鸿蒙上此亮度设置仅影响当前页面/小程序，离开后会恢复为系统亮度"),
                            _cE("input", _uM("class" to "input-box", "modelValue" to unref(brightnessInput), "onInput" to fun(`$event`: UniInputEvent){
                                trySetRefValue(brightnessInput, `$event`.detail.value)
                            }
                            , "placeholder" to "请输入 0 到 1 的值"), null, 40, _uA(
                                "modelValue"
                            )),
                            _cE("view", _uM("class" to "button-row"), _uA(
                                _cE("button", _uM("id" to "btn-set-brightness-0", "class" to "action-button", "onClick" to fun(){
                                    setPresetBrightness(0)
                                }
                                ), "设置 0", 8, _uA(
                                    "onClick"
                                )),
                                _cE("button", _uM("id" to "btn-set-brightness-05", "class" to "action-button", "onClick" to fun(){
                                    setPresetBrightness(0.5)
                                }
                                ), "设置 0.5", 8, _uA(
                                    "onClick"
                                )),
                                _cE("button", _uM("id" to "btn-set-brightness-045", "class" to "action-button", "onClick" to fun(){
                                    setPresetBrightness(0.45)
                                }
                                ), "设置 0.45", 8, _uA(
                                    "onClick"
                                )),
                                _cE("button", _uM("id" to "btn-set-brightness-1", "class" to "action-button", "onClick" to fun(){
                                    setPresetBrightness(1)
                                }
                                ), "设置 1", 8, _uA(
                                    "onClick"
                                ))
                            )),
                            _cE("view", _uM("class" to "button-row"), _uA(
                                _cE("button", _uM("id" to "btn-set-brightness-custom", "class" to "action-button", "onClick" to setCustomBrightness), "提交自定义值"),
                                _cE("button", _uM("id" to "btn-set-brightness-overflow", "class" to "action-button", "onClick" to setOverflowBrightness), "传入 1.5")
                            )),
                            _cE("text", _uM("id" to "set-brightness-success", "class" to "result-text"), "success：" + _tD(unref(setBrightnessSuccessText)), 1),
                            _cE("text", _uM("id" to "set-brightness-fail", "class" to "result-text"), "fail：" + _tD(unref(setBrightnessFailText)), 1),
                            _cE("text", _uM("id" to "set-brightness-complete", "class" to "result-text"), "complete：" + _tD(unref(setBrightnessCompleteText)), 1)
                        )),
                        _cE("view", _uM("class" to "panel"), _uA(
                            _cE("text", _uM("class" to "panel-title"), "getScreenBrightness 示例（Web不支持）"),
                            _cE("text", _uM("class" to "result-text"), "如果设备是自动调节亮度，Android只能获取到自动调节前的亮度。亮度有效范围为0~1"),
                            _cE("button", _uM("id" to "btn-get-brightness", "class" to "action-button", "onClick" to getCurrentBrightness), "读取当前亮度"),
                            _cE("text", _uM("id" to "get-brightness-value", "class" to "result-text"), "当前亮度：" + _tD(unref(getBrightnessValueText)), 1),
                            _cE("text", _uM("id" to "get-brightness-fail", "class" to "result-text"), "fail：" + _tD(unref(getBrightnessFailText)), 1),
                            _cE("text", _uM("id" to "get-brightness-complete", "class" to "result-text"), "complete：" + _tD(unref(getBrightnessCompleteText)), 1)
                        )),
                        _cE("view", _uM("class" to "panel"), _uA(
                            _cE("text", _uM("class" to "panel-title"), "setKeepScreenOn 示例"),
                            _cE("text", _uM("class" to "result-text"), "浏览器需要https下才能生效"),
                            _cE("view", _uM("class" to "button-row"), _uA(
                                _cE("button", _uM("id" to "btn-keep-screen-on", "class" to "action-button", "onClick" to fun(){
                                    updateKeepScreenOn(true)
                                }
                                ), "keepScreenOn = true", 8, _uA(
                                    "onClick"
                                )),
                                _cE("button", _uM("id" to "btn-keep-screen-off", "class" to "action-button", "onClick" to fun(){
                                    updateKeepScreenOn(false)
                                }
                                ), "keepScreenOn = false", 8, _uA(
                                    "onClick"
                                ))
                            )),
                            _cE("text", _uM("id" to "keep-screen-state", "class" to "result-text"), "当前状态：" + _tD(unref(keepScreenOnStateText)), 1),
                            _cE("text", _uM("id" to "keep-screen-success", "class" to "result-text"), "success：" + _tD(unref(keepScreenOnSuccessText)), 1),
                            _cE("text", _uM("id" to "keep-screen-fail", "class" to "result-text"), "fail：" + _tD(unref(keepScreenOnFailText)), 1),
                            _cE("text", _uM("id" to "keep-screen-complete", "class" to "result-text"), "complete：" + _tD(unref(keepScreenOnCompleteText)), 1)
                        )),
                        _cE("view", _uM("class" to "panel"), _uA(
                            _cE("text", _uM("class" to "panel-title"), "最近回调日志"),
                            _cE(Fragment, null, RenderHelpers.renderList(unref(logs), fun(item, __key, __index, _cached): Any {
                                return _cE("view", _uM("key" to item, "class" to "log-item"), _uA(
                                    _cE("text", _uM("class" to "log-text"), _tD(item), 1)
                                ))
                            }
                            ), 128)
                        ))
                    ))
                ))
            }
        }
        val styles: Map<String, Map<String, Map<String, Any>>> by lazy {
            _nCS(_uA(
                styles0
            ))
        }
        val styles0: Map<String, Map<String, Map<String, Any>>>
            get() {
                return _uM("page-scroll" to _pS(_uM("flexGrow" to 1, "flexShrink" to 1, "flexBasis" to "0%")), "page-body" to _pS(_uM("paddingTop" to 12, "paddingRight" to 12, "paddingBottom" to 12, "paddingLeft" to 12)), "panel" to _pS(_uM("backgroundColor" to "#ffffff", "borderTopLeftRadius" to 10, "borderTopRightRadius" to 10, "borderBottomRightRadius" to 10, "borderBottomLeftRadius" to 10, "paddingTop" to 12, "paddingRight" to 12, "paddingBottom" to 12, "paddingLeft" to 12, "marginBottom" to 12)), "panel-title" to _pS(_uM("fontSize" to 15, "color" to "#222222", "marginBottom" to 10)), "panel-text" to _pS(_uM("fontSize" to 13, "color" to "#666666", "lineHeight" to "20px", "marginBottom" to 6)), "input-box" to _pS(_uM("height" to 40, "borderTopWidth" to 1, "borderRightWidth" to 1, "borderBottomWidth" to 1, "borderLeftWidth" to 1, "borderTopStyle" to "solid", "borderRightStyle" to "solid", "borderBottomStyle" to "solid", "borderLeftStyle" to "solid", "borderTopColor" to "#d9d9d9", "borderRightColor" to "#d9d9d9", "borderBottomColor" to "#d9d9d9", "borderLeftColor" to "#d9d9d9", "borderTopLeftRadius" to 8, "borderTopRightRadius" to 8, "borderBottomRightRadius" to 8, "borderBottomLeftRadius" to 8, "paddingLeft" to 10, "paddingRight" to 10, "marginBottom" to 10)), "button-row" to _pS(_uM("display" to "flex", "flexDirection" to "row", "flexWrap" to "wrap", "marginBottom" to 8)), "action-button" to _pS(_uM("marginRight" to 8, "marginBottom" to 8, "fontSize" to 13)), "result-text" to _pS(_uM("fontSize" to 12, "color" to "#444444", "lineHeight" to "18px", "marginTop" to 4)), "log-item" to _pS(_uM("paddingTop" to 6, "paddingBottom" to 6, "borderBottomWidth" to 1, "borderBottomStyle" to "solid", "borderBottomColor" to "#f0f0f0")), "log-text" to _pS(_uM("fontSize" to 12, "color" to "#555555", "lineHeight" to "18px")))
            }
        var inheritAttrs = true
        var inject: Map<String, Map<String, Any?>> = _uM()
        var emits: Map<String, Any?> = _uM()
        var props = _nP(_uM())
        var propsNeedCastKeys: UTSArray<String> = _uA()
        var components: Map<String, CreateVueComponent> = _uM()
    }
}
