1/** 2 * Copyright (c) 2023-2023 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 from '@ohos.router'; 17import ExtensionServiceManagementModel from '../model/accessibilityImpl/ExtensionServiceManagementModel'; 18import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil'; 19import ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData'; 20import HeadComponent from '../../../../../../common/component/src/main/ets/default/headComponent'; 21import ResourceUtil from '../../../../../../common/search/src/main/ets/default/common/ResourceUtil'; 22import { ServiceItemComponent } from '../../../../../../common/component/src/main/ets/default/serviceItemComponent'; 23import ImageAnimatorComponent from '../../../../../../common/component/src/main/ets/default/imageAnimatorComponent'; 24 25const MODULE_TAG = ConfigData.TAG + 'serviceManagement-> '; 26 27class serviceListItem { 28 serviceUri?: string; 29 serviceIcon?: string | Resource; 30 serviceTitle?: string | Resource; 31 serviceEndText?: string 32} 33 34/** 35 * application list 36 */ 37@Entry 38@Component 39struct extensionServiceManagement { 40 @StorageLink('extensionServiceManagementList') serviceList: serviceListItem[] = []; 41 private whtl: string = '80vp'; 42 43 build() { 44 Column() { 45 GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) { 46 Column() { 47 HeadComponent({ headName: $r('app.string.installed_service'), isActive: true }); 48 49 if (this.serviceList.length <= 0) { 50 ImageAnimatorComponent({ 51 imageWidth: $r('app.float.wh_value_80'), 52 imageHeight: $r('app.float.wh_value_80'), whtl: this.whtl 53 }) 54 .margin({ top: $r("app.float.distance_8") }) 55 .zIndex(1) 56 .align(Alignment.Center) 57 .padding({ top: ConfigData.WH_35_100 }) 58 .width(ConfigData.WH_100_100) 59 .height(ConfigData.WH_100_100); 60 } 61 62 Column() { 63 List() { 64 ForEach(this.serviceList, (item: serviceListItem) => { 65 ListItem() { 66 ServiceItemComponent({ 67 targetPage: item.serviceUri, 68 serviceIcon: item.serviceIcon, 69 serviceTitle: item.serviceTitle, 70 serviceEndText: item.serviceEndText, 71 }); 72 } 73 .onClick(() => { 74 router.pushUrl({ url: item.serviceUri as string, params: item }); 75 }) 76 .height($r('app.float.wh_value_72')); 77 }, (item: serviceListItem) => JSON.stringify(item)); 78 } 79 .borderRadius($r("app.float.radius_24")) 80 .divider({ 81 strokeWidth: 1, 82 color: $r('app.color.color_E3E3E3_grey'), 83 startMargin: $r('app.float.wh_value_65'), 84 endMargin: $r('sys.float.ohos_id_card_margin_end'), 85 }) 86 .visibility(this.serviceList.length > 0 ? Visibility.Visible : Visibility.None) 87 .zIndex(0); 88 } 89 .layoutWeight(ConfigData.LAYOUT_WEIGHT_1) 90 .borderRadius($r("app.float.radius_24")) 91 .backgroundColor($r("app.color.white_bg_color")) 92 .padding($r('app.float.distance_4')); 93 } 94 .useSizeType({ 95 sm: { span: 4, offset: 0 }, 96 md: { span: 6, offset: 1 }, 97 lg: { span: 8, offset: 2 }, 98 }); 99 } 100 .width(ConfigData.WH_100_100) 101 .height(ConfigData.WH_100_100); 102 } 103 .backgroundColor($r("sys.color.ohos_id_color_sub_background")) 104 .width(ConfigData.WH_100_100) 105 .height(ConfigData.WH_100_100); 106 } 107 108 aboutToAppear(): void { 109 LogUtil.info(`${MODULE_TAG} aboutToAppear in`); 110 AppStorage.SetOrCreate('extensionServiceManagementList', []); 111 ExtensionServiceManagementModel.setExtensionServiceManagementListener(); 112 ExtensionServiceManagementModel.openExtensionServiceManagementStatusListener(); 113 ResourceUtil.getString($r('app.float.wh_value_80')).then(value => this.whtl = value); 114 LogUtil.info(`${MODULE_TAG} aboutToAppear appList: ${JSON.stringify(this.serviceList)}`); 115 LogUtil.info(`${MODULE_TAG} aboutToAppear out`); 116 } 117 118 onPageShow(): void { 119 LogUtil.info(`${MODULE_TAG} onPageShow in`); 120 AppStorage.SetOrCreate('extensionServiceManagementList', []); 121 ExtensionServiceManagementModel.setExtensionServiceManagementListener(); 122 ExtensionServiceManagementModel.openExtensionServiceManagementApplicationListener(); 123 ResourceUtil.getString($r('app.float.wh_value_80')).then(value => this.whtl = value); 124 LogUtil.info(`${MODULE_TAG} onPageShow ServiceList: ${JSON.stringify(this.serviceList)}`); 125 LogUtil.info(`${MODULE_TAG} onPageShow out`); 126 } 127 128 aboutToDisappear(): void { 129 LogUtil.info(`${MODULE_TAG} aboutToDisappear in`); 130 ExtensionServiceManagementModel.closeExtensionServiceManagementStatusListener(); 131 AppStorage.Delete(MODULE_TAG + 'extensionServiceManagementList'); 132 LogUtil.info(`${MODULE_TAG} aboutToDisappear out`); 133 } 134 135 onPageHide(): void { 136 LogUtil.info(`${MODULE_TAG} onPageHide in`); 137 ExtensionServiceManagementModel.closeExtensionServiceManagementApplicationListener(); 138 } 139}