• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 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 {isNfcAvailable} from '../../../../../../../../common/src/main/ets/default/Constants';
17import Log from '../../../../../../../../common/src/main/ets/default/Log';
18import {FASlotName} from '../../../../../../../../common/src/main/ets/default/Constants';
19import LocationComponent from '../../../../../../../locationcomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleLocationComponent';
20import RingModeComponent from '../../../../../../../ringmodecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleRingModeComponent';
21import AutoRotateComponent from '../../../../../../../autorotatecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleAutoRotateComponent';
22import NFCComponent from '../../../../../../../nfccomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleNFComponent';
23import SimpleToggleComponent from './SimpleToggleComponent';
24
25const TAG = 'SimpleToggleLoadComponent';
26
27@Component
28export default struct SimpleToggleLoadComponent {
29  private keyId: string
30  private mEditMode: boolean = false
31  private mDragMode: boolean = false
32
33  aboutToAppear() {
34    Log.showInfo(TAG, `aboutToAppear Start, keyId: ${this.keyId}, mEditMode: ${this.mEditMode} mDragMode: ${this.mDragMode}`);
35  }
36
37  aboutToDisappear() {
38    Log.showInfo(TAG, `aboutToDisappear`);
39  }
40
41  build() {
42    Column() {
43      if (this.keyId == FASlotName.LOCATION) {
44        LocationComponent({
45          keyId: this.keyId,
46          mEditMode: this.mEditMode,
47          mDragMode: this.mDragMode,
48        })
49      } else if (this.keyId == FASlotName.RING_MODE) {
50        RingModeComponent({
51          keyId: this.keyId,
52          mEditMode: this.mEditMode,
53          mDragMode: this.mDragMode,
54        })
55      } else if (this.keyId == FASlotName.AUTO_ROTATE) {
56        AutoRotateComponent({
57          keyId: this.keyId,
58          mEditMode: this.mEditMode,
59          mDragMode: this.mDragMode,
60        })
61      } else if (this.keyId == FASlotName.NFC) {
62        if (isNfcAvailable()) {
63          NFCComponent({
64            keyId: this.keyId,
65            mEditMode: this.mEditMode,
66            mDragMode: this.mDragMode,
67          })
68        }
69      } else {
70        SimpleToggleComponent({
71          keyId: this.keyId,
72          mEditMode: this.mEditMode,
73          mDragMode: this.mDragMode,
74        })
75      }
76    }.width('100%')
77    .height('100%')
78  }
79}