1/* 2 * Copyright (c) 2023-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 16if (!("finalizeConstruction" in ViewPU.prototype)) { 17 Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); 18} 19if (PUV2ViewBase.contextStack === undefined) { 20 Reflect.set(PUV2ViewBase, 'contextStack', []); 21} 22const vibrator = requireNativeModule('ohos.vibrator'); 23const curves = requireNativeModule('ohos.curves'); 24const composetitlebar = requireNapi('arkui.advanced.ComposeTitleBar'); 25const editabletitlebar = requireNapi('arkui.advanced.EditableTitleBar'); 26const subheader = requireNapi('arkui.advanced.SubHeader'); 27const hilog = requireNapi('hilog'); 28const LengthMetrics = requireNapi('arkui.node').LengthMetrics; 29const MeasureText = requireNapi('measure'); 30 31const ComposeTitleBar = composetitlebar.ComposeTitleBar; 32const EditableTitleBar = editabletitlebar.EditableTitleBar; 33const EditableLeftIconType = editabletitlebar.EditableLeftIconType; 34const SubHeader = subheader.SubHeader; 35const OperationType = subheader.OperationType; 36 37const COL_IMAGE_TEXT = 3; 38const COL_TEXT = 4; 39const GRID_COL_3 = '1fr 1fr 1fr'; 40const GRID_COL_4 = '1fr 1fr 1fr 1fr'; 41const ICON_SIZE = 24; 42const IMAGE_DEFAULT = 56; 43const TEXT_PADDING_LEFT_RIGHT = 12; 44const PADDING_EIGHT = 4; 45const GRID_ITEM_HEIGHT_TEXT = 28; 46const MARGIN_EIGHT = 8; 47const ROW_GAP = 16; 48const SUBTITLE_HEIGHT = 56; 49const TEXT_MAX_LINES = 1; 50const MIN_FONT_SCALE = 1; 51const MAX_FONT_SCALE = 2; 52const DEFAULT_TEXT_SIZE = 12; 53const DEFAULT_FONT_SIZE_SCALE = 1; 54const DEFAULT_BLOCK_TEXT_ITEM_SAFE_MARGIN = 8; 55const EDIT_BLOCK_TEXT_ITEM_SAFE_MARGIN = 16; 56const ENTER_EXIT_ICON_DURATION = 200; 57const COMMON_BEZIER = curves.cubicBezierCurve(0.33, 0, 0.67, 1); 58const DRAG_SPRING = curves.interpolatingSpring(0, 1, 400, 38); 59const REMOVE_ADD_SPRING = curves.interpolatingSpring(0, 1, 150, 24); 60const LONG_TOUCH_SCALE = curves.cubicBezierCurve(0.2, 0, 0.2, 1); 61export var GridObjectSortComponentType; 62(function (g17) { 63 g17["IMAGE_TEXT"] = "image_text"; 64 g17["TEXT"] = "text"; 65})(GridObjectSortComponentType || (GridObjectSortComponentType = {})); 66class MenuItem { 67 constructor(d17, e17, f17) { 68 this.value = d17; 69 this.isEnabled = e17; 70 this.action = f17; 71 } 72} 73export class GridObjectSortComponent extends ViewPU { 74 constructor(t16, u16, v16, w16 = -1, x16 = undefined, y16) { 75 super(t16, v16, w16, y16); 76 if (typeof x16 === "function") { 77 this.paramsGenerator_ = x16; 78 } 79 this.__options = new SynchedPropertyObjectOneWayPU(u16.options, this, "options"); 80 this.dataList = []; 81 this.__selected = new ObservedPropertyObjectPU([], this, "selected"); 82 this.__unSelected = new ObservedPropertyObjectPU([], this, "unSelected"); 83 this.__copySelected = new ObservedPropertyObjectPU([], this, "copySelected"); 84 this.__copyUnSelected = new ObservedPropertyObjectPU([], this, "copyUnSelected"); 85 this.__content = new ObservedPropertyObjectPU({ id: '', text: '', selected: false, order: 0 }, this, "content"); 86 this.__dragContent = new ObservedPropertyObjectPU({ id: '', text: '', selected: false, order: 0 }, this, "dragContent"); 87 this.__dragContentIndex = new ObservedPropertySimplePU(-1, this, "dragContentIndex"); 88 this.__hoverId = new ObservedPropertySimplePU('', this, "hoverId"); 89 this.__gridComState = new ObservedPropertySimplePU(false, this, "gridComState"); 90 this.__menuSwitch = new ObservedPropertySimplePU(false, this, "menuSwitch"); 91 this.__areaWidth = new ObservedPropertySimplePU(0, this, "areaWidth"); 92 this.__blockWidth = new ObservedPropertySimplePU(0, this, "blockWidth"); 93 this.__blockHeight = new ObservedPropertySimplePU(0, this, "blockHeight"); 94 this.__longScaleOnePointTwo = new ObservedPropertySimplePU(1, this, "longScaleOnePointTwo"); 95 this.__scaleGridItemNinetyPercent = new ObservedPropertySimplePU(1, this, "scaleGridItemNinetyPercent"); 96 this.__reboundSize = new ObservedPropertySimplePU(1, this, "reboundSize"); 97 this.__scaleIcon = new ObservedPropertySimplePU(1, this, "scaleIcon"); 98 this.__addIconShow = new ObservedPropertySimplePU(false, this, "addIconShow"); 99 this.__scaleAddIcon = new ObservedPropertySimplePU(0, this, "scaleAddIcon"); 100 this.__isStartDrag = new ObservedPropertySimplePU(false, this, "isStartDrag"); 101 this.__insertIndex = new ObservedPropertySimplePU(-1, this, "insertIndex"); 102 this.__itemIndex = new ObservedPropertySimplePU(0, this, "itemIndex"); 103 this.__editGridDataLength = new ObservedPropertySimplePU(-1, this, "editGridDataLength"); 104 this.__isTouchDown = new ObservedPropertySimplePU(false, this, "isTouchDown"); 105 this.__addItemMoveX = new ObservedPropertySimplePU(0, this, "addItemMoveX"); 106 this.__addItemMoveY = new ObservedPropertySimplePU(0, this, "addItemMoveY"); 107 this.__editItemMoveX = new ObservedPropertySimplePU(0, this, "editItemMoveX"); 108 this.__editItemMoveY = new ObservedPropertySimplePU(0, this, "editItemMoveY"); 109 this.__unSelectedIndex = new ObservedPropertySimplePU(0, this, "unSelectedIndex"); 110 this.__clickAddBtn = new ObservedPropertySimplePU(false, this, "clickAddBtn"); 111 this.__selectedIndex = new ObservedPropertySimplePU(-1, this, "selectedIndex"); 112 this.__clickRemoveBtn = new ObservedPropertySimplePU(false, this, "clickRemoveBtn"); 113 this.__addAreaLongPressGesture = new ObservedPropertySimplePU(false, this, "addAreaLongPressGesture"); 114 this.__arraySelectIsChange = new ObservedPropertySimplePU(0, this, "arraySelectIsChange"); 115 this.__arrayUnSelectIsChange = new ObservedPropertySimplePU(0, this, "arrayUnSelectIsChange"); 116 this.__textItemEditWidth = new ObservedPropertySimplePU(0, this, "textItemEditWidth"); 117 this.__textItemEditHeight = new ObservedPropertySimplePU(0, this, "textItemEditHeight"); 118 this.__imageItemWidth = new ObservedPropertySimplePU(0, this, "imageItemWidth"); 119 this.__saveClick = new ObservedPropertySimplePU(false, this, "saveClick"); 120 this.__imageTextAddIconShow = new ObservedPropertySimplePU(false, this, "imageTextAddIconShow"); 121 this.__imageTextRemoveIconShow = new ObservedPropertySimplePU(false, this, "imageTextRemoveIconShow"); 122 this.__firstIn = new ObservedPropertySimplePU(true, this, "firstIn"); 123 this.__fontSizeScale = new ObservedPropertyObjectPU(1, this, "fontSizeScale"); 124 this.__customColumns = new ObservedPropertySimplePU('1fr 1fr 1fr 1fr', this, "customColumns"); 125 this.__editGridHeight = new ObservedPropertySimplePU(0, this, "editGridHeight"); 126 this.__addGridHeight = new ObservedPropertySimplePU(0, this, "addGridHeight"); 127 this.__subTitleHeight = new ObservedPropertySimplePU(0, this, "subTitleHeight"); 128 this.callbackId = undefined; 129 this.colNum = COL_IMAGE_TEXT; 130 this.vibrationDone = false; 131 this.touchDown = { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_click_effect'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; 132 this.touchBorderRadius = { "id": -1, "type": 10002, params: ['sys.float.ohos_id_corner_radius_clicked'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; 133 this.hoverBackgroundColor = { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_hover'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; 134 this.focusBorder = { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_focused_outline'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; 135 this.imageText = false; 136 this.menuItems = [ 137 new MenuItem({ "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_edit'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, true, () => { 138 this.goEdit(); 139 }), 140 ]; 141 this.onSave = undefined; 142 this.onCancel = undefined; 143 this.isFollowingSystemFontScale = false; 144 this.maxAppFontScale = 1; 145 this.envCallback = { 146 onConfigurationUpdated: (b17) => { 147 let c17 = this.getUIContext(); 148 this.fontSizeScale = this.decideFontScale(c17); 149 }, 150 onMemoryLevel: (a17) => { } 151 }; 152 this.setInitiallyProvidedValue(u16); 153 this.declareWatch("gridComState", this.onGridComStateChange); 154 this.declareWatch("fontSizeScale", this.calcAreaInfo); 155 this.finalizeConstruction(); 156 } 157 setInitiallyProvidedValue(s16) { 158 if (s16.options === undefined) { 159 this.__options.set({}); 160 } 161 if (s16.dataList !== undefined) { 162 this.dataList = s16.dataList; 163 } 164 if (s16.selected !== undefined) { 165 this.selected = s16.selected; 166 } 167 if (s16.unSelected !== undefined) { 168 this.unSelected = s16.unSelected; 169 } 170 if (s16.copySelected !== undefined) { 171 this.copySelected = s16.copySelected; 172 } 173 if (s16.copyUnSelected !== undefined) { 174 this.copyUnSelected = s16.copyUnSelected; 175 } 176 if (s16.content !== undefined) { 177 this.content = s16.content; 178 } 179 if (s16.dragContent !== undefined) { 180 this.dragContent = s16.dragContent; 181 } 182 if (s16.dragContentIndex !== undefined) { 183 this.dragContentIndex = s16.dragContentIndex; 184 } 185 if (s16.hoverId !== undefined) { 186 this.hoverId = s16.hoverId; 187 } 188 if (s16.gridComState !== undefined) { 189 this.gridComState = s16.gridComState; 190 } 191 if (s16.menuSwitch !== undefined) { 192 this.menuSwitch = s16.menuSwitch; 193 } 194 if (s16.areaWidth !== undefined) { 195 this.areaWidth = s16.areaWidth; 196 } 197 if (s16.blockWidth !== undefined) { 198 this.blockWidth = s16.blockWidth; 199 } 200 if (s16.blockHeight !== undefined) { 201 this.blockHeight = s16.blockHeight; 202 } 203 if (s16.longScaleOnePointTwo !== undefined) { 204 this.longScaleOnePointTwo = s16.longScaleOnePointTwo; 205 } 206 if (s16.scaleGridItemNinetyPercent !== undefined) { 207 this.scaleGridItemNinetyPercent = s16.scaleGridItemNinetyPercent; 208 } 209 if (s16.reboundSize !== undefined) { 210 this.reboundSize = s16.reboundSize; 211 } 212 if (s16.scaleIcon !== undefined) { 213 this.scaleIcon = s16.scaleIcon; 214 } 215 if (s16.addIconShow !== undefined) { 216 this.addIconShow = s16.addIconShow; 217 } 218 if (s16.scaleAddIcon !== undefined) { 219 this.scaleAddIcon = s16.scaleAddIcon; 220 } 221 if (s16.isStartDrag !== undefined) { 222 this.isStartDrag = s16.isStartDrag; 223 } 224 if (s16.insertIndex !== undefined) { 225 this.insertIndex = s16.insertIndex; 226 } 227 if (s16.itemIndex !== undefined) { 228 this.itemIndex = s16.itemIndex; 229 } 230 if (s16.editGridDataLength !== undefined) { 231 this.editGridDataLength = s16.editGridDataLength; 232 } 233 if (s16.isTouchDown !== undefined) { 234 this.isTouchDown = s16.isTouchDown; 235 } 236 if (s16.addItemMoveX !== undefined) { 237 this.addItemMoveX = s16.addItemMoveX; 238 } 239 if (s16.addItemMoveY !== undefined) { 240 this.addItemMoveY = s16.addItemMoveY; 241 } 242 if (s16.editItemMoveX !== undefined) { 243 this.editItemMoveX = s16.editItemMoveX; 244 } 245 if (s16.editItemMoveY !== undefined) { 246 this.editItemMoveY = s16.editItemMoveY; 247 } 248 if (s16.unSelectedIndex !== undefined) { 249 this.unSelectedIndex = s16.unSelectedIndex; 250 } 251 if (s16.clickAddBtn !== undefined) { 252 this.clickAddBtn = s16.clickAddBtn; 253 } 254 if (s16.selectedIndex !== undefined) { 255 this.selectedIndex = s16.selectedIndex; 256 } 257 if (s16.clickRemoveBtn !== undefined) { 258 this.clickRemoveBtn = s16.clickRemoveBtn; 259 } 260 if (s16.addAreaLongPressGesture !== undefined) { 261 this.addAreaLongPressGesture = s16.addAreaLongPressGesture; 262 } 263 if (s16.arraySelectIsChange !== undefined) { 264 this.arraySelectIsChange = s16.arraySelectIsChange; 265 } 266 if (s16.arrayUnSelectIsChange !== undefined) { 267 this.arrayUnSelectIsChange = s16.arrayUnSelectIsChange; 268 } 269 if (s16.textItemEditWidth !== undefined) { 270 this.textItemEditWidth = s16.textItemEditWidth; 271 } 272 if (s16.textItemEditHeight !== undefined) { 273 this.textItemEditHeight = s16.textItemEditHeight; 274 } 275 if (s16.imageItemWidth !== undefined) { 276 this.imageItemWidth = s16.imageItemWidth; 277 } 278 if (s16.saveClick !== undefined) { 279 this.saveClick = s16.saveClick; 280 } 281 if (s16.imageTextAddIconShow !== undefined) { 282 this.imageTextAddIconShow = s16.imageTextAddIconShow; 283 } 284 if (s16.imageTextRemoveIconShow !== undefined) { 285 this.imageTextRemoveIconShow = s16.imageTextRemoveIconShow; 286 } 287 if (s16.firstIn !== undefined) { 288 this.firstIn = s16.firstIn; 289 } 290 if (s16.fontSizeScale !== undefined) { 291 this.fontSizeScale = s16.fontSizeScale; 292 } 293 if (s16.customColumns !== undefined) { 294 this.customColumns = s16.customColumns; 295 } 296 if (s16.editGridHeight !== undefined) { 297 this.editGridHeight = s16.editGridHeight; 298 } 299 if (s16.addGridHeight !== undefined) { 300 this.addGridHeight = s16.addGridHeight; 301 } 302 if (s16.subTitleHeight !== undefined) { 303 this.subTitleHeight = s16.subTitleHeight; 304 } 305 if (s16.callbackId !== undefined) { 306 this.callbackId = s16.callbackId; 307 } 308 if (s16.colNum !== undefined) { 309 this.colNum = s16.colNum; 310 } 311 if (s16.vibrationDone !== undefined) { 312 this.vibrationDone = s16.vibrationDone; 313 } 314 if (s16.touchDown !== undefined) { 315 this.touchDown = s16.touchDown; 316 } 317 if (s16.touchBorderRadius !== undefined) { 318 this.touchBorderRadius = s16.touchBorderRadius; 319 } 320 if (s16.hoverBackgroundColor !== undefined) { 321 this.hoverBackgroundColor = s16.hoverBackgroundColor; 322 } 323 if (s16.focusBorder !== undefined) { 324 this.focusBorder = s16.focusBorder; 325 } 326 if (s16.imageText !== undefined) { 327 this.imageText = s16.imageText; 328 } 329 if (s16.menuItems !== undefined) { 330 this.menuItems = s16.menuItems; 331 } 332 if (s16.onSave !== undefined) { 333 this.onSave = s16.onSave; 334 } 335 if (s16.onCancel !== undefined) { 336 this.onCancel = s16.onCancel; 337 } 338 if (s16.isFollowingSystemFontScale !== undefined) { 339 this.isFollowingSystemFontScale = s16.isFollowingSystemFontScale; 340 } 341 if (s16.maxAppFontScale !== undefined) { 342 this.maxAppFontScale = s16.maxAppFontScale; 343 } 344 if (s16.envCallback !== undefined) { 345 this.envCallback = s16.envCallback; 346 } 347 } 348 updateStateVars(r16) { 349 this.__options.reset(r16.options); 350 } 351 purgeVariableDependenciesOnElmtId(q16) { 352 this.__options.purgeDependencyOnElmtId(q16); 353 this.__selected.purgeDependencyOnElmtId(q16); 354 this.__unSelected.purgeDependencyOnElmtId(q16); 355 this.__copySelected.purgeDependencyOnElmtId(q16); 356 this.__copyUnSelected.purgeDependencyOnElmtId(q16); 357 this.__content.purgeDependencyOnElmtId(q16); 358 this.__dragContent.purgeDependencyOnElmtId(q16); 359 this.__dragContentIndex.purgeDependencyOnElmtId(q16); 360 this.__hoverId.purgeDependencyOnElmtId(q16); 361 this.__gridComState.purgeDependencyOnElmtId(q16); 362 this.__menuSwitch.purgeDependencyOnElmtId(q16); 363 this.__areaWidth.purgeDependencyOnElmtId(q16); 364 this.__blockWidth.purgeDependencyOnElmtId(q16); 365 this.__blockHeight.purgeDependencyOnElmtId(q16); 366 this.__longScaleOnePointTwo.purgeDependencyOnElmtId(q16); 367 this.__scaleGridItemNinetyPercent.purgeDependencyOnElmtId(q16); 368 this.__reboundSize.purgeDependencyOnElmtId(q16); 369 this.__scaleIcon.purgeDependencyOnElmtId(q16); 370 this.__addIconShow.purgeDependencyOnElmtId(q16); 371 this.__scaleAddIcon.purgeDependencyOnElmtId(q16); 372 this.__isStartDrag.purgeDependencyOnElmtId(q16); 373 this.__insertIndex.purgeDependencyOnElmtId(q16); 374 this.__itemIndex.purgeDependencyOnElmtId(q16); 375 this.__editGridDataLength.purgeDependencyOnElmtId(q16); 376 this.__isTouchDown.purgeDependencyOnElmtId(q16); 377 this.__addItemMoveX.purgeDependencyOnElmtId(q16); 378 this.__addItemMoveY.purgeDependencyOnElmtId(q16); 379 this.__editItemMoveX.purgeDependencyOnElmtId(q16); 380 this.__editItemMoveY.purgeDependencyOnElmtId(q16); 381 this.__unSelectedIndex.purgeDependencyOnElmtId(q16); 382 this.__clickAddBtn.purgeDependencyOnElmtId(q16); 383 this.__selectedIndex.purgeDependencyOnElmtId(q16); 384 this.__clickRemoveBtn.purgeDependencyOnElmtId(q16); 385 this.__addAreaLongPressGesture.purgeDependencyOnElmtId(q16); 386 this.__arraySelectIsChange.purgeDependencyOnElmtId(q16); 387 this.__arrayUnSelectIsChange.purgeDependencyOnElmtId(q16); 388 this.__textItemEditWidth.purgeDependencyOnElmtId(q16); 389 this.__textItemEditHeight.purgeDependencyOnElmtId(q16); 390 this.__imageItemWidth.purgeDependencyOnElmtId(q16); 391 this.__saveClick.purgeDependencyOnElmtId(q16); 392 this.__imageTextAddIconShow.purgeDependencyOnElmtId(q16); 393 this.__imageTextRemoveIconShow.purgeDependencyOnElmtId(q16); 394 this.__firstIn.purgeDependencyOnElmtId(q16); 395 this.__fontSizeScale.purgeDependencyOnElmtId(q16); 396 this.__customColumns.purgeDependencyOnElmtId(q16); 397 this.__editGridHeight.purgeDependencyOnElmtId(q16); 398 this.__addGridHeight.purgeDependencyOnElmtId(q16); 399 this.__subTitleHeight.purgeDependencyOnElmtId(q16); 400 } 401 aboutToBeDeleted() { 402 this.__options.aboutToBeDeleted(); 403 this.__selected.aboutToBeDeleted(); 404 this.__unSelected.aboutToBeDeleted(); 405 this.__copySelected.aboutToBeDeleted(); 406 this.__copyUnSelected.aboutToBeDeleted(); 407 this.__content.aboutToBeDeleted(); 408 this.__dragContent.aboutToBeDeleted(); 409 this.__dragContentIndex.aboutToBeDeleted(); 410 this.__hoverId.aboutToBeDeleted(); 411 this.__gridComState.aboutToBeDeleted(); 412 this.__menuSwitch.aboutToBeDeleted(); 413 this.__areaWidth.aboutToBeDeleted(); 414 this.__blockWidth.aboutToBeDeleted(); 415 this.__blockHeight.aboutToBeDeleted(); 416 this.__longScaleOnePointTwo.aboutToBeDeleted(); 417 this.__scaleGridItemNinetyPercent.aboutToBeDeleted(); 418 this.__reboundSize.aboutToBeDeleted(); 419 this.__scaleIcon.aboutToBeDeleted(); 420 this.__addIconShow.aboutToBeDeleted(); 421 this.__scaleAddIcon.aboutToBeDeleted(); 422 this.__isStartDrag.aboutToBeDeleted(); 423 this.__insertIndex.aboutToBeDeleted(); 424 this.__itemIndex.aboutToBeDeleted(); 425 this.__editGridDataLength.aboutToBeDeleted(); 426 this.__isTouchDown.aboutToBeDeleted(); 427 this.__addItemMoveX.aboutToBeDeleted(); 428 this.__addItemMoveY.aboutToBeDeleted(); 429 this.__editItemMoveX.aboutToBeDeleted(); 430 this.__editItemMoveY.aboutToBeDeleted(); 431 this.__unSelectedIndex.aboutToBeDeleted(); 432 this.__clickAddBtn.aboutToBeDeleted(); 433 this.__selectedIndex.aboutToBeDeleted(); 434 this.__clickRemoveBtn.aboutToBeDeleted(); 435 this.__addAreaLongPressGesture.aboutToBeDeleted(); 436 this.__arraySelectIsChange.aboutToBeDeleted(); 437 this.__arrayUnSelectIsChange.aboutToBeDeleted(); 438 this.__textItemEditWidth.aboutToBeDeleted(); 439 this.__textItemEditHeight.aboutToBeDeleted(); 440 this.__imageItemWidth.aboutToBeDeleted(); 441 this.__saveClick.aboutToBeDeleted(); 442 this.__imageTextAddIconShow.aboutToBeDeleted(); 443 this.__imageTextRemoveIconShow.aboutToBeDeleted(); 444 this.__firstIn.aboutToBeDeleted(); 445 this.__fontSizeScale.aboutToBeDeleted(); 446 this.__customColumns.aboutToBeDeleted(); 447 this.__editGridHeight.aboutToBeDeleted(); 448 this.__addGridHeight.aboutToBeDeleted(); 449 this.__subTitleHeight.aboutToBeDeleted(); 450 SubscriberManager.Get().delete(this.id__()); 451 this.aboutToBeDeletedInternal(); 452 } 453 get options() { 454 return this.__options.get(); 455 } 456 set options(p16) { 457 this.__options.set(p16); 458 } 459 get selected() { 460 return this.__selected.get(); 461 } 462 set selected(o16) { 463 this.__selected.set(o16); 464 } 465 get unSelected() { 466 return this.__unSelected.get(); 467 } 468 set unSelected(n16) { 469 this.__unSelected.set(n16); 470 } 471 get copySelected() { 472 return this.__copySelected.get(); 473 } 474 set copySelected(m16) { 475 this.__copySelected.set(m16); 476 } 477 get copyUnSelected() { 478 return this.__copyUnSelected.get(); 479 } 480 set copyUnSelected(l16) { 481 this.__copyUnSelected.set(l16); 482 } 483 get content() { 484 return this.__content.get(); 485 } 486 set content(k16) { 487 this.__content.set(k16); 488 } 489 get dragContent() { 490 return this.__dragContent.get(); 491 } 492 set dragContent(j16) { 493 this.__dragContent.set(j16); 494 } 495 get dragContentIndex() { 496 return this.__dragContentIndex.get(); 497 } 498 set dragContentIndex(i16) { 499 this.__dragContentIndex.set(i16); 500 } 501 get hoverId() { 502 return this.__hoverId.get(); 503 } 504 set hoverId(h16) { 505 this.__hoverId.set(h16); 506 } 507 get gridComState() { 508 return this.__gridComState.get(); 509 } 510 set gridComState(g16) { 511 this.__gridComState.set(g16); 512 } 513 get menuSwitch() { 514 return this.__menuSwitch.get(); 515 } 516 set menuSwitch(f16) { 517 this.__menuSwitch.set(f16); 518 } 519 get areaWidth() { 520 return this.__areaWidth.get(); 521 } 522 set areaWidth(e16) { 523 this.__areaWidth.set(e16); 524 } 525 get blockWidth() { 526 return this.__blockWidth.get(); 527 } 528 set blockWidth(d16) { 529 this.__blockWidth.set(d16); 530 } 531 get blockHeight() { 532 return this.__blockHeight.get(); 533 } 534 set blockHeight(c16) { 535 this.__blockHeight.set(c16); 536 } 537 get longScaleOnePointTwo() { 538 return this.__longScaleOnePointTwo.get(); 539 } 540 set longScaleOnePointTwo(b16) { 541 this.__longScaleOnePointTwo.set(b16); 542 } 543 get scaleGridItemNinetyPercent() { 544 return this.__scaleGridItemNinetyPercent.get(); 545 } 546 set scaleGridItemNinetyPercent(a16) { 547 this.__scaleGridItemNinetyPercent.set(a16); 548 } 549 get reboundSize() { 550 return this.__reboundSize.get(); 551 } 552 set reboundSize(z15) { 553 this.__reboundSize.set(z15); 554 } 555 get scaleIcon() { 556 return this.__scaleIcon.get(); 557 } 558 set scaleIcon(y15) { 559 this.__scaleIcon.set(y15); 560 } 561 get addIconShow() { 562 return this.__addIconShow.get(); 563 } 564 set addIconShow(x15) { 565 this.__addIconShow.set(x15); 566 } 567 get scaleAddIcon() { 568 return this.__scaleAddIcon.get(); 569 } 570 set scaleAddIcon(w15) { 571 this.__scaleAddIcon.set(w15); 572 } 573 get isStartDrag() { 574 return this.__isStartDrag.get(); 575 } 576 set isStartDrag(v15) { 577 this.__isStartDrag.set(v15); 578 } 579 get insertIndex() { 580 return this.__insertIndex.get(); 581 } 582 set insertIndex(u15) { 583 this.__insertIndex.set(u15); 584 } 585 get itemIndex() { 586 return this.__itemIndex.get(); 587 } 588 set itemIndex(t15) { 589 this.__itemIndex.set(t15); 590 } 591 get editGridDataLength() { 592 return this.__editGridDataLength.get(); 593 } 594 set editGridDataLength(s15) { 595 this.__editGridDataLength.set(s15); 596 } 597 get isTouchDown() { 598 return this.__isTouchDown.get(); 599 } 600 set isTouchDown(r15) { 601 this.__isTouchDown.set(r15); 602 } 603 get addItemMoveX() { 604 return this.__addItemMoveX.get(); 605 } 606 set addItemMoveX(q15) { 607 this.__addItemMoveX.set(q15); 608 } 609 get addItemMoveY() { 610 return this.__addItemMoveY.get(); 611 } 612 set addItemMoveY(p15) { 613 this.__addItemMoveY.set(p15); 614 } 615 get editItemMoveX() { 616 return this.__editItemMoveX.get(); 617 } 618 set editItemMoveX(o15) { 619 this.__editItemMoveX.set(o15); 620 } 621 get editItemMoveY() { 622 return this.__editItemMoveY.get(); 623 } 624 set editItemMoveY(n15) { 625 this.__editItemMoveY.set(n15); 626 } 627 get unSelectedIndex() { 628 return this.__unSelectedIndex.get(); 629 } 630 set unSelectedIndex(m15) { 631 this.__unSelectedIndex.set(m15); 632 } 633 get clickAddBtn() { 634 return this.__clickAddBtn.get(); 635 } 636 set clickAddBtn(l15) { 637 this.__clickAddBtn.set(l15); 638 } 639 get selectedIndex() { 640 return this.__selectedIndex.get(); 641 } 642 set selectedIndex(k15) { 643 this.__selectedIndex.set(k15); 644 } 645 get clickRemoveBtn() { 646 return this.__clickRemoveBtn.get(); 647 } 648 set clickRemoveBtn(j15) { 649 this.__clickRemoveBtn.set(j15); 650 } 651 get addAreaLongPressGesture() { 652 return this.__addAreaLongPressGesture.get(); 653 } 654 set addAreaLongPressGesture(i15) { 655 this.__addAreaLongPressGesture.set(i15); 656 } 657 get arraySelectIsChange() { 658 return this.__arraySelectIsChange.get(); 659 } 660 set arraySelectIsChange(h15) { 661 this.__arraySelectIsChange.set(h15); 662 } 663 get arrayUnSelectIsChange() { 664 return this.__arrayUnSelectIsChange.get(); 665 } 666 set arrayUnSelectIsChange(g15) { 667 this.__arrayUnSelectIsChange.set(g15); 668 } 669 get textItemEditWidth() { 670 return this.__textItemEditWidth.get(); 671 } 672 set textItemEditWidth(f15) { 673 this.__textItemEditWidth.set(f15); 674 } 675 get textItemEditHeight() { 676 return this.__textItemEditHeight.get(); 677 } 678 set textItemEditHeight(e15) { 679 this.__textItemEditHeight.set(e15); 680 } 681 get imageItemWidth() { 682 return this.__imageItemWidth.get(); 683 } 684 set imageItemWidth(d15) { 685 this.__imageItemWidth.set(d15); 686 } 687 get saveClick() { 688 return this.__saveClick.get(); 689 } 690 set saveClick(c15) { 691 this.__saveClick.set(c15); 692 } 693 get imageTextAddIconShow() { 694 return this.__imageTextAddIconShow.get(); 695 } 696 set imageTextAddIconShow(b15) { 697 this.__imageTextAddIconShow.set(b15); 698 } 699 get imageTextRemoveIconShow() { 700 return this.__imageTextRemoveIconShow.get(); 701 } 702 set imageTextRemoveIconShow(a15) { 703 this.__imageTextRemoveIconShow.set(a15); 704 } 705 get firstIn() { 706 return this.__firstIn.get(); 707 } 708 set firstIn(z14) { 709 this.__firstIn.set(z14); 710 } 711 get fontSizeScale() { 712 return this.__fontSizeScale.get(); 713 } 714 set fontSizeScale(y14) { 715 this.__fontSizeScale.set(y14); 716 } 717 get customColumns() { 718 return this.__customColumns.get(); 719 } 720 set customColumns(x14) { 721 this.__customColumns.set(x14); 722 } 723 get editGridHeight() { 724 return this.__editGridHeight.get(); 725 } 726 set editGridHeight(w14) { 727 this.__editGridHeight.set(w14); 728 } 729 get addGridHeight() { 730 return this.__addGridHeight.get(); 731 } 732 set addGridHeight(v14) { 733 this.__addGridHeight.set(v14); 734 } 735 get subTitleHeight() { 736 return this.__subTitleHeight.get(); 737 } 738 set subTitleHeight(u14) { 739 this.__subTitleHeight.set(u14); 740 } 741 aboutToAppear() { 742 this.dataList.length = 50; 743 this.selected = this.dataList && this.deduplicate(this.dataList).filter(t14 => t14.selected).sort(this.sortBy()); 744 this.unSelected = this.dataList && this.deduplicate(this.dataList).filter(s14 => !s14.selected).sort(this.sortBy()); 745 this.copySelected = this.selected.slice(); 746 this.copyUnSelected = this.unSelected.slice(); 747 this.editGridDataLength = this.selected.length; 748 this.imageText = this.options.type === GridObjectSortComponentType.IMAGE_TEXT; 749 try { 750 let r14 = this.getUIContext(); 751 this.isFollowingSystemFontScale = r14.isFollowingSystemFontScale(); 752 this.maxAppFontScale = r14.getMaxFontScale(); 753 this.fontSizeScale = this.decideFontScale(r14); 754 } 755 catch (o14) { 756 let p14 = o14.code; 757 let q14 = o14.message; 758 hilog.error(0x3900, 'Ace', `GridObjectSortComponent Faild to init fontsizescale info, code:${p14}, message: ${q14}`); 759 } 760 try { 761 this.callbackId = getContext()?.getApplicationContext()?.on('environment', this.envCallback); 762 } 763 catch (l14) { 764 let m14 = l14.code; 765 let n14 = l14.message; 766 hilog.error(0x3900, 'Ace', `GridObjectSortComponent Faild to get environment param error: ${m14}, ${n14}`); 767 } 768 this.calcGridHeight(); 769 setTimeout(() => { 770 this.firstIn = false; 771 }, 500); 772 } 773 calcTextItemEditHeight() { 774 let h14 = MeasureText.measureTextSize({ 775 textContent: this.dataList[0]?.text ?? '', 776 fontSize: `${(LengthMetrics.resource({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_button3'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" })?.value ?? 777 DEFAULT_TEXT_SIZE) * (this.fontSizeScale ?? DEFAULT_FONT_SIZE_SCALE)}vp`, 778 overflow: TextOverflow.Ellipsis, 779 maxLines: TEXT_MAX_LINES 780 }); 781 this.textItemEditHeight = this.fontSizeScale === DEFAULT_FONT_SIZE_SCALE ? 782 GRID_ITEM_HEIGHT_TEXT : px2vp(h14.height); 783 this.textItemEditHeight = this.textItemEditHeight + PADDING_EIGHT * 2; 784 } 785 decideFontScale(f14) { 786 if (!this.isFollowingSystemFontScale) { 787 return 1; 788 } 789 let g14 = f14.getHostContext()?.config.fontSizeScale ?? DEFAULT_FONT_SIZE_SCALE; 790 return Math.min(g14, this.maxAppFontScale, MAX_FONT_SCALE); 791 } 792 calcColNum() { 793 if (this.imageText || (this.fontSizeScale && this.fontSizeScale > DEFAULT_FONT_SIZE_SCALE)) { 794 this.customColumns = GRID_COL_3; 795 this.colNum = COL_IMAGE_TEXT; 796 } 797 else { 798 this.customColumns = GRID_COL_4; 799 this.colNum = COL_TEXT; 800 } 801 } 802 aboutToDisappear() { 803 Context.animateTo({ 804 duration: ENTER_EXIT_ICON_DURATION, 805 curve: COMMON_BEZIER, 806 }, () => { 807 this.gridComState = false; 808 }); 809 this.menuSwitch = false; 810 this.selected = this.copySelected; 811 this.unSelected = this.copyUnSelected; 812 if (this.callbackId) { 813 this.getUIContext() 814 .getHostContext() 815 ?.getApplicationContext() 816 ?.off('environment', this.callbackId); 817 this.callbackId = void (0); 818 } 819 } 820 deduplicate(y13) { 821 const z13 = []; 822 y13.forEach(b14 => { 823 if (!z13.some(d14 => d14.id === b14.id)) { 824 z13.push(b14); 825 } 826 }); 827 return z13; 828 } 829 onGridComStateChange() { 830 this.textItemEditWidth = this.gridComState ? this.blockWidth - 24 : this.blockWidth - 16; 831 if (!this.imageText) { 832 this.blockHeight = this.gridComState ? 833 this.textItemEditHeight + EDIT_BLOCK_TEXT_ITEM_SAFE_MARGIN : 834 this.textItemEditHeight + DEFAULT_BLOCK_TEXT_ITEM_SAFE_MARGIN; 835 } 836 } 837 sortBy() { 838 return (w13, x13) => { 839 return w13.order - x13.order; 840 }; 841 } 842 cancelEdit() { 843 if (this.isStartDrag || this.clickAddBtn || this.clickRemoveBtn) { 844 return; 845 } 846 Context.animateTo({ 847 duration: ENTER_EXIT_ICON_DURATION, 848 curve: LONG_TOUCH_SCALE 849 }, () => { 850 this.longScaleOnePointTwo = 1; 851 }); 852 Context.animateTo({ 853 duration: ENTER_EXIT_ICON_DURATION, 854 curve: COMMON_BEZIER, 855 }, () => { 856 this.gridComState = false; 857 }); 858 this.menuSwitch = false; 859 this.selected = this.copySelected.slice(); 860 this.unSelected = this.copyUnSelected.slice(); 861 this.editGridDataLength = this.selected.length; 862 this.calcGridHeight(); 863 this.onCancel && this.onCancel(); 864 } 865 goEdit() { 866 Context.animateTo({ 867 duration: ENTER_EXIT_ICON_DURATION, 868 curve: COMMON_BEZIER, 869 }, () => { 870 this.gridComState = true; 871 }); 872 this.menuSwitch = true; 873 this.calcGridHeight(); 874 } 875 onSaveEdit() { 876 if (this.isStartDrag) { 877 return; 878 } 879 Context.animateTo({ 880 duration: ENTER_EXIT_ICON_DURATION, 881 curve: LONG_TOUCH_SCALE 882 }, () => { 883 this.longScaleOnePointTwo = 1; 884 }); 885 this.editGridDataLength = this.selected.length; 886 Context.animateTo({ 887 duration: ENTER_EXIT_ICON_DURATION, 888 curve: COMMON_BEZIER, 889 }, () => { 890 this.gridComState = false; 891 this.copySelected = this.selected.slice(); 892 this.copyUnSelected = this.unSelected.slice(); 893 const q13 = this.getNewData(this.selected, true, 0); 894 const r13 = this.getNewData(this.unSelected, false, this.selected.length); 895 this.selected = q13; 896 this.unSelected = r13; 897 this.calcGridHeight(); 898 this.onSave && this.onSave(q13, r13); 899 }); 900 setTimeout(() => { 901 this.saveClick = false; 902 }, ENTER_EXIT_ICON_DURATION); 903 this.menuSwitch = false; 904 } 905 onDragMoveEvent(j13, k13, l13) { 906 if (!this.gridComState || (j13.x < this.blockWidth / 3 && j13.y < this.blockHeight / 3)) { 907 return; 908 } 909 let m13 = l13; 910 if (m13 < 0) { 911 m13 = this.selected.length - 1; 912 } 913 if (this.dragContent.visibility !== Visibility.Hidden) { 914 this.dragContent.visibility = Visibility.Hidden; 915 } 916 this.insertIndex = l13; 917 } 918 handleDeleteClick(d13) { 919 if (this.clickAddBtn || this.clickRemoveBtn) { 920 return; 921 } 922 this.clickRemoveBtn = true; 923 this.scaleIcon = 0; 924 this.arraySelectIsChange = 1; 925 let e13 = this.selected.findIndex(i13 => i13.id === d13.id); 926 this.content = d13; 927 this.selectedIndex = e13; 928 this.calcGridHeight(); 929 Context.animateTo({ curve: REMOVE_ADD_SPRING, onFinish: () => { 930 this.scaleIcon = 1; 931 this.selected.splice(e13, 1); 932 this.unSelected.unshift(d13); 933 this.calcGridHeight(); 934 this.editGridDataLength = this.editGridDataLength - 1; 935 this.editItemMoveX = 0; 936 this.editItemMoveY = 0; 937 this.arraySelectIsChange = 2; 938 this.clickRemoveBtn = false; 939 } }, () => { 940 let h13 = this.getAddItemGridPosition(); 941 this.editItemMoveX = h13.x; 942 this.editItemMoveY = h13.y; 943 }); 944 } 945 getNewData(x12, y12, z12) { 946 return x12.map((b13, c13) => { 947 b13.selected = y12; 948 b13.order = z12 + c13; 949 b13.visibility = Visibility.Visible; 950 return b13; 951 }); 952 } 953 getBlockWidth() { 954 const w12 = (this.areaWidth - 32) / this.colNum; 955 return w12; 956 } 957 calcGridHeight() { 958 this.editGridHeight = this.getGridHeight(this.selected, 'edit'); 959 this.addGridHeight = this.getGridHeight(this.unSelected); 960 } 961 getGridHeight(n12, o12) { 962 let p12 = 0; 963 let q12 = n12.length; 964 n12.forEach(v12 => { 965 if (v12.visibility === Visibility.Hidden) { 966 q12 = q12 - 1; 967 } 968 }); 969 let r12 = 0; 970 let s12 = q12 % this.colNum === 0; 971 if (this.clickAddBtn && s12) { 972 r12 = 1; 973 } 974 else if (this.isStartDrag && s12 && o12) { 975 r12 = 1; 976 } 977 else if (this.clickRemoveBtn && s12 && !o12) { 978 r12 = 1; 979 } 980 else { 981 r12 = 0; 982 } 983 let t12 = Math.ceil(q12 / this.colNum) + r12; 984 p12 = this.blockHeight * t12; 985 if (q12 === 0) { 986 p12 = 0; 987 } 988 return p12; 989 } 990 imageTextRemoveIcon(k12) { 991 const l12 = this.clickRemoveBtn && this.content.id === k12.id; 992 const m12 = l12 ? { "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_add_norm_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } : { "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_remove_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; 993 return m12; 994 } 995 imageTextAddIcon(h12) { 996 const i12 = this.clickAddBtn && this.content.id === h12.id && this.gridComState; 997 const j12 = i12 ? { "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_remove_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } : { "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_add_norm_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; 998 return j12; 999 } 1000 imageTextAddIconVisible(e12) { 1001 const f12 = this.clickAddBtn && this.content.id === e12.id && !this.gridComState; 1002 const g12 = f12 ? Visibility.Hidden : Visibility.Visible; 1003 return g12; 1004 } 1005 getCoodXY(z11) { 1006 let a12 = 0; 1007 let b12 = 0; 1008 const c12 = this.colNum; 1009 const d12 = Math.trunc(z11 % c12); 1010 if (z11 >= this.dragContentIndex) { 1011 if (z11 <= this.insertIndex && z11 !== this.dragContentIndex) { 1012 if (d12 === 0) { 1013 a12 = a12 + this.blockWidth * (c12 - 1); 1014 b12 = b12 - this.blockHeight; 1015 } 1016 else { 1017 a12 = a12 - this.blockWidth; 1018 } 1019 } 1020 } 1021 else { 1022 if (z11 >= this.insertIndex) { 1023 if (d12 === c12 - 1) { 1024 a12 = a12 - this.blockWidth * (c12 - 1); 1025 b12 = b12 + this.blockHeight; 1026 } 1027 else { 1028 a12 = a12 + this.blockWidth; 1029 } 1030 } 1031 } 1032 if (!this.isStartDrag) { 1033 a12 = 0; 1034 b12 = 0; 1035 } 1036 return { x: a12, y: b12 }; 1037 } 1038 getAddItemGridPosition() { 1039 const n11 = this.selected.length; 1040 const o11 = this.colNum; 1041 const p11 = (this.selectedIndex + 1) % o11; 1042 const q11 = Math.ceil((this.selectedIndex + 1) / o11); 1043 const r11 = Math.ceil(n11 / o11); 1044 const s11 = this.imageText; 1045 let t11 = 0; 1046 if (p11 === 0) { 1047 t11 = s11 || (this.fontSizeScale && this.fontSizeScale > 1) ? -this.blockWidth * 2 : -this.blockWidth * 3; 1048 } 1049 else { 1050 t11 = -this.blockWidth * (p11 - 1); 1051 } 1052 let u11 = SUBTITLE_HEIGHT; 1053 let v11 = 0; 1054 const w11 = r11 - q11; 1055 const x11 = n11 % o11; 1056 const y11 = x11 === 1 ? w11 : w11 + 1; 1057 if (this.fontSizeScale && this.fontSizeScale > 1) { 1058 u11 = this.subTitleHeight; 1059 } 1060 v11 = y11 * this.blockHeight + u11; 1061 return { 1062 x: t11, 1063 y: v11 1064 }; 1065 } 1066 getCoveringGridPosition(k11) { 1067 let l11 = 0; 1068 let m11 = 0; 1069 if (k11 > this.selectedIndex && this.arraySelectIsChange !== 2) { 1070 l11 = k11 % this.colNum === 0 ? this.blockWidth * (this.colNum - 1) : -this.blockWidth; 1071 m11 = k11 % this.colNum === 0 ? -this.blockHeight : 0; 1072 } 1073 return { 1074 x: l11, 1075 y: m11 1076 }; 1077 } 1078 getEditItemGridPosition(y10, z10) { 1079 const a11 = y10.length; 1080 const b11 = this.colNum; 1081 const c11 = Math.trunc(a11 % b11); 1082 const d11 = Math.trunc(z10 % b11); 1083 let e11 = Math.abs(c11 - d11) * this.blockWidth; 1084 if (c11 < d11) { 1085 e11 = -e11; 1086 } 1087 else if (c11 > d11) { 1088 e11 = e11; 1089 } 1090 else { 1091 e11 = 0; 1092 } 1093 let f11 = 0; 1094 let g11 = 0; 1095 let h11 = Math.trunc(z10 / this.colNum); 1096 let i11 = SUBTITLE_HEIGHT; 1097 const j11 = !this.imageText && this.gridComState && z10 > 3; 1098 if (j11) { 1099 g11 = (h11 + 1) * (this.blockHeight - 8) + 8; 1100 } 1101 else { 1102 g11 = (h11 + 1) * this.blockHeight; 1103 } 1104 if (this.fontSizeScale && this.fontSizeScale > 1) { 1105 i11 = this.subTitleHeight; 1106 } 1107 f11 = g11 + i11; 1108 return { 1109 x: e11, 1110 y: f11 1111 }; 1112 } 1113 getCoveringGridPositionBottom(t10) { 1114 let u10 = 0; 1115 let v10 = 0; 1116 const w10 = t10 % this.colNum === 0; 1117 const x10 = this.gridComState && !this.imageText ? -this.blockHeight + 8 : -this.blockHeight; 1118 if (t10 > this.unSelectedIndex && this.arrayUnSelectIsChange !== 2) { 1119 u10 = w10 ? this.blockWidth * (this.colNum - 1) : -this.blockWidth; 1120 v10 = w10 ? x10 : 0; 1121 } 1122 return { 1123 x: u10, 1124 y: v10 1125 }; 1126 } 1127 getAddItemRightMove(p10) { 1128 let q10 = this.blockWidth; 1129 let r10 = 0; 1130 let s10 = (p10 + 1) % this.colNum === 0; 1131 if (s10) { 1132 q10 = -this.blockWidth * (this.colNum - 1); 1133 r10 = this.imageText ? this.blockHeight : this.blockHeight - 8; 1134 } 1135 return { x: q10, y: r10 }; 1136 } 1137 getShowAreaItemTranslate(m10) { 1138 if (this.isStartDrag) { 1139 let o10 = this.getCoodXY(m10); 1140 return { 1141 x: o10.x, 1142 y: o10.y 1143 }; 1144 } 1145 if (!this.isStartDrag && m10 === this.selectedIndex) { 1146 return { 1147 x: this.editItemMoveX, 1148 y: this.editItemMoveY 1149 }; 1150 } 1151 if (!this.isStartDrag && m10 !== this.selectedIndex && this.clickRemoveBtn) { 1152 let n10 = this.getCoveringGridPosition(m10); 1153 return { 1154 x: n10.x, 1155 y: n10.y 1156 }; 1157 } 1158 return { x: 0, y: 0 }; 1159 } 1160 getAddAreaItemTranslate(j10) { 1161 if (this.clickRemoveBtn) { 1162 let l10 = this.getAddItemRightMove(j10); 1163 return { 1164 x: l10.x, 1165 y: l10.y 1166 }; 1167 } 1168 if (!this.clickRemoveBtn && j10 === this.unSelectedIndex) { 1169 return { 1170 x: this.addItemMoveX, 1171 y: -this.addItemMoveY 1172 }; 1173 } 1174 if (!this.clickRemoveBtn && j10 !== this.unSelectedIndex && this.clickAddBtn) { 1175 let k10 = this.getCoveringGridPositionBottom(j10); 1176 return { 1177 x: k10.x, 1178 y: k10.y 1179 }; 1180 } 1181 return { x: 0, y: 0 }; 1182 } 1183 PixelMapBuilder(d9, e9, f9 = null) { 1184 this.observeComponentCreation2((h10, i10) => { 1185 Stack.create({ alignContent: Alignment.Center }); 1186 Stack.clip(false); 1187 Stack.height(this.blockHeight * 1.5); 1188 Stack.width(this.blockWidth * 1.2); 1189 }, Stack); 1190 this.observeComponentCreation2((i9, j9) => { 1191 If.create(); 1192 if (this.imageText) { 1193 this.ifElseBranchUpdateFunction(0, () => { 1194 this.observeComponentCreation2((f10, g10) => { 1195 Column.create(); 1196 Column.alignItems(HorizontalAlign.Center); 1197 Column.justifyContent(FlexAlign.Center); 1198 Column.width(this.imageItemWidth); 1199 Column.height(this.imageItemWidth); 1200 Column.padding({ left: MARGIN_EIGHT, right: MARGIN_EIGHT }); 1201 Column.backgroundColor(this.touchDown); 1202 Column.borderRadius(this.touchBorderRadius); 1203 Column.scale({ x: this.longScaleOnePointTwo, y: this.longScaleOnePointTwo }); 1204 }, Column); 1205 this.observeComponentCreation2((d10, e10) => { 1206 Image.create(d9); 1207 Image.draggable(false); 1208 Image.height(this.options.imageSize || IMAGE_DEFAULT); 1209 Image.width((this.options.imageSize || IMAGE_DEFAULT)); 1210 }, Image); 1211 this.observeComponentCreation2((b10, c10) => { 1212 Text.create(e9); 1213 Text.textAlign(TextAlign.Center); 1214 Text.fontSize({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_button3'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1215 Text.margin({ top: 2 }); 1216 Text.maxLines(TEXT_MAX_LINES); 1217 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1218 Text.minFontScale(MIN_FONT_SCALE); 1219 Text.maxFontScale(ObservedObject.GetRawObject(this.fontSizeScale)); 1220 }, Text); 1221 Text.pop(); 1222 this.observeComponentCreation2((z9, a10) => { 1223 Image.create({ "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_remove_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1224 Image.draggable(false); 1225 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1226 Image.width(ICON_SIZE); 1227 Image.height(ICON_SIZE); 1228 Image.position({ 1229 x: this.blockWidth - 40, 1230 y: -MARGIN_EIGHT 1231 }); 1232 }, Image); 1233 Column.pop(); 1234 }); 1235 } 1236 else { 1237 this.ifElseBranchUpdateFunction(1, () => { 1238 this.observeComponentCreation2((s9, t9) => { 1239 Row.create(); 1240 Row.borderRadius(50); 1241 Row.padding({ 1242 left: TEXT_PADDING_LEFT_RIGHT, 1243 right: TEXT_PADDING_LEFT_RIGHT, 1244 }); 1245 Row.scale({ x: this.longScaleOnePointTwo, y: this.longScaleOnePointTwo }); 1246 Row.alignItems(VerticalAlign.Center); 1247 Row.justifyContent(FlexAlign.Center); 1248 Row.backgroundColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_button_normal'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1249 Row.width(this.textItemEditWidth); 1250 Row.height(this.textItemEditHeight); 1251 }, Row); 1252 this.observeComponentCreation2((q9, r9) => { 1253 Text.create(e9); 1254 Text.fontColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_text_primary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1255 Text.fontSize({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_button3'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1256 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1257 Text.textAlign(TextAlign.Center); 1258 Text.maxLines(TEXT_MAX_LINES); 1259 Text.minFontScale(MIN_FONT_SCALE); 1260 Text.maxFontScale(ObservedObject.GetRawObject(this.fontSizeScale)); 1261 }, Text); 1262 Text.pop(); 1263 this.observeComponentCreation2((o9, p9) => { 1264 Image.create({ "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_remove_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1265 Image.draggable(false); 1266 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1267 Image.width(ICON_SIZE); 1268 Image.height(ICON_SIZE); 1269 Image.position({ 1270 x: this.blockWidth - 52, 1271 y: -MARGIN_EIGHT 1272 }); 1273 }, Image); 1274 Row.pop(); 1275 }); 1276 } 1277 }, If); 1278 If.pop(); 1279 Stack.pop(); 1280 } 1281 HeaderTitleBuilder(i8 = null) { 1282 this.observeComponentCreation2((b9, c9) => { 1283 __Common__.create(); 1284 __Common__.visibility(!this.menuSwitch ? Visibility.Visible : Visibility.None); 1285 }, __Common__); 1286 { 1287 this.observeComponentCreation2((v8, w8) => { 1288 if (w8) { 1289 let x8 = new ComposeTitleBar(this, { 1290 title: this.options.normalTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_title_chanel'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 1291 menuItems: this.menuItems, 1292 }, undefined, v8, () => { }, { page: "librarys/gridobjectsortcomponent/src/main/ets/components/GridObjectSortComponent.ets", line: 764, col: 5 }); 1293 ViewPU.create(x8); 1294 let r17 = () => { 1295 return { 1296 title: this.options.normalTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_title_chanel'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 1297 menuItems: this.menuItems 1298 }; 1299 }; 1300 x8.paramsGenerator_ = r17; 1301 } 1302 else { 1303 this.updateStateVarsOfChildByElmtId(v8, {}); 1304 } 1305 }, { name: "ComposeTitleBar" }); 1306 } 1307 __Common__.pop(); 1308 this.observeComponentCreation2((s8, t8) => { 1309 __Common__.create(); 1310 __Common__.visibility(this.menuSwitch ? Visibility.Visible : Visibility.None); 1311 }, __Common__); 1312 { 1313 this.observeComponentCreation2((m8, n8) => { 1314 if (n8) { 1315 let o8 = new EditableTitleBar(this, { 1316 leftIconStyle: EditableLeftIconType.Cancel, 1317 menuItems: [], 1318 title: this.options.editTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_title_edit'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 1319 onCancel: () => { 1320 this.cancelEdit(); 1321 }, 1322 onSave: () => { 1323 this.saveClick = true; 1324 this.onSaveEdit(); 1325 } 1326 }, undefined, m8, () => { }, { page: "librarys/gridobjectsortcomponent/src/main/ets/components/GridObjectSortComponent.ets", line: 769, col: 5 }); 1327 ViewPU.create(o8); 1328 let q17 = () => { 1329 return { 1330 leftIconStyle: EditableLeftIconType.Cancel, 1331 menuItems: [], 1332 title: this.options.editTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_title_edit'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 1333 onCancel: () => { 1334 this.cancelEdit(); 1335 }, 1336 onSave: () => { 1337 this.saveClick = true; 1338 this.onSaveEdit(); 1339 } 1340 }; 1341 }; 1342 o8.paramsGenerator_ = q17; 1343 } 1344 else { 1345 this.updateStateVarsOfChildByElmtId(m8, {}); 1346 } 1347 }, { name: "EditableTitleBar" }); 1348 } 1349 __Common__.pop(); 1350 } 1351 ImageTextBuilder(e7, f7, g7 = null) { 1352 this.observeComponentCreation2((g8, h8) => { 1353 Column.create(); 1354 Column.padding({ left: MARGIN_EIGHT, right: MARGIN_EIGHT }); 1355 Column.width('100%'); 1356 }, Column); 1357 this.observeComponentCreation2((e8, f8) => { 1358 Column.create(); 1359 Column.alignItems(HorizontalAlign.Center); 1360 Column.justifyContent(FlexAlign.Center); 1361 Column.width('100%'); 1362 Column.height(this.imageItemWidth); 1363 Column.padding({ left: MARGIN_EIGHT, right: MARGIN_EIGHT }); 1364 Column.borderRadius((this.isTouchDown && e7.id === this.content.id) || 1365 e7.id === this.hoverId ? this.touchBorderRadius : 0); 1366 Column.backgroundColor(this.isTouchDown && e7.id === this.content.id 1367 ? this.touchDown : e7.id === this.hoverId ? this.hoverBackgroundColor : ''); 1368 Column.scale(e7.id === this.content.id ? { x: this.longScaleOnePointTwo, y: this.longScaleOnePointTwo } : {}); 1369 }, Column); 1370 this.observeComponentCreation2((c8, d8) => { 1371 Image.create(e7.url); 1372 Image.draggable(false); 1373 Image.height(this.options.imageSize || IMAGE_DEFAULT); 1374 Image.width((this.options.imageSize || IMAGE_DEFAULT)); 1375 }, Image); 1376 this.observeComponentCreation2((a8, b8) => { 1377 Text.create(e7.text); 1378 Text.textAlign(TextAlign.Center); 1379 Text.fontSize({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_button3'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1380 Text.margin({ top: 2 }); 1381 Text.maxLines(TEXT_MAX_LINES); 1382 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1383 Text.minFontScale(MIN_FONT_SCALE); 1384 Text.maxFontScale(ObservedObject.GetRawObject(this.fontSizeScale)); 1385 Text.padding({ 1386 top: PADDING_EIGHT, 1387 bottom: PADDING_EIGHT 1388 }); 1389 }, Text); 1390 Text.pop(); 1391 this.observeComponentCreation2((q7, r7) => { 1392 Image.create(this.imageTextAddIcon(e7)); 1393 Image.draggable(false); 1394 Image.visibility(f7 === 'add' ? this.imageTextAddIconVisible(e7) : Visibility.Hidden); 1395 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1396 Image.width(ICON_SIZE); 1397 Image.height(ICON_SIZE); 1398 Image.position({ 1399 x: this.blockWidth - 40, 1400 y: -MARGIN_EIGHT 1401 }); 1402 Image.onClick(() => { 1403 if (this.clickAddBtn || this.clickRemoveBtn) { 1404 return; 1405 } 1406 this.scaleIcon = 0; 1407 this.content = e7; 1408 const t7 = this.unSelected.findIndex(z7 => z7.id === e7.id); 1409 this.editGridDataLength = this.selected.length + 1; 1410 const u7 = this.getEditItemGridPosition(ObservedObject.GetRawObject(this.selected), t7); 1411 this.unSelectedIndex = t7; 1412 this.arrayUnSelectIsChange = 1; 1413 this.clickAddBtn = true; 1414 this.calcGridHeight(); 1415 Context.animateTo({ 1416 curve: REMOVE_ADD_SPRING, 1417 onFinish: () => { 1418 if (!this.selected.some(y7 => y7.id === e7.id)) { 1419 this.arrayUnSelectIsChange = 2; 1420 this.scaleIcon = 1; 1421 this.selected.push(e7); 1422 this.unSelected.splice(t7, 1); 1423 this.calcGridHeight(); 1424 this.addItemMoveX = 0; 1425 this.addItemMoveY = 0; 1426 if (!this.gridComState) { 1427 this.onSaveEdit(); 1428 } 1429 this.clickAddBtn = false; 1430 } 1431 } 1432 }, () => { 1433 this.addItemMoveX = u7.x; 1434 this.addItemMoveY = u7.y; 1435 }); 1436 }); 1437 }, Image); 1438 this.observeComponentCreation2((n7, o7) => { 1439 Image.create(this.imageTextRemoveIcon(e7)); 1440 Image.draggable(false); 1441 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1442 Image.visibility(f7 === 'delete' && this.gridComState ? Visibility.Visible : Visibility.Hidden); 1443 Image.width(ICON_SIZE); 1444 Image.height(ICON_SIZE); 1445 Image.position({ 1446 x: this.blockWidth - 40, 1447 y: -MARGIN_EIGHT 1448 }); 1449 Image.onClick(() => this.handleDeleteClick(e7)); 1450 }, Image); 1451 Column.pop(); 1452 Column.pop(); 1453 } 1454 TextBlockBuilder(j6, k6 = null) { 1455 this.observeComponentCreation2((c7, d7) => { 1456 Stack.create(); 1457 Stack.scale(j6.id === this.content.id ? { x: this.longScaleOnePointTwo, y: this.longScaleOnePointTwo } : {}); 1458 Stack.padding({ 1459 left: MARGIN_EIGHT, 1460 right: MARGIN_EIGHT 1461 }); 1462 Stack.height(this.textItemEditHeight); 1463 }, Stack); 1464 this.observeComponentCreation2((a7, b7) => { 1465 Row.create(); 1466 Context.animation(!this.firstIn ? { 1467 duration: ENTER_EXIT_ICON_DURATION, 1468 curve: this.gridComState ? DRAG_SPRING : COMMON_BEZIER 1469 } : { duration: 0 }); 1470 Row.borderRadius(50); 1471 Row.width(this.clickRemoveBtn && j6.id === this.content.id ? this.textItemEditWidth + 8 : this.textItemEditWidth); 1472 Row.translate(this.gridComState ? this.clickRemoveBtn && 1473 j6.id === this.content.id ? { x: 0 } : { x: -4 } : { x: 0 }); 1474 Row.height('100%'); 1475 Context.animation(null); 1476 Row.backgroundColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_button_normal'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1477 }, Row); 1478 Row.pop(); 1479 this.observeComponentCreation2((y6, z6) => { 1480 Flex.create({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }); 1481 Context.animation(!this.firstIn ? { 1482 duration: ENTER_EXIT_ICON_DURATION, 1483 curve: this.gridComState ? DRAG_SPRING : COMMON_BEZIER 1484 } : { duration: 0 }); 1485 Flex.borderRadius(50); 1486 Flex.padding({ 1487 left: TEXT_PADDING_LEFT_RIGHT, 1488 right: TEXT_PADDING_LEFT_RIGHT, 1489 }); 1490 Flex.backgroundColor(this.isTouchDown && j6.id === this.content.id ? this.touchDown 1491 : j6.id === this.hoverId ? this.hoverBackgroundColor 1492 : ''); 1493 Flex.width(this.clickRemoveBtn && j6.id === this.content.id ? this.textItemEditWidth + 8 : this.textItemEditWidth); 1494 Flex.translate(this.gridComState ? this.clickRemoveBtn && j6.id === this.content.id ? { x: 0 } : { x: -4 } : { 1495 x: 0 1496 }); 1497 Flex.height('100%'); 1498 Context.animation(null); 1499 }, Flex); 1500 this.observeComponentCreation2((w6, x6) => { 1501 Image.create({ "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_add'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1502 Context.animation({ 1503 duration: ENTER_EXIT_ICON_DURATION, 1504 curve: COMMON_BEZIER 1505 }); 1506 Image.width(12); 1507 Image.height(12); 1508 Image.draggable(false); 1509 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_text_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1510 Image.visibility(this.clickRemoveBtn && j6.id === this.content.id ? Visibility.Visible : Visibility.None); 1511 Image.transition({ type: TransitionType.All, scale: { x: 0, y: 0, } }); 1512 Image.margin({ right: 4 }); 1513 Context.animation(null); 1514 }, Image); 1515 this.observeComponentCreation2((u6, v6) => { 1516 Text.create(j6.text); 1517 Text.fontColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_text_primary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1518 Text.fontSize({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_button3'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1519 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1520 Text.textAlign(TextAlign.Center); 1521 Text.maxLines(TEXT_MAX_LINES); 1522 Text.minFontScale(MIN_FONT_SCALE); 1523 Text.maxFontScale(ObservedObject.GetRawObject(this.fontSizeScale)); 1524 }, Text); 1525 Text.pop(); 1526 this.observeComponentCreation2((r6, s6) => { 1527 Image.create({ "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_remove_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1528 Context.animation({ 1529 duration: ENTER_EXIT_ICON_DURATION, 1530 curve: COMMON_BEZIER, 1531 }); 1532 Image.draggable(false); 1533 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1534 Image.width(ICON_SIZE); 1535 Image.transition({ type: TransitionType.All, scale: { x: 0, y: 0, centerX: '50%' } }); 1536 Image.scale(j6.id === this.content.id ? { x: this.scaleIcon, y: this.scaleIcon } : {}); 1537 Image.visibility(this.gridComState ? 0 : 1); 1538 Image.position({ 1539 x: this.blockWidth - 52, 1540 y: -MARGIN_EIGHT 1541 }); 1542 Context.animation(null); 1543 Image.onClick(() => this.handleDeleteClick(j6)); 1544 }, Image); 1545 Flex.pop(); 1546 Stack.pop(); 1547 } 1548 TextBlockAddItemBuilder(k5, l5 = null) { 1549 this.observeComponentCreation2((h6, i6) => { 1550 Stack.create(); 1551 Stack.scale(k5.id === this.content.id ? { x: this.longScaleOnePointTwo, y: this.longScaleOnePointTwo } : {}); 1552 Stack.padding({ 1553 left: MARGIN_EIGHT, 1554 right: MARGIN_EIGHT 1555 }); 1556 Stack.height(this.textItemEditHeight); 1557 }, Stack); 1558 this.observeComponentCreation2((f6, g6) => { 1559 Row.create(); 1560 Context.animation({ 1561 duration: ENTER_EXIT_ICON_DURATION, 1562 curve: COMMON_BEZIER 1563 }); 1564 Row.borderRadius(50); 1565 Row.height('100%'); 1566 Row.width(this.addIconShow && k5.id === this.content.id ? this.textItemEditWidth : '100%'); 1567 Row.translate(this.addIconShow && k5.id === this.content.id && this.gridComState ? { x: -4 } : { x: 0 }); 1568 Context.animation(null); 1569 Row.backgroundColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_button_normal'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1570 }, Row); 1571 Row.pop(); 1572 this.observeComponentCreation2((d6, e6) => { 1573 Flex.create({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }); 1574 Context.animation({ 1575 duration: ENTER_EXIT_ICON_DURATION, 1576 curve: COMMON_BEZIER 1577 }); 1578 Flex.borderRadius(50); 1579 Flex.padding({ 1580 left: TEXT_PADDING_LEFT_RIGHT, 1581 right: TEXT_PADDING_LEFT_RIGHT, 1582 }); 1583 Flex.backgroundColor(this.isTouchDown && k5.id === this.content.id ? this.touchDown 1584 : k5.id === this.hoverId ? this.hoverBackgroundColor : ''); 1585 Flex.width(this.addIconShow && k5.id === this.content.id ? this.textItemEditWidth : '100%'); 1586 Flex.translate(this.addIconShow && k5.id === this.content.id && this.gridComState ? { x: -4 } : { x: 0 }); 1587 Context.animation(null); 1588 Flex.height('100%'); 1589 }, Flex); 1590 this.observeComponentCreation2((b6, c6) => { 1591 Image.create({ "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_add'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1592 Context.animation({ 1593 duration: ENTER_EXIT_ICON_DURATION, 1594 curve: COMMON_BEZIER 1595 }); 1596 Image.draggable(false); 1597 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_text_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1598 Image.width(12); 1599 Image.height(12); 1600 Image.visibility(this.addIconShow && k5.id === this.content.id ? Visibility.None : Visibility.Visible); 1601 Image.transition({ type: TransitionType.All, scale: { x: 0, y: 0 } }); 1602 Image.margin({ right: 4 }); 1603 Context.animation(null); 1604 }, Image); 1605 this.observeComponentCreation2((z5, a6) => { 1606 Text.create(k5.text); 1607 Text.fontSize({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_button3'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1608 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1609 Text.textAlign(TextAlign.Start); 1610 Text.maxLines(TEXT_MAX_LINES); 1611 Text.minFontScale(MIN_FONT_SCALE); 1612 Text.maxFontScale(ObservedObject.GetRawObject(this.fontSizeScale)); 1613 }, Text); 1614 Text.pop(); 1615 this.observeComponentCreation2((s5, t5) => { 1616 If.create(); 1617 if (this.gridComState && this.addIconShow && k5.id === this.content.id) { 1618 this.ifElseBranchUpdateFunction(0, () => { 1619 this.observeComponentCreation2((x5, y5) => { 1620 Image.create({ "id": -1, "type": 20000, params: ['sys.media.ohos_ic_public_remove_filled'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1621 Image.draggable(false); 1622 Image.transition({ type: TransitionType.All, scale: { x: 0, y: 0 } }); 1623 Image.fillColor({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1624 Image.width(ICON_SIZE); 1625 Image.translate(this.gridComState ? { x: -MARGIN_EIGHT } : {}); 1626 Image.position({ 1627 x: this.blockWidth - 44, 1628 y: -MARGIN_EIGHT 1629 }); 1630 }, Image); 1631 }); 1632 } 1633 else { 1634 this.ifElseBranchUpdateFunction(1, () => { 1635 }); 1636 } 1637 }, If); 1638 If.pop(); 1639 Flex.pop(); 1640 Stack.pop(); 1641 } 1642 AddTagBuilder(o3 = null) { 1643 this.observeComponentCreation2((i5, j5) => { 1644 Grid.create(); 1645 Context.animation({ 1646 duration: ENTER_EXIT_ICON_DURATION, 1647 curve: this.imageText ? REMOVE_ADD_SPRING : COMMON_BEZIER, 1648 }); 1649 Grid.translate(this.clickRemoveBtn && this.selected.length % this.colNum === 1 ? { y: -this.blockHeight } : {}); 1650 Context.animation(null); 1651 Grid.columnsTemplate(this.customColumns); 1652 Grid.padding({ 1653 left: ROW_GAP, 1654 right: ROW_GAP, 1655 }); 1656 Grid.clip(false); 1657 Grid.height(this.addGridHeight); 1658 }, Grid); 1659 this.observeComponentCreation2((r3, s3) => { 1660 ForEach.create(); 1661 const n17 = (x3, y3) => { 1662 const z3 = x3; 1663 { 1664 const o17 = (f5, g5) => { 1665 GridItem.create(() => { }, false); 1666 Context.animation({ 1667 curve: this.clickRemoveBtn ? DRAG_SPRING : y3 === this.unSelectedIndex ? REMOVE_ADD_SPRING : DRAG_SPRING 1668 }); 1669 GridItem.clip(false); 1670 GridItem.translate(this.getAddAreaItemTranslate(y3)); 1671 Context.animation(null); 1672 }; 1673 const p17 = () => { 1674 this.observeComponentCreation2(o17, GridItem); 1675 this.observeComponentCreation2((k4, l4) => { 1676 Stack.create(); 1677 Stack.onHover((e5) => { 1678 if (e5) { 1679 this.hoverId = z3.id; 1680 } 1681 else { 1682 this.hoverId = ''; 1683 } 1684 }); 1685 Stack.margin({ 1686 bottom: this.imageText ? ROW_GAP : MARGIN_EIGHT 1687 }); 1688 Stack.clickEffect({ level: ClickEffectLevel.LIGHT }); 1689 Stack.onTouch((u4) => { 1690 if (this.clickAddBtn || this.clickRemoveBtn) { 1691 return; 1692 } 1693 if (u4.type === TouchType.Down) { 1694 this.content = z3; 1695 this.isTouchDown = true; 1696 } 1697 if (u4.type === TouchType.Up) { 1698 this.isTouchDown = false; 1699 if (this.addAreaLongPressGesture || this.longScaleOnePointTwo === 1.05 || this.imageText) { 1700 return; 1701 } 1702 Context.animateTo({ 1703 duration: ENTER_EXIT_ICON_DURATION, 1704 curve: COMMON_BEZIER 1705 }, () => { 1706 this.addIconShow = true; 1707 }); 1708 if (this.options.type === GridObjectSortComponentType.TEXT) { 1709 this.scaleAddIcon = 1; 1710 } 1711 this.scaleIcon = 0; 1712 const v4 = this.unSelected.findIndex(d5 => d5.id === z3.id); 1713 this.editGridDataLength = this.selected.length + 1; 1714 const w4 = this.getEditItemGridPosition(ObservedObject.GetRawObject(this.selected), v4); 1715 this.content = z3; 1716 this.unSelectedIndex = v4; 1717 this.clickAddBtn = true; 1718 this.arrayUnSelectIsChange = 1; 1719 this.calcGridHeight(); 1720 Context.animateTo({ curve: REMOVE_ADD_SPRING, onFinish: () => { 1721 if (!this.selected.some(c5 => c5.id === z3.id)) { 1722 this.scaleIcon = 1; 1723 this.scaleAddIcon = 0; 1724 this.selected.push(z3); 1725 this.unSelected.splice(v4, 1); 1726 this.calcGridHeight(); 1727 this.arrayUnSelectIsChange = 2; 1728 this.addItemMoveX = 0; 1729 this.addItemMoveY = 0; 1730 if (!this.gridComState) { 1731 this.onSaveEdit(); 1732 } 1733 Context.animateTo({ 1734 duration: ENTER_EXIT_ICON_DURATION, 1735 curve: COMMON_BEZIER 1736 }, () => { 1737 this.addIconShow = false; 1738 }); 1739 this.clickAddBtn = false; 1740 } 1741 } }, () => { 1742 this.addItemMoveX = w4.x; 1743 this.addItemMoveY = w4.y; 1744 }); 1745 } 1746 }); 1747 Gesture.create(GesturePriority.Low); 1748 LongPressGesture.create({ repeat: true }); 1749 LongPressGesture.onAction((r4) => { 1750 if (!this.gridComState) { 1751 Context.animateTo({ 1752 duration: ENTER_EXIT_ICON_DURATION, 1753 curve: COMMON_BEZIER, 1754 }, () => { 1755 this.addAreaLongPressGesture = true; 1756 this.gridComState = true; 1757 }); 1758 this.menuSwitch = true; 1759 } 1760 else { 1761 Context.animateTo({ 1762 duration: ENTER_EXIT_ICON_DURATION, 1763 curve: LONG_TOUCH_SCALE 1764 }, () => { 1765 this.longScaleOnePointTwo = 1.05; 1766 }); 1767 } 1768 this.calcGridHeight(); 1769 }); 1770 LongPressGesture.onActionEnd(() => { 1771 this.addAreaLongPressGesture = false; 1772 Context.animateTo({ 1773 duration: ENTER_EXIT_ICON_DURATION, 1774 curve: LONG_TOUCH_SCALE 1775 }, () => { 1776 this.longScaleOnePointTwo = 1; 1777 }); 1778 }); 1779 LongPressGesture.pop(); 1780 Gesture.pop(); 1781 }, Stack); 1782 this.observeComponentCreation2((g4, h4) => { 1783 If.create(); 1784 if (this.imageText) { 1785 this.ifElseBranchUpdateFunction(0, () => { 1786 this.ImageTextBuilder.bind(this)(z3, 'add'); 1787 }); 1788 } 1789 else { 1790 this.ifElseBranchUpdateFunction(1, () => { 1791 this.TextBlockAddItemBuilder.bind(this)(z3); 1792 }); 1793 } 1794 }, If); 1795 If.pop(); 1796 Stack.pop(); 1797 GridItem.pop(); 1798 }; 1799 p17(); 1800 } 1801 }; 1802 this.forEachUpdateFunction(r3, this.unSelected, n17, (w3) => w3.id.toString(), true, false); 1803 }, ForEach); 1804 ForEach.pop(); 1805 Grid.pop(); 1806 } 1807 EditTagBuilder(m1 = null) { 1808 this.observeComponentCreation2((m3, n3) => { 1809 Column.create(); 1810 }, Column); 1811 this.observeComponentCreation2((t2, u2) => { 1812 Grid.create(); 1813 Context.animation(!this.firstIn ? { 1814 duration: ENTER_EXIT_ICON_DURATION, 1815 curve: this.imageText ? REMOVE_ADD_SPRING : COMMON_BEZIER, 1816 } : { duration: 0 }); 1817 Gesture.create(GesturePriority.Parallel); 1818 LongPressGesture.create({ repeat: true }); 1819 LongPressGesture.onAction((i3) => { 1820 if (!this.gridComState) { 1821 Context.animateTo({ 1822 duration: ENTER_EXIT_ICON_DURATION, 1823 curve: COMMON_BEZIER 1824 }, () => { 1825 this.gridComState = true; 1826 }); 1827 this.menuSwitch = true; 1828 } 1829 else { 1830 Context.animateTo({ 1831 duration: ENTER_EXIT_ICON_DURATION, 1832 curve: LONG_TOUCH_SCALE 1833 }, () => { 1834 this.longScaleOnePointTwo = 1.05; 1835 }); 1836 if (i3.repeat && !this.vibrationDone) { 1837 try { 1838 vibrator.startVibration({ 1839 type: 'time', 1840 duration: 1000 1841 }, { 1842 id: 0, 1843 usage: 'alarm' 1844 }).then(() => { 1845 this.vibrationDone = true; 1846 }); 1847 } 1848 catch { 1849 this.vibrationDone = false; 1850 } 1851 } 1852 } 1853 this.calcGridHeight(); 1854 }); 1855 LongPressGesture.pop(); 1856 Gesture.pop(); 1857 Grid.clip(false); 1858 Grid.editMode(this.gridComState); 1859 Grid.columnsTemplate(this.customColumns); 1860 Grid.padding({ 1861 left: ROW_GAP, 1862 right: ROW_GAP 1863 }); 1864 Grid.height(this.editGridHeight); 1865 Context.animation(null); 1866 Grid.onItemDragStart((g3, h3) => { 1867 this.itemIndex = h3; 1868 this.selectedIndex = -1; 1869 if (!this.gridComState) { 1870 return; 1871 } 1872 this.isStartDrag = true; 1873 this.insertIndex = h3; 1874 this.dragContent = this.selected[h3]; 1875 this.dragContentIndex = h3; 1876 return { builder: () => { 1877 this.PixelMapBuilder.call(this, this.dragContent?.url, this.dragContent?.text); 1878 } }; 1879 }); 1880 Grid.onItemDrop((c3, d3, e3, f3) => { 1881 this.insertItem(d3, e3); 1882 }); 1883 Grid.onItemDragMove((z2, a3, b3) => this.onDragMoveEvent(z2, a3, b3)); 1884 }, Grid); 1885 this.observeComponentCreation2((q1, r1) => { 1886 ForEach.create(); 1887 const k17 = (w1, x1) => { 1888 const y1 = w1; 1889 { 1890 const l17 = (q2, r2) => { 1891 GridItem.create(() => { }, false); 1892 Context.animation({ 1893 curve: this.isStartDrag ? DRAG_SPRING : x1 === this.selectedIndex ? REMOVE_ADD_SPRING : DRAG_SPRING, 1894 }); 1895 GridItem.clip(false); 1896 GridItem.translate(this.getShowAreaItemTranslate(x1)); 1897 Context.animation(null); 1898 GridItem.visibility(y1.visibility); 1899 }; 1900 const m17 = () => { 1901 this.observeComponentCreation2(l17, GridItem); 1902 this.observeComponentCreation2((j2, k2) => { 1903 Stack.create(); 1904 Stack.onHover((p2) => { 1905 if (p2) { 1906 this.hoverId = y1.id; 1907 } 1908 else { 1909 this.hoverId = ''; 1910 } 1911 }); 1912 Stack.clickEffect({ level: ClickEffectLevel.LIGHT }); 1913 Stack.clip(false); 1914 Stack.margin({ 1915 bottom: this.imageText ? ROW_GAP : this.gridComState ? ROW_GAP : MARGIN_EIGHT 1916 }); 1917 Stack.onTouch((n2) => { 1918 if (this.clickAddBtn || this.clickRemoveBtn) { 1919 return; 1920 } 1921 if (n2.type === TouchType.Down) { 1922 this.content = y1; 1923 this.isTouchDown = true; 1924 } 1925 if (n2.type === TouchType.Up) { 1926 this.isTouchDown = false; 1927 Context.animateTo({ 1928 duration: ENTER_EXIT_ICON_DURATION, 1929 curve: LONG_TOUCH_SCALE 1930 }, () => { 1931 this.longScaleOnePointTwo = 1; 1932 }); 1933 } 1934 }); 1935 }, Stack); 1936 this.observeComponentCreation2((f2, g2) => { 1937 If.create(); 1938 if (this.imageText) { 1939 this.ifElseBranchUpdateFunction(0, () => { 1940 this.ImageTextBuilder.bind(this)(y1, 'delete'); 1941 }); 1942 } 1943 else { 1944 this.ifElseBranchUpdateFunction(1, () => { 1945 this.TextBlockBuilder.bind(this)(y1); 1946 }); 1947 } 1948 }, If); 1949 If.pop(); 1950 Stack.pop(); 1951 GridItem.pop(); 1952 }; 1953 m17(); 1954 } 1955 }; 1956 this.forEachUpdateFunction(q1, this.selected, k17, (v1) => v1.id.toString(), true, false); 1957 }, ForEach); 1958 ForEach.pop(); 1959 Grid.pop(); 1960 Column.pop(); 1961 } 1962 insertItem(j1, k1) { 1963 if (!this.gridComState) { 1964 return; 1965 } 1966 this.vibrationDone = false; 1967 Context.animateTo({ 1968 duration: ENTER_EXIT_ICON_DURATION, 1969 curve: LONG_TOUCH_SCALE 1970 }, () => { 1971 this.longScaleOnePointTwo = 1; 1972 }); 1973 this.isStartDrag = false; 1974 if (k1 !== -1) { 1975 this.selected.splice(j1, 1); 1976 this.selected.splice(k1, 0, this.dragContent); 1977 } 1978 this.dragContent.visibility = Visibility.Visible; 1979 this.calcGridHeight(); 1980 } 1981 calcAreaInfo() { 1982 this.calcColNum(); 1983 this.blockWidth = this.getBlockWidth(); 1984 this.textItemEditWidth = this.gridComState ? this.blockWidth - 24 : this.blockWidth - 16; 1985 this.imageItemWidth = this.blockWidth - 16; 1986 this.calcTextItemEditHeight(); 1987 this.blockHeight = this.imageText ? this.imageItemWidth + EDIT_BLOCK_TEXT_ITEM_SAFE_MARGIN : this.gridComState ? 1988 this.textItemEditHeight + EDIT_BLOCK_TEXT_ITEM_SAFE_MARGIN : 1989 this.textItemEditHeight + DEFAULT_BLOCK_TEXT_ITEM_SAFE_MARGIN; 1990 this.calcGridHeight(); 1991 } 1992 initialRender() { 1993 this.observeComponentCreation2((h1, i1) => { 1994 Column.create(); 1995 Column.width('100%'); 1996 Column.height('90%'); 1997 }, Column); 1998 this.HeaderTitleBuilder.bind(this)(); 1999 this.observeComponentCreation2((f1, g1) => { 2000 Scroll.create(); 2001 }, Scroll); 2002 this.observeComponentCreation2((a1, b1) => { 2003 Column.create(); 2004 Column.onAreaChange((d1, e1) => { 2005 this.areaWidth = Number(e1.width); 2006 this.calcAreaInfo(); 2007 }); 2008 Column.width('100%'); 2009 }, Column); 2010 this.observeComponentCreation2((y, z) => { 2011 __Common__.create(); 2012 __Common__.margin({ bottom: MARGIN_EIGHT }); 2013 }, __Common__); 2014 { 2015 this.observeComponentCreation2((s, t) => { 2016 if (t) { 2017 let u = new SubHeader(this, { 2018 primaryTitle: '', 2019 secondaryTitle: this.options.showAreaTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_subtitle_sort'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 2020 icon: '', 2021 operationType: OperationType.BUTTON 2022 }, undefined, s, () => { }, { page: "librarys/gridobjectsortcomponent/src/main/ets/components/GridObjectSortComponent.ets", line: 1333, col: 11 }); 2023 ViewPU.create(u); 2024 let j17 = () => { 2025 return { 2026 primaryTitle: '', 2027 secondaryTitle: this.options.showAreaTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_subtitle_sort'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 2028 icon: '', 2029 operationType: OperationType.BUTTON 2030 }; 2031 }; 2032 u.paramsGenerator_ = j17; 2033 } 2034 else { 2035 this.updateStateVarsOfChildByElmtId(s, { 2036 primaryTitle: '', 2037 secondaryTitle: this.options.showAreaTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_subtitle_sort'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 2038 icon: '', 2039 operationType: OperationType.BUTTON 2040 }); 2041 } 2042 }, { name: "SubHeader" }); 2043 } 2044 __Common__.pop(); 2045 this.EditTagBuilder.bind(this)(); 2046 this.observeComponentCreation2((m, n) => { 2047 __Common__.create(); 2048 Context.animation({ 2049 duration: ENTER_EXIT_ICON_DURATION, 2050 curve: this.imageText ? REMOVE_ADD_SPRING : COMMON_BEZIER, 2051 }); 2052 __Common__.translate(this.clickRemoveBtn && this.selected.length % this.colNum === 1 ? { y: -this.blockHeight } : {}); 2053 Context.animation(null); 2054 __Common__.margin({ bottom: MARGIN_EIGHT }); 2055 __Common__.onAreaChange((p, q) => { 2056 this.subTitleHeight = Number(q.height); 2057 }); 2058 }, __Common__); 2059 { 2060 this.observeComponentCreation2((g, h) => { 2061 if (h) { 2062 let i = new SubHeader(this, { 2063 primaryTitle: '', 2064 secondaryTitle: this.options.addAreaTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_subtitle_add'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 2065 icon: '', 2066 operationType: OperationType.BUTTON 2067 }, undefined, g, () => { }, { page: "librarys/gridobjectsortcomponent/src/main/ets/components/GridObjectSortComponent.ets", line: 1342, col: 11 }); 2068 ViewPU.create(i); 2069 let i17 = () => { 2070 return { 2071 primaryTitle: '', 2072 secondaryTitle: this.options.addAreaTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_subtitle_add'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 2073 icon: '', 2074 operationType: OperationType.BUTTON 2075 }; 2076 }; 2077 i.paramsGenerator_ = i17; 2078 } 2079 else { 2080 this.updateStateVarsOfChildByElmtId(g, { 2081 primaryTitle: '', 2082 secondaryTitle: this.options.addAreaTitle || { "id": -1, "type": 10003, params: ['sys.string.ohos_grid_edit_subtitle_add'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 2083 icon: '', 2084 operationType: OperationType.BUTTON 2085 }); 2086 } 2087 }, { name: "SubHeader" }); 2088 } 2089 __Common__.pop(); 2090 this.AddTagBuilder.bind(this)(); 2091 Column.pop(); 2092 Scroll.pop(); 2093 Column.pop(); 2094 } 2095 rerender() { 2096 this.updateDirtyElements(); 2097 } 2098} 2099 2100export default { 2101 GridObjectSortComponent, GridObjectSortComponentType 2102}