<template>
<div class="watch-root">
<canvas
id="euv-watch-canvas"
class="watch-canvas"
ontouchstart="onTouchStart"
ontouchmove="onTouchMove"
ontouchend="onTouchEnd"
ontouchcancel="onTouchCancel"
></canvas>
</div>
</template>
<style>
.watch-root {
width: 466px;
height: 466px;
background-color: #09090b;
}
.watch-canvas {
width: 466px;
height: 466px;
}
</style>
<script>
import vibrator from '@system.vibrator';
import storage from '@system.storage';
import router from '@system.router';
import euvWasmGlue from '../../common/euv_wasm_glue.js';
import createWearableBridge from '../../common/euv-bridge.js';
export default {
private: {
bridge: null
},
onReady() {
const canvas = this.$element('euv-watch-canvas');
this.bridge = createWearableBridge({ vibrator, storage, router }, euvWasmGlue);
this.bridge.mount(canvas, { shape: 'round', width: 466, height: 466, dpr: 2.0 });
},
onShow() {
if (this.bridge) this.bridge.dispatchLifecycle(2);
},
onHide() {
if (this.bridge) this.bridge.dispatchLifecycle(3);
},
onDestroy() {
if (this.bridge) {
this.bridge.dispatchLifecycle(4);
this.bridge.destroy();
this.bridge = null;
}
},
onBackPress() {
if (this.bridge) this.bridge.dispatchGesture(4);
return false;
},
onTouchStart(e) {
if (this.bridge) this.bridge.dispatchTouch(0, e);
},
onTouchMove(e) {
if (this.bridge) this.bridge.dispatchTouch(1, e);
},
onTouchEnd(e) {
if (this.bridge) this.bridge.dispatchTouch(2, e);
},
onTouchCancel(e) {
if (this.bridge) this.bridge.dispatchTouch(3, e);
}
};
</script>