1/** 2 * Copyright (c) 2024-2024 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 Constants from '../../common/constants/ComConstant'; 17import ResourceUtil from '../../common/utils/ResourceUtil'; 18import { AutoMenuViewState } from '../../main/auto_menu/AutoMenuViewState'; 19import MenuInfo from '../../common/bean/MenuInfo'; 20 21@Component 22export default struct PrivacyProtectionListView { 23 // Function access list data 24 @Prop menuViewState: AutoMenuViewState; 25 private itemClickEvent = (menuInfo: MenuInfo) => { 26 }; 27 28 build() { 29 Column() { 30 List({ space: Constants.DEFAULT_SPACE }) { 31 ForEach(this.menuViewState.listMenuList, (item: MenuInfo) => { 32 ListItem() { 33 PrivacyProtectionItem({ menuInfo: item, itemClickEvent: this.itemClickEvent }) 34 .visibility(item !== undefined && item !== null ? Visibility.Visible : Visibility.None) 35 } 36 }, (item: MenuInfo) => JSON.stringify(item)) 37 } 38 .borderRadius($r('sys.float.ohos_id_corner_radius_card')) 39 .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) 40 .margin({ 41 top: this.menuViewState.cardMenuList.length === 0 ? 0 : $r('app.float.function_access_list_default_margin_top'), 42 bottom: $r('app.float.function_access_list_margin_bottom') 43 }) 44 } 45 .visibility(this.menuViewState.listMenuList.length !== 0 ? Visibility.Visible : Visibility.None) 46 } 47} 48 49@Component 50struct PrivacyProtectionItem { 51 @Prop menuInfo: MenuInfo; 52 @State isTouched: boolean = false; 53 private itemClickEvent = (menuInfo: MenuInfo) => { 54 } 55 56 build() { 57 Row() { 58 Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { 59 Text(this.menuInfo.titleString) 60 .fontColor($r('sys.color.ohos_id_color_text_primary')) 61 .textAlign(TextAlign.Start) 62 .fontFamily('HarmonyHeiTi') 63 .fontWeight(FontWeight.Medium) 64 .fontSize($r('sys.float.ohos_id_text_size_body1')) 65 Row() { 66 Image($r('app.media.ic_settings_arrow')) 67 .width($r('app.float.width_height_xs')) 68 .height($r('app.float.width_height_m')) 69 .align(Alignment.End) 70 .fillColor($r('sys.color.ohos_id_color_fourth')) 71 .draggable(false) 72 } 73 .padding({ 74 top: $r('app.float.function_access_inside_list_padding'), 75 bottom: $r('app.float.function_access_inside_list_padding'), 76 }) 77 .margin({ 78 left: $r('sys.float.ohos_id_text_margin_horizontal'), 79 }) 80 } 81 .hoverEffect(HoverEffect.Highlight) 82 .onClick(() => { 83 this.itemClickEvent(this.menuInfo) 84 }) 85 .backgroundColor(this.isTouched ? $r('sys.color.ohos_id_color_click_effect') : $r('sys.color.ohos_id_color_list_card_bg')) 86 .onTouch((event?: TouchEvent | undefined) => { 87 if (event?.type === TouchType.Down) { 88 this.isTouched = true; 89 } 90 if (event?.type === TouchType.Up) { 91 this.isTouched = false; 92 } 93 }) 94 .padding({ 95 left: $r('app.float.function_access_inside_list_padding'), 96 top: $r('app.float.function_access_list_padding_top'), 97 right: $r('app.float.function_access_inside_list_padding'), 98 bottom: $r('app.float.function_access_list_padding_top'), 99 }) 100 .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) 101 .borderRadius(ResourceUtil.getFloatNumber($r('sys.float.ohos_id_corner_radius_default_l')) - 4) 102 } 103 .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) 104 .borderRadius($r('sys.float.ohos_id_corner_radius_default_l')) 105 .padding($r('app.float.function_access_list_padding')) 106 .backgroundColor($r('sys.color.ohos_id_color_list_card_bg')) 107 .enabled(this.menuInfo.isClickable === 1) 108 .visibility(this.menuInfo.isSupport ? Visibility.Visible : Visibility.None) 109 } 110} 111 112 113 114 115 116