• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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
16import router from '@ohos.router';
17
18const TEST_CASES = [
19    { castName: 'Rotation PickView', uri: 'pages/pickView/index' },
20    { castName: 'Rotation Slider', uri: 'pages/slider/index' },
21    { castName: 'Rotation Swiper', uri: 'pages/swiper/index' },
22    { castName: 'Empty Item_1' },
23    { castName: 'Empty Item_2' },
24    { castName: 'Empty Item_3' },
25    { castName: 'Empty Item_4' },
26    { castName: 'Empty Item_5' },
27    { castName: 'Empty Item_6' },
28    { castName: 'Empty Item_7' },
29    { castName: 'Empty Item_8' }
30];
31
32export default {
33    data: {
34        title: '',
35        caseList: [],
36        optionName: '关闭旋转表冠'
37    },
38    onInit() {
39        this.title = 'Test rotating';
40        this.onInitTestCast();
41        this.$refs.listObj.rotation({focus: true});
42    },
43    onShow() {
44        this.$refs.listObj.rotation({focus: true});
45    },
46    onInitTestCast() {
47        this.caseList = TEST_CASES.map(item => ({ castName: item.castName }));
48        console.log('onInitTestCast---length' + this.caseList.length);
49    },
50    onListItemClick(item) {
51        const targetCase = TEST_CASES.find(test => test.castName === item.castName);
52        if (!targetCase || !targetCase.uri) {
53            return;
54        }
55
56        router.replaceUrl({
57            uri: targetCase.uri,
58        });
59    },
60    onSelectList() {
61    },
62    onChangeOption() {
63        if (this.optionName === '关闭旋转表冠') {
64            this.optionName = '开启旋转表冠';
65            this.$refs.listObj.rotation({focus: false});
66        } else {
67            this.optionName = '开启旋转表冠';
68            this.$refs.listObj.rotation({focus: true});
69        }
70    }
71};
72