import { TimePicker } from "android.widget" import { View } from "android.view" export class NativeTimePicker { $element : UniObjectElement; constructor(element : UniObjectElement, hour: number, minute: number) { this.$element = element; bindView(hour, minute); } picker : TimePicker | null = null; bindView(hour: number, minute: number) { this.picker = new TimePicker($element.getAndroidActivity()!); //构建原生view $element.bindAndroidView(picker!); setHour(hour) setMinute(minute) this.picker?.setOnTimeChangedListener((_, hourOfDay, minute) => { const detail = {"hour": hourOfDay, "minute": minute} const event = new UniObjectCustomEvent("timechanged", detail) $element.dispatchEvent(event) }) } setHour(hour: number) { this.picker?.setHour(hour.toInt()) } setMinute(minute: number) { this.picker?.setMinute(minute.toInt()) } }