arkts适配

Signed-off-by: gengzhengxing <gengzhengxing1@h-partners.com>
This commit is contained in:
gengzhengxing 2023-11-05 17:19:44 +08:00
parent 55a1a04aea
commit 6f627e66fe
3 changed files with 26 additions and 24 deletions

View File

@ -19,8 +19,8 @@ const TAG = 'OverlayAppIcon';
@Component
export default struct OverlayAppIcon {
iconSize: number;
icon: string;
iconSize: number = 0;
icon: string = '';
// 0.9(pressed size) / 1.05(hover size) = 0.8571
@State overlaySize: number = 0.8571;

View File

@ -22,6 +22,7 @@ import {
Log
} from '@ohos/common';
import ThisStyleConstants from '../../common/constants/StyleConstants';
import { PageDesktopViewModel } from '../../../../../../../pagedesktop/src/main/ets/default/viewmodel/PageDesktopViewModel';
const TAG = 'ServiceFormAppItem';
@ -33,18 +34,18 @@ export default struct ServiceFormAppItem {
bundleName: string = '';
abilityName: string = '';
moduleName: string = '';
appLabelId: number;
iconId: number;
appLabelId: number = 0;
iconId: number = 0;
@State appName: string = '';
mDefaultAppIcon: string = '';
clickApp?: Function | null = null;
private item: AppItemInfo;
private mResourceManager: ResourceManager;
private item: AppItemInfo = new AppItemInfo();
private mResourceManager: ResourceManager = ResourceManager.getInstance();
private mIconSize: number = ThisStyleConstants.FORM_SERVICE_APP_ICON_SIZE_WIDTH;
private mNameLines: number = globalThis.PageDesktopViewModel?.getPageDesktopStyleConfig().mNameLines;
private mNameLines: number = PageDesktopViewModel.getInstance().getPageDesktopStyleConfig().mNameLines;
private mNameMarginLeft: number = ThisStyleConstants.FORM_SERVICE_APP_NAME_MARGIN_LEFT;
private mAppItemHeight: number = ThisStyleConstants.FORM_SERVICE_APP_ITEM_HEIGHT;
private idIndex: number;
private idIndex: number = 0;
aboutToAppear(): void {
this.mResourceManager = ResourceManager.getInstance();
@ -54,10 +55,10 @@ export default struct ServiceFormAppItem {
private updateIcon(): void {
this.mResourceManager.getAppIconWithCache(this.iconId, this.bundleName, this.moduleName,
this.iconLoadCallback.bind(this), this.mDefaultAppIcon);
this.iconLoadCallback, this.mDefaultAppIcon);
}
private iconLoadCallback(image: string): void {
private iconLoadCallback = (image: string): void => {
Log.showInfo(TAG, `iconLoadCallback ${this.bundleName} ${this.abilityName}`);
if (SettingsModel.getInstance().getDevice() == CommonConstants.PAD_DEVICE_TYPE
&& this.bundleName == CommonConstants.LAUNCHER_BUNDLE) {
@ -70,12 +71,12 @@ export default struct ServiceFormAppItem {
private updateName(): void {
if (CheckEmptyUtils.isEmpty(this.appName)) {
this.mResourceManager.getAppNameWithCache(this.appLabelId, this.bundleName, this.moduleName,
this.appName, this.appNameLoadCallback.bind(this));
this.appName, this.appNameLoadCallback);
return;
}
}
private appNameLoadCallback(name: string): void {
private appNameLoadCallback = (name: string): void => {
this.appName = name;
}

View File

@ -21,7 +21,8 @@ import {
CardItemInfo
} from '@ohos/common';
import ThisStyleConstants from '../constants/StyleConstants';
import Curves from '@ohos.curves'
import Curves from '@ohos.curves';
import { PageDesktopViewModel } from '../../../../../../../pagedesktop/src/main/ets/default/viewmodel/PageDesktopViewModel';
const TAG = 'ServiceFormItem';
@ -43,9 +44,9 @@ export default struct ServiceFormItem {
curve: Curves.springCurve(0.5, 1, 350, 35)
};
private idIndex: number = 0;
private formItem: CardItemInfo;
private formId: number;
getFormId: (id: number) => void;
private formItem: CardItemInfo = new CardItemInfo();
private formId: number = 0;
getFormId: (id: number) => void = (id: number) => {};
@State opacityValue: number = 1;
@State blurValue: number = 50;
@ -141,14 +142,14 @@ export default struct ServiceFormItem {
@Component
struct ServiceFormName {
private nameLines: number = globalThis.PageDesktopViewModel?.getPageDesktopStyleConfig().mNameLines;
bundleName: string;
moduleName: string;
labelId: number;
private nameLines: number = PageDesktopViewModel.getInstance().getPageDesktopStyleConfig().mNameLines;
bundleName: string = '';
moduleName: string = '';
labelId: number = 0;
@State @Watch("updateName") appName: string = '';
formNum: number;
formNum: number = 0;
useCache: boolean = true;
private mResourceManager;
private mResourceManager = ResourceManager.getInstance();
private idIndex: number = 0;
public aboutToAppear(): void {
@ -156,14 +157,14 @@ struct ServiceFormName {
this.updateName();
}
public appNameLoadCallback(name: string) {
public appNameLoadCallback = (name: string) => {
this.appName = name;
}
public updateName() {
if (CheckEmptyUtils.isEmpty(this.appName)) {
this.mResourceManager.getAppNameWithCache(this.labelId, this.bundleName, this.moduleName,
this.appName, this.appNameLoadCallback.bind(this));
this.appName, this.appNameLoadCallback);
}
}