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 Router, { ParamsInterface } from '@system.router'; 17import BluetoothDevice from '../model/bluetoothImpl/BluetoothDevice'; 18import BluetoothDeviceController from '../controller/bluetooth/BluetoothDeviceController'; 19import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil'; 20import ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData'; 21import HeadComponent from '../../../../../../common/component/src/main/ets/default/headComponent'; 22 23// let param; 24 25/** 26 * BluetoothPairedDeviceInfo 27 */ 28@Entry 29@Component 30struct BluetoothPairedDeviceInfo { 31 @State bluetoothDevice: BluetoothDevice = new BluetoothDevice(); 32 @State isTouched: boolean = false; 33 private controller: BluetoothDeviceController = new BluetoothDeviceController() 34 35 aboutToAppear() { 36 let param = Router.getParams(); 37 this.bluetoothDevice = JSON.parse((param as ParamsInterface).bluetoothDevice.toString()); 38 } 39 40 build() { 41 Column() { 42 GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) { 43 Column() { 44 HeadComponent({ headName: this.bluetoothDevice?.deviceName, isActive: true }); 45 46 Blank() 47 48 Button() { 49 Text($r("app.string.cancelPairing")) 50 .fontSize($r('app.float.application_button_subtitle_size')) 51 .fontColor($r("app.color.font_color_007DFF")) 52 } 53 .backgroundColor($r('sys.color.ohos_id_color_button_normal')) 54 .width($r("app.float.component_button_width")) 55 .height($r("app.float.wh_value_40")) 56 .align(Alignment.Center) 57 .onClick(() => { 58 LogUtil.log(ConfigData.TAG + "unpair onClick"); 59 if (this.bluetoothDevice) { 60 if (this.controller.unpair(this.bluetoothDevice.deviceId)) { 61 Router.back(); 62 } 63 } 64 }) 65 .margin({ bottom: $r('app.float.distance_24'), top: $r("app.float.distance_8") }); 66 } 67 .height(ConfigData.WH_100_100) 68 .useSizeType({ 69 sm: { span: 4, offset: 0 }, 70 md: { span: 6, offset: 1 }, 71 lg: { span: 8, offset: 2 } 72 }) 73 } 74 .width(ConfigData.WH_100_100) 75 .height(ConfigData.WH_100_100); 76 } 77 .backgroundColor($r("sys.color.ohos_id_color_sub_background")) 78 .width(ConfigData.WH_100_100) 79 .height(ConfigData.WH_100_100); 80 } 81} 82