@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.navigateTo as uni_navigateTo
import io.dcloud.uniapp.extapi.offAccelerometerChange as uni_offAccelerometerChange
import io.dcloud.uniapp.extapi.onAccelerometerChange as uni_onAccelerometerChange
import io.dcloud.uniapp.extapi.startAccelerometer as uni_startAccelerometer
import io.dcloud.uniapp.extapi.stopAccelerometer as uni_stopAccelerometer
open class GenPagesAPIAccelerometerAccelerometer : 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: GenPagesAPIAccelerometerAccelerometer) -> Any? = fun(__props): Any? {
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenPagesAPIAccelerometerAccelerometer
            val _cache = __ins.renderCache
            val intervalOptions = _uA(
                IntervalOption(value = "normal", label = "normal"),
                IntervalOption(value = "ui", label = "ui"),
                IntervalOption(value = "game", label = "game")
            ) as UTSArray<IntervalOption>
            val activeInterval = ref<PageAccelerometerInterval>("normal")
            val statusText = ref("未启动")
            val axisX = ref("0.000")
            val axisY = ref("0.000")
            val axisZ = ref("0.000")
            val axisItems = computed(fun(): UTSArray<AxisItem> {
                return _uA(
                    AxisItem(key = "X", value = axisX.value),
                    AxisItem(key = "Y", value = axisY.value),
                    AxisItem(key = "Z", value = axisZ.value)
                )
            }
            )
            fun gen_formatAxisValue_fn(value: Number): String {
                return value.toFixed(3)
            }
            val formatAxisValue = ::gen_formatAxisValue_fn
            val accelerometerListener: OnAccelerometerChangeCallback = fun(result: OnAccelerometerChangeCallbackResult){
                axisX.value = formatAxisValue(result.x)
                axisY.value = formatAxisValue(result.y)
                axisZ.value = formatAxisValue(result.z)
            }
            fun gen_handleIntervalChange_fn(event: UniRadioGroupChangeEvent): Unit {
                activeInterval.value = event.detail.value as PageAccelerometerInterval
            }
            val handleIntervalChange = ::gen_handleIntervalChange_fn
            fun gen_startListen_fn(): Unit {
                uni_onAccelerometerChange(accelerometerListener)
                uni_startAccelerometer(StartAccelerometerOptions(interval = activeInterval.value, success = fun(_){
                    statusText.value = "监听中 (" + activeInterval.value + ")"
                }
                , fail = fun(error){
                    statusText.value = if (error.errMsg != null) {
                        error.errMsg
                    } else {
                        "启动失败"
                    }
                    console.error("startAccelerometer:fail", error)
                }
                ))
            }
            val startListen = ::gen_startListen_fn
            fun gen_stopListen_fn(): Unit {
                uni_stopAccelerometer(StopAccelerometerOptions(success = fun(_){
                    statusText.value = "已停止"
                }
                ))
            }
            val stopListen = ::gen_stopListen_fn
            fun gen_navigateToShake_fn(): Unit {
                uni_navigateTo(NavigateToOptions(url = "/pages/API/accelerometer/shake"))
            }
            val navigateToShake = ::gen_navigateToShake_fn
            onUnload(fun(){
                uni_offAccelerometerChange(accelerometerListener)
                uni_stopAccelerometer(null)
            }
            )
            return fun(): Any? {
                val _component_radio = resolveComponent("radio")
                val _component_radio_group = resolveComponent("radio-group")
                return _cE("scroll-view", _uM("style" to _nS(_uM("flex" to "1", "padding" to "6px"))), _uA(
                    _cE("text", _uM("class" to "uni-h2"), "加速度计"),
                    _cE("text", null, "开始监听后可实时查看设备在 X、Y、Z 轴上的加速度数据。"),
                    _cE("text", _uM("class" to "margin-v"), "当前状态：" + _tD(unref(statusText)), 1),
                    _cE("text", _uM("class" to "uni-h3"), "采样频率"),
                    _cV(_component_radio_group, _uM("class" to "option-group", "onChange" to handleIntervalChange), _uM("default" to withSlotCtx(fun(): UTSArray<Any> {
                        return _uA(
                            _cE(Fragment, null, RenderHelpers.renderList(intervalOptions, fun(item, __key, __index, _cached): Any {
                                return _cE("view", _uM("class" to "option-item", "key" to item.value), _uA(
                                    _cV(_component_radio, _uM("value" to item.value, "checked" to (unref(activeInterval) == item.value)), _uM("default" to withSlotCtx(fun(): UTSArray<Any> {
                                        return _uA(
                                            _cE("text", _uM("class" to "option-text"), _tD(item.label), 1)
                                        )
                                    }
                                    ), "_" to 2), 1032, _uA(
                                        "value",
                                        "checked"
                                    ))
                                ))
                            }
                            ), 64)
                        )
                    }
                    ), "_" to 1)),
                    _cE("button", _uM("class" to "margin-v", "type" to "primary", "onClick" to startListen), "开始监听"),
                    _cE("button", _uM("class" to "margin-v", "onClick" to stopListen), "停止监听"),
                    _cE("button", _uM("class" to "margin-v", "onClick" to navigateToShake), "跳转摇一摇"),
                    _cE("text", _uM("class" to "uni-h3"), "实时数据"),
                    _cE("view", _uM("class" to "log-list"), _uA(
                        _cE(Fragment, null, RenderHelpers.renderList(unref(axisItems), fun(item, __key, __index, _cached): Any {
                            return _cE("text", _uM("class" to "log-item", "key" to item.key), _tD(item.key) + "：" + _tD(item.value), 1)
                        }
                        ), 128)
                    ))
                ), 4)
            }
        }
        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("margin-v" to _pS(_uM("marginTop" to 5, "marginRight" to 0, "marginBottom" to 5, "marginLeft" to 0)), "option-group" to _pS(_uM("marginTop" to 5, "marginRight" to 0, "marginBottom" to 5, "marginLeft" to 0, "display" to "flex", "flexDirection" to "row", "flexWrap" to "wrap")), "option-item" to _pS(_uM("display" to "flex", "flexDirection" to "row", "alignItems" to "center", "marginRight" to 18, "marginTop" to 8)), "option-text" to _pS(_uM("fontSize" to 14)), "log-list" to _pS(_uM("marginTop" to 5, "marginRight" to 0, "marginBottom" to 5, "marginLeft" to 0, "paddingTop" to 10, "paddingRight" to 10, "paddingBottom" to 10, "paddingLeft" to 10, "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 "#cccccc", "borderRightColor" to "#cccccc", "borderBottomColor" to "#cccccc", "borderLeftColor" to "#cccccc", "display" to "flex", "flexDirection" to "column")), "log-item" to _pS(_uM("fontSize" to 14, "marginTop" to 4, "marginRight" to 0, "marginBottom" to 4, "marginLeft" to 0)))
            }
        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()
    }
}
