大文件夹bugfix

Signed-off-by: zhangchao <zhangchao338@huawei.com>
This commit is contained in:
zhangchao 2022-07-14 17:46:43 +08:00
parent 4d5af4215d
commit 42479219b5
7 changed files with 59 additions and 14 deletions

View File

@ -88,10 +88,10 @@ export default struct AppBubble {
.padding(this.isSelect ? { left: StyleConstants.DEFAULT_20,
right: StyleConstants.DEFAULT_20, top: this.mPaddingTop } : { top: this.mPaddingTop })
.gesture(
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
AppStorage.SetOrCreate('isLongPress', true);
})
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
AppStorage.SetOrCreate('isLongPress', true);
})
)
}
.parallelGesture(

View File

@ -333,6 +333,5 @@ export default struct FolderComponent {
.borderRadius(this.isSelect ? StyleConstants.DEFAULT_15 : StyleConstants.DEFAULT_0)
.padding(this.isSelect ? { left: StyleConstants.DEFAULT_20,
right: StyleConstants.DEFAULT_20, top: this.mPaddingTop + StyleConstants.DEFAULT_10 } : { top: this.mPaddingTop })
}
}

View File

@ -27,6 +27,7 @@ import BigFolderModel from '../common/BigFolderModel';
import FolderStyleConstants from '../common/constants/FolderStyleConstants';
import FeatureConstants from '../common/constants/FeatureConstants';
import BigFolderStyleConfig from '../common/BigFolderStyleConfig';
import FolderLayoutConfig from '../../../../../../../common/src/main/ets/default/layoutconfig/FolderLayoutConfig';
const TAG = 'FolderViewModel';
const HEXADECIMAL_VALUE = 36;
@ -39,6 +40,7 @@ export default class FolderViewModel extends BaseAppPresenter {
private readonly mGridConfig;
private mPageIndex = 0;
private readonly mFolderStyleConfig: BigFolderStyleConfig;
private readonly mFolderLayoutConfig: FolderLayoutConfig;
private readonly mLocalEventListener = {
onReceiveEvent: (event, params) => {
Log.showDebug(TAG, `FolderViewModel receive event: ${event}, params: ${JSON.stringify(params)}`);
@ -81,6 +83,7 @@ export default class FolderViewModel extends BaseAppPresenter {
this.mFolderModel.registerFolderUpdateEvent(this.mLocalEventListener);
this.mFolderStyleConfig = LayoutConfigManager.getStyleConfig(BigFolderStyleConfig.APP_LIST_STYLE_CONFIG,
FeatureConstants.FEATURE_NAME);
this.mFolderLayoutConfig = LayoutConfigManager.getFunctionConfig(FolderLayoutConfig.FOLDER_GRID_LAYOUT_INFO);
}
static getInstance(): FolderViewModel {
@ -97,6 +100,13 @@ export default class FolderViewModel extends BaseAppPresenter {
return this.mFolderStyleConfig;
}
/**
* return folderOpenLayoutTable
*/
getFolderLayoutConfig(): any {
return this.mFolderLayoutConfig.getFolderLayoutInfo().folderOpenLayoutTable;
}
/**
* add new folder
*
@ -127,7 +137,9 @@ export default class FolderViewModel extends BaseAppPresenter {
// Delete {the app list} from desktop app list
for (let i = 0; i < appLayoutInfo.length; i++) {
const index = gridLayoutInfo.layoutInfo.indexOf(appLayoutInfo[i]);
gridLayoutInfo.layoutInfo.splice(index, 1);
if (index != CommonConstants.INVALID_VALUE) {
gridLayoutInfo.layoutInfo.splice(index, 1);
}
}
const folderInfo = await this.createNewFolderInfo();
@ -797,7 +809,7 @@ export default class FolderViewModel extends BaseAppPresenter {
Log.showDebug(TAG, 'getFolderAddAppList folderId is Empty');
return;
}
const allAppList = [];
let allAppList = [];
let appInfos: any;
let gridLayoutInfo = {
layoutInfo: []
@ -837,6 +849,19 @@ export default class FolderViewModel extends BaseAppPresenter {
allAppList.push(appListInfo[i]);
}
}
if (!this.getIsPad()) {
let bottomAppList: any = AppStorage.Get('residentList');
if (!CheckEmptyUtils.isEmptyArr(bottomAppList)) {
for (let i = 0; i < bottomAppList.length; i++) {
allAppList = allAppList.filter((item) => {
if (bottomAppList[i].keyName == item.keyName) {
return false;
}
return true;
})
}
}
}
AppStorage.SetOrCreate('allAppListForFolder', allAppList);
return allAppList;
}

View File

@ -134,7 +134,6 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
}
});
return itemInfo;
}
/**
@ -343,7 +342,6 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
if (this.isDropOutSide() && isSuccess) {
Log.showInfo(TAG, 'onDragEnd dropOutSide');
}
this.mStartPosition = null;
this.mEndPosition = null;
AppStorage.SetOrCreate('dragFocus', '');
@ -787,7 +785,6 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
break;
}
for (let column = 0; column < allPositions[row].length; column++) {
const usablePositionCount =this.getUsablePositionCount(moveFolderOrForm, allPositions, row , column);
if (usablePositionCount == moveFolderOrForm.area[1] * moveFolderOrForm.area[0]) {
isUsablePosition = true;

View File

@ -64,6 +64,29 @@ export default struct FolderItem {
this.mMargin = styleConfig.mMargin;
this.mGridSpaceWidth = Number(this.mPageDesktopViewModel.getWorkSpaceWidth()) - this.mMargin;
this.mGridSpaceHeight = Number(this.mPageDesktopViewModel.getWorkSpaceHeight());
this.formatFolderInfo();
}
/**
* format FolderInfo
*/
private formatFolderInfo() {
let column = this.mFolderViewModel.getFolderLayoutConfig().column;
let row = this.mFolderViewModel.getFolderLayoutConfig().row;
const allCount = column * row;
if (this.folderItem.layoutInfo[0].length > allCount) {
let folderLayoutInfoList = [];
let integer = Math.floor(this.folderItem.layoutInfo[0].length / allCount);
let remainder = this.folderItem.layoutInfo[0].length % allCount;
for (let i = 0; i < integer; i++) {
folderLayoutInfoList.push(this.folderItem.layoutInfo[0].slice(i * allCount, (i + 1) * allCount));
}
if (remainder != 0) {
folderLayoutInfoList.push(this.folderItem.layoutInfo[0].slice(integer * allCount, integer * allCount + remainder));
}
this.folderItem.layoutInfo.splice(0, 1);
this.folderItem.layoutInfo = folderLayoutInfoList;
}
}
/**

View File

@ -502,12 +502,10 @@ export default class PageDesktopViewModel extends BaseAppPresenter {
const appListInfo = [];
const info = this.getAndSetLayoutInfo();
const layoutInfo = info.layoutInfo;
for (let i = 0; i < layoutInfo.length; i++) {
Log.showDebug(TAG, `pagingFiltering layoutInfo: ${JSON.stringify(layoutInfo[i])}`);
Log.showDebug(TAG, `pagingFiltering keyName: ${layoutInfo[i].keyName}`);
if (layoutInfo[i].typeId == CommonConstants.TYPE_APP) {
for (let j = 0; j < this.mBundleInfoList.length; j++) {
Log.showDebug(TAG, `pagingFiltering mBundleInfoList: ${JSON.stringify(this.mBundleInfoList[j])}`);
if (layoutInfo[i].keyName == this.mBundleInfoList[j].keyName
&& layoutInfo[i].typeId == this.mBundleInfoList[j].typeId) {
this.mBundleInfoList[j].area = layoutInfo[i].area;
@ -1519,7 +1517,7 @@ export default class PageDesktopViewModel extends BaseAppPresenter {
Log.showInfo(TAG, `removeBottomBarInfo bottomAppList length: ${bottomAppList.length}`);
if (!CheckEmptyUtils.isEmptyArr(bottomAppList)) {
for (let i = 0; i < bottomAppList.length; i++) {
Log.showInfo(TAG, `removeBottomBarInfo bottomAppList[i]: ${JSON.stringify(bottomAppList[i])}`);
Log.showDebug(TAG, `removeBottomBarInfo bottomAppList[${i}]: ${JSON.stringify(bottomAppList[i])}`);
const appInfo = pageDesktopInfo.find(item => {
if (item.keyName == bottomAppList[i].keyName) {
return true;

View File

@ -205,6 +205,9 @@ export default class SmartDockModel {
* @param index
*/
addToSmartdock(appInfo: AppItemInfo, index?: number): boolean {
if (appInfo.typeId != CommonConstants.TYPE_APP) {
return false;
}
this.mResidentList = AppStorage.Get('residentList');
const dockItemCount = this.mResidentList.length;
if (this.checkDockNum(dockItemCount)) {