1/* 2 * Copyright (c) 2023 Fujian Newland Auto-ID Tech.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 */ 15import { InputDeviceInfo } from '../../model/InputDeviceInfo' 16import inputDevice from '@ohos.multimodalInput.inputDevice' 17/** 18 * 输入设备详情弹窗 19 */ 20@CustomDialog 21export struct InputDeviceDataDialog { 22 @Link mDeviceInfo: InputDeviceInfo 23 mController?: CustomDialogController; 24 cancel?: () => void 25 26 build() { 27 Scroll() { 28 Column() { 29 Text(this.mDeviceInfo.name) 30 .fontColor($r('sys.color.ohos_id_color_text_primary')) 31 .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) 32 .fontWeight(FontWeight.Medium) 33 .width('100%') 34 .margin({ 35 bottom: px2vp(48) 36 }) 37 38 DeviceData({ 39 title: $r('app.string.input_device_id'), 40 context: this.mDeviceInfo.id.toString() 41 }) 42 43 DeviceData({ 44 title: $r('app.string.input_device_uniq'), 45 context: this.mDeviceInfo.uniq 46 }) 47 48 DeviceData({ 49 title: $r('app.string.input_device_style'), 50 context: this.mDeviceInfo.sources.join(',') 51 }) 52 53 DeviceData({ 54 title: $r('app.string.input_device_axis_ranges'), 55 }) 56 57 ForEach(this.mDeviceInfo.axisRanges, (item: inputDevice.AxisRange) => { 58 Column() { 59 DeviceData({ 60 title: $r('app.string.input_device_source_style'), 61 context: item.source 62 }) 63 64 DeviceData({ 65 title: $r('app.string.input_device_axis_type'), 66 context: item.axis 67 }) 68 69 DeviceData({ 70 title: $r('app.string.input_device_max'), 71 context: item.max.toString() 72 }) 73 74 DeviceData({ 75 title: $r('app.string.input_device_min'), 76 context: item.min.toString() 77 }) 78 79 DeviceData({ 80 title: $r('app.string.input_device_fuzz'), 81 context: item.fuzz.toString() 82 }) 83 84 DeviceData({ 85 title: $r('app.string.input_device_flat'), 86 context: item.flat.toString() 87 }) 88 89 DeviceData({ 90 title: $r('app.string.input_device_resolution'), 91 context: item.resolution.toString() 92 }) 93 } 94 .width('97%') 95 .justifyContent(FlexAlign.End) 96 .alignItems(HorizontalAlign.Center) 97 }) 98 99 DeviceData({ 100 title: $r('app.string.input_device_bus'), 101 context: this.mDeviceInfo.bus.toString() 102 }) 103 104 DeviceData({ 105 title: $r('app.string.input_device_product'), 106 context: this.mDeviceInfo.product.toString() 107 }) 108 109 DeviceData({ 110 title: $r('app.string.input_device_vendor'), 111 context: this.mDeviceInfo.vendor.toString() 112 }) 113 114 DeviceData({ 115 title: $r('app.string.input_device_version'), 116 context: this.mDeviceInfo.version.toString(), 117 isShowDivider: false 118 }) 119 } 120 .justifyContent(FlexAlign.Center) 121 .alignItems(HorizontalAlign.End) 122 .padding(px2vp(24)) 123 } 124 } 125} 126 127@Component 128struct DeviceData { 129 title: string | Resource = ''; 130 context?: string = '' 131 isShowDivider?: boolean = true 132 133 @Builder CustomDivider() { 134 Divider() 135 .strokeWidth('1px') 136 .color($r('sys.color.ohos_id_color_subheading_separator')) 137 .margin({ 138 bottom: px2vp(8) 139 }) 140 } 141 142 build() { 143 Column() { 144 Row() { 145 Text(this.title) 146 .fontColor($r('sys.color.ohos_id_color_text_primary')) 147 .fontSize($r('sys.float.ohos_id_text_size_body1')) 148 .fontWeight(FontWeight.Medium) 149 150 Blank() 151 Text(this.context) 152 .fontColor($r('app.color.battery_info_value_text')) 153 .fontSize($r('sys.float.ohos_id_text_size_body2')) 154 } 155 .width('100%') 156 .height(47) 157 158 if (this.isShowDivider) { 159 this.CustomDivider() 160 } 161 } 162 .width('100%') 163 .height(48) 164 } 165}