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 AirplaneComponent from '../../../../../../../airplanecomponent/src/main/ets/default/pages/ControlCenterSimpleToggleAirplaneComponent'; 24import SimpleToggleComponent from './SimpleToggleComponent'; 25 26const TAG = 'SimpleToggleLoadComponent'; 27 28@Component 29export default struct SimpleToggleLoadComponent { 30 private keyId: string = '' 31 private mEditMode: boolean = false 32 private mDragMode: boolean = false 33 34 aboutToAppear() { 35 Log.showInfo(TAG, `aboutToAppear Start, keyId: ${this.keyId}, mEditMode: ${this.mEditMode} mDragMode: ${this.mDragMode}`); 36 } 37 38 aboutToDisappear() { 39 Log.showInfo(TAG, `aboutToDisappear`); 40 } 41 42 build() { 43 Column() { 44 if (this.keyId == FASlotName.LOCATION) { 45 LocationComponent({ 46 keyId: this.keyId, 47 mEditMode: this.mEditMode, 48 mDragMode: this.mDragMode, 49 }) 50 } else if (this.keyId == FASlotName.RING_MODE) { 51 RingModeComponent({ 52 keyId: this.keyId, 53 mEditMode: this.mEditMode, 54 mDragMode: this.mDragMode, 55 }) 56 } else if (this.keyId == FASlotName.AUTO_ROTATE) { 57 AutoRotateComponent({ 58 keyId: this.keyId, 59 mEditMode: this.mEditMode, 60 mDragMode: this.mDragMode, 61 }) 62 } else if (this.keyId == FASlotName.AIR_PLANE) { 63 AirplaneComponent({ 64 keyId: this.keyId, 65 mEditMode: this.mEditMode, 66 mDragMode: this.mDragMode, 67 }) 68 } else if (this.keyId == FASlotName.NFC) { 69 if (isNfcAvailable()) { 70 NFCComponent({ 71 keyId: this.keyId, 72 mEditMode: this.mEditMode, 73 mDragMode: this.mDragMode, 74 }) 75 } 76 } else { 77 SimpleToggleComponent({ 78 keyId: this.keyId, 79 mEditMode: this.mEditMode, 80 mDragMode: this.mDragMode, 81 }) 82 } 83 }.width('100%') 84 .height('100%') 85 } 86}