• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16exports.source = `
17import router from '@system.router'
18import app from '@system.app'
19
20@Entry
21@Component
22struct MyComponent {
23  @State text_num: number = 0.0
24
25  build() {
26    Column() {
27      Text('fingers:2,angle: ' + this.text_num)
28        .fontSize(25)
29        .width(400)
30        .height(400)
31        .backgroundColor('red')
32        .gesture(
33            RotationGesture({fingers: 2, angle: 5})
34            .onActionStart((event: GestureEvent) => {
35                this.text_num = event.angle
36                console.error('rotation gesture on clicked')
37            })
38            .onActionUpdate((event: GestureEvent) => {
39                this.text_num = event.angle
40                console.error('rotation gesture on clicked')
41            })
42            .onActionEnd((event: GestureEvent) => {
43                this.text_num = event.angle
44                console.error('rotation gesture on clicked')
45            })
46            .onActionCancel(() => {
47            })
48        )
49
50    }
51  }
52}`
53
54exports.expectResult =
55`"use strict";
56var router = globalThis.requireNativeModule('system.router');
57var app = globalThis.requireNativeModule('system.app');
58class MyComponent extends View {
59    constructor(compilerAssignedUniqueChildId, parent, params) {
60        super(compilerAssignedUniqueChildId, parent);
61        this.__text_num = new ObservedPropertySimple(0.0, this, "text_num");
62        this.updateWithValueParams(params);
63    }
64    updateWithValueParams(params) {
65        if (params.text_num !== undefined) {
66            this.text_num = params.text_num;
67        }
68    }
69    aboutToBeDeleted() {
70        this.__text_num.aboutToBeDeleted();
71        SubscriberManager.Get().delete(this.id());
72    }
73    get text_num() {
74        return this.__text_num.get();
75    }
76    set text_num(newValue) {
77        this.__text_num.set(newValue);
78    }
79    render() {
80        Column.create();
81        Text.create('fingers:2,angle: ' + this.text_num);
82        Text.fontSize(25);
83        Text.width(400);
84        Text.height(400);
85        Text.backgroundColor('red');
86        Gesture.create(GesturePriority.Low);
87        RotationGesture.create({ fingers: 2, angle: 5 });
88        RotationGesture.onActionStart((event) => {
89            this.text_num = event.angle;
90            console.error('rotation gesture on clicked');
91        });
92        RotationGesture.onActionUpdate((event) => {
93            this.text_num = event.angle;
94            console.error('rotation gesture on clicked');
95        });
96        RotationGesture.onActionEnd((event) => {
97            this.text_num = event.angle;
98            console.error('rotation gesture on clicked');
99        });
100        RotationGesture.onActionCancel(() => {
101        });
102        RotationGesture.pop();
103        Gesture.pop();
104        Text.pop();
105        Column.pop();
106    }
107}
108loadDocument(new MyComponent("1", undefined, {}));
109`
110