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 16let deviceInfo = requireNapi('deviceInfo'); 17let inputMethod = requireNapi('inputMethod'); 18let inputMethodEngine = requireNapi('inputMethodEngine'); 19let settings = requireNapi('settings'); 20 21function __Divider__divider() { 22 Divider.height('1px'); 23 Divider.color('#10000000'); 24 Divider.margin({ left: 12, right: 12 }); 25} 26 27function __Text__textStyle() { 28 Text.width('100%'); 29 Text.fontWeight(400); 30 Text.maxLines(1); 31} 32 33const TAG = 'InputMethodListDialog'; 34const BIG_IMAGE_SIZE = 30; 35const NORMAL_IMAGE_SIZE = 24; 36const BIG_DIALOG_WIDTH = 196; 37const NORMAL_DIALOG_WIDTH = 156; 38const BIG_FONT_SIZE = 20; 39const NORMAL_FONT_SIZE = 16; 40const BIG_ITEM_HEIGHT = 60; 41const NORMAL_ITEM_HEIGHT = 48; 42const NORMAL_IMAGE_BUTTON_WIDTH = 40; 43const NORMAL_IMAGE_BUTTON_HEIGHT = 32; 44const BIG_IMAGE_BUTTON_WIDTH = 50; 45const BIG_IMAGE_BUTTON_HEIGHT = 40; 46const NORMAL_COLUMN_PADDING = 4; 47const BIG_COLUMN_PADDING = 5; 48const NORMAL_IMAGE_RADIUS = 8; 49const BIG_IMAGE_RADIUS = 10; 50const NORMAL_FONT_PADDING = 12; 51const BIG_FONT_PADDING = 20; 52const NORMAL_ITEM_RADIUS = 16; 53const BIG_ITEM_RADIUS = 12; 54 55export class InputMethodListDialog extends ViewPU { 56 constructor(a, b, c, d = -1, e = undefined, f) { 57 super(a, c, d, f); 58 if (typeof e === 'function') { 59 this.paramsGenerator_ = e; 60 } 61 this.listBgColor = '#ffffff'; 62 this.pressedColor = '#1A000000'; 63 this.selectedColor = '#220A59F7'; 64 this.fontColor = '#E6000000'; 65 this.selectedFontColor = '#0A59F7'; 66 this.__listItemHeight = new ObservedPropertySimplePU(NORMAL_ITEM_HEIGHT, this, 'listItemHeight'); 67 this.__listItemRadius = new ObservedPropertySimplePU(NORMAL_IMAGE_RADIUS, this, 'listItemRadius'); 68 this.__inputMethods = new ObservedPropertyObjectPU([], this, 'inputMethods'); 69 this.__fontSize = new ObservedPropertySimplePU(NORMAL_FONT_SIZE, this, 'fontSize'); 70 this.__fontPadding = new ObservedPropertySimplePU(NORMAL_FONT_PADDING, this, 'fontPadding'); 71 this.__dialogWidth = new ObservedPropertySimplePU(NORMAL_DIALOG_WIDTH, this, 'dialogWidth'); 72 this.__imageSize = new ObservedPropertySimplePU(NORMAL_IMAGE_SIZE, this, 'imageSize'); 73 this.__imageBtnWidth = new ObservedPropertySimplePU(NORMAL_IMAGE_BUTTON_WIDTH, this, 'imageBtnWidth'); 74 this.__imageBtnHeight = new ObservedPropertySimplePU(NORMAL_IMAGE_BUTTON_HEIGHT, this, 'imageBtnHeight'); 75 this.__columnPadding = new ObservedPropertySimplePU(NORMAL_COLUMN_PADDING, this, 'columnPadding'); 76 this.__imageRadius = new ObservedPropertySimplePU(NORMAL_IMAGE_RADIUS, this, 'imageRadius'); 77 this.__subTypes = new ObservedPropertyObjectPU([], this, 'subTypes'); 78 this.__showHand = new ObservedPropertySimplePU(false, this, 'showHand'); 79 this.__inputMethodConfig = new ObservedPropertyObjectPU(undefined, this, 'inputMethodConfig'); 80 this.__defaultInputMethod = new ObservedPropertyObjectPU(undefined, this, 'defaultInputMethod'); 81 this.__currentInputMethod = new ObservedPropertyObjectPU(undefined, this, 'currentInputMethod'); 82 this.__currentSub = new ObservedPropertyObjectPU(undefined, this, 'currentSub'); 83 this.__patternMode = this.createStorageLink('patternMode', 0, 'patternMode'); 84 this.__maxListNum = this.createStorageLink('maxListNum', 0, 'maxListNum'); 85 this.activeSubtypes = []; 86 this.controller = new CustomDialogController({ 87 builder: undefined 88 }, this); 89 this.patternOptions = undefined; 90 this.setInitiallyProvidedValue(b); 91 } 92 93 setInitiallyProvidedValue(g) { 94 if (g.listBgColor !== undefined) { 95 this.listBgColor = g.listBgColor; 96 } 97 if (g.pressedColor !== undefined) { 98 this.pressedColor = g.pressedColor; 99 } 100 if (g.selectedColor !== undefined) { 101 this.selectedColor = g.selectedColor; 102 } 103 if (g.fontColor !== undefined) { 104 this.fontColor = g.fontColor; 105 } 106 if (g.selectedFontColor !== undefined) { 107 this.selectedFontColor = g.selectedFontColor; 108 } 109 if (g.listItemHeight !== undefined) { 110 this.listItemHeight = g.listItemHeight; 111 } 112 if (g.listItemRadius !== undefined) { 113 this.listItemRadius = g.listItemRadius; 114 } 115 if (g.inputMethods !== undefined) { 116 this.inputMethods = g.inputMethods; 117 } 118 if (g.fontSize !== undefined) { 119 this.fontSize = g.fontSize; 120 } 121 if (g.fontPadding !== undefined) { 122 this.fontPadding = g.fontPadding; 123 } 124 if (g.dialogWidth !== undefined) { 125 this.dialogWidth = g.dialogWidth; 126 } 127 if (g.imageSize !== undefined) { 128 this.imageSize = g.imageSize; 129 } 130 if (g.imageBtnWidth !== undefined) { 131 this.imageBtnWidth = g.imageBtnWidth; 132 } 133 if (g.imageBtnHeight !== undefined) { 134 this.imageBtnHeight = g.imageBtnHeight; 135 } 136 if (g.columnPadding !== undefined) { 137 this.columnPadding = g.columnPadding; 138 } 139 if (g.imageRadius !== undefined) { 140 this.imageRadius = g.imageRadius; 141 } 142 if (g.subTypes !== undefined) { 143 this.subTypes = g.subTypes; 144 } 145 if (g.showHand !== undefined) { 146 this.showHand = g.showHand; 147 } 148 if (g.inputMethodConfig !== undefined) { 149 this.inputMethodConfig = g.inputMethodConfig; 150 } 151 if (g.defaultInputMethod !== undefined) { 152 this.defaultInputMethod = g.defaultInputMethod; 153 } 154 if (g.currentInputMethod !== undefined) { 155 this.currentInputMethod = g.currentInputMethod; 156 } 157 if (g.currentSub !== undefined) { 158 this.currentSub = g.currentSub; 159 } 160 if (g.activeSubtypes !== undefined) { 161 this.activeSubtypes = g.activeSubtypes; 162 } 163 if (g.controller !== undefined) { 164 this.controller = g.controller; 165 } 166 if (g.patternOptions !== undefined) { 167 this.patternOptions = g.patternOptions; 168 } 169 } 170 171 updateStateVars(h) { 172 } 173 174 purgeVariableDependenciesOnElmtId(i) { 175 this.__listItemHeight.purgeDependencyOnElmtId(i); 176 this.__listItemRadius.purgeDependencyOnElmtId(i); 177 this.__inputMethods.purgeDependencyOnElmtId(i); 178 this.__fontSize.purgeDependencyOnElmtId(i); 179 this.__fontPadding.purgeDependencyOnElmtId(i); 180 this.__dialogWidth.purgeDependencyOnElmtId(i); 181 this.__imageSize.purgeDependencyOnElmtId(i); 182 this.__imageBtnWidth.purgeDependencyOnElmtId(i); 183 this.__imageBtnHeight.purgeDependencyOnElmtId(i); 184 this.__columnPadding.purgeDependencyOnElmtId(i); 185 this.__imageRadius.purgeDependencyOnElmtId(i); 186 this.__subTypes.purgeDependencyOnElmtId(i); 187 this.__showHand.purgeDependencyOnElmtId(i); 188 this.__inputMethodConfig.purgeDependencyOnElmtId(i); 189 this.__defaultInputMethod.purgeDependencyOnElmtId(i); 190 this.__currentInputMethod.purgeDependencyOnElmtId(i); 191 this.__currentSub.purgeDependencyOnElmtId(i); 192 this.__patternMode.purgeDependencyOnElmtId(i); 193 this.__maxListNum.purgeDependencyOnElmtId(i); 194 } 195 196 aboutToBeDeleted() { 197 this.__listItemHeight.aboutToBeDeleted(); 198 this.__listItemRadius.aboutToBeDeleted(); 199 this.__inputMethods.aboutToBeDeleted(); 200 this.__fontSize.aboutToBeDeleted(); 201 this.__fontPadding.aboutToBeDeleted(); 202 this.__dialogWidth.aboutToBeDeleted(); 203 this.__imageSize.aboutToBeDeleted(); 204 this.__imageBtnWidth.aboutToBeDeleted(); 205 this.__imageBtnHeight.aboutToBeDeleted(); 206 this.__columnPadding.aboutToBeDeleted(); 207 this.__imageRadius.aboutToBeDeleted(); 208 this.__subTypes.aboutToBeDeleted(); 209 this.__showHand.aboutToBeDeleted(); 210 this.__inputMethodConfig.aboutToBeDeleted(); 211 this.__defaultInputMethod.aboutToBeDeleted(); 212 this.__currentInputMethod.aboutToBeDeleted(); 213 this.__currentSub.aboutToBeDeleted(); 214 this.__patternMode.aboutToBeDeleted(); 215 this.__maxListNum.aboutToBeDeleted(); 216 SubscriberManager.Get().delete(this.id__()); 217 this.aboutToBeDeletedInternal(); 218 } 219 220 get listItemHeight() { 221 return this.__listItemHeight.get(); 222 } 223 224 set listItemHeight(j) { 225 this.__listItemHeight.set(j); 226 } 227 228 get listItemRadius() { 229 return this.__listItemRadius.get(); 230 } 231 232 set listItemRadius(k) { 233 this.__listItemRadius.set(k); 234 } 235 236 get inputMethods() { 237 return this.__inputMethods.get(); 238 } 239 240 set inputMethods(l) { 241 this.__inputMethods.set(l); 242 } 243 244 get fontSize() { 245 return this.__fontSize.get(); 246 } 247 248 set fontSize(m) { 249 this.__fontSize.set(m); 250 } 251 252 get fontPadding() { 253 return this.__fontPadding.get(); 254 } 255 256 set fontPadding(n) { 257 this.__fontPadding.set(n); 258 } 259 260 get dialogWidth() { 261 return this.__dialogWidth.get(); 262 } 263 264 set dialogWidth(o) { 265 this.__dialogWidth.set(o); 266 } 267 268 get imageSize() { 269 return this.__imageSize.get(); 270 } 271 272 set imageSize(p) { 273 this.__imageSize.set(p); 274 } 275 276 get imageBtnWidth() { 277 return this.__imageBtnWidth.get(); 278 } 279 280 set imageBtnWidth(q) { 281 this.__imageBtnWidth.set(q); 282 } 283 284 get imageBtnHeight() { 285 return this.__imageBtnHeight.get(); 286 } 287 288 set imageBtnHeight(r) { 289 this.__imageBtnHeight.set(r); 290 } 291 292 get columnPadding() { 293 return this.__columnPadding.get(); 294 } 295 296 set columnPadding(s) { 297 this.__columnPadding.set(s); 298 } 299 300 get imageRadius() { 301 return this.__imageRadius.get(); 302 } 303 304 set imageRadius(t) { 305 this.__imageRadius.set(t); 306 } 307 308 get subTypes() { 309 return this.__subTypes.get(); 310 } 311 312 set subTypes(u) { 313 this.__subTypes.set(u); 314 } 315 316 get showHand() { 317 return this.__showHand.get(); 318 } 319 320 set showHand(v) { 321 this.__showHand.set(v); 322 } 323 324 get inputMethodConfig() { 325 return this.__inputMethodConfig.get(); 326 } 327 328 set inputMethodConfig(w) { 329 this.__inputMethodConfig.set(w); 330 } 331 332 get defaultInputMethod() { 333 return this.__defaultInputMethod.get(); 334 } 335 336 set defaultInputMethod(x) { 337 this.__defaultInputMethod.set(x); 338 } 339 340 get currentInputMethod() { 341 return this.__currentInputMethod.get(); 342 } 343 344 set currentInputMethod(y) { 345 this.__currentInputMethod.set(y); 346 } 347 348 get currentSub() { 349 return this.__currentSub.get(); 350 } 351 352 set currentSub(z) { 353 this.__currentSub.set(z); 354 } 355 356 get patternMode() { 357 return this.__patternMode.get(); 358 } 359 360 set patternMode(a1) { 361 this.__patternMode.set(a1); 362 } 363 364 get maxListNum() { 365 return this.__maxListNum.get(); 366 } 367 368 set maxListNum(b1) { 369 this.__maxListNum.set(b1); 370 } 371 372 setController(c1) { 373 this.controller = c1; 374 } 375 376 async getDefaultInputMethodSubType() { 377 console.info(`${TAG} getDefaultInputMethodSubType`); 378 this.inputMethodConfig = inputMethod.getSystemInputMethodConfigAbility(); 379 if (this.inputMethodConfig) { 380 console.info(`${TAG} inputMethodConfig: ${JSON.stringify(this.inputMethodConfig)}`); 381 } 382 this.inputMethods = await inputMethod.getSetting().getInputMethods(true); 383 this.defaultInputMethod = inputMethod.getDefaultInputMethod(); 384 this.currentInputMethod = inputMethod.getCurrentInputMethod(); 385 let d1 = 0; 386 for (let f1 = 0; f1 < this.inputMethods.length; f1++) { 387 if (this.inputMethods[f1].name === this.defaultInputMethod.name) { 388 d1 = f1; 389 break; 390 } 391 } 392 this.inputMethods.splice(d1, 1); 393 this.inputMethods.unshift(this.defaultInputMethod); 394 this.currentSub = inputMethod.getCurrentInputMethodSubtype(); 395 console.info(`${TAG} defaultInput: ${JSON.stringify(this.defaultInputMethod)}`); 396 if (this.defaultInputMethod.name === this.currentInputMethod.name) { 397 if (this.patternOptions) { 398 if (AppStorage.get('patternMode') === undefined) { 399 if (this.patternOptions.defaultSelected) { 400 this.patternMode = this.patternOptions.defaultSelected; 401 } else { 402 this.patternMode = 0; 403 } 404 AppStorage.setOrCreate('patternMode', this.patternMode); 405 } else { 406 this.patternMode = AppStorage.get('patternMode'); 407 } 408 this.showHand = true; 409 } 410 } 411 let e1 = getContext(this); 412 try { 413 let g1 = await settings.getValue(e1, settings.input.ACTIVATED_INPUT_METHOD_SUB_MODE); 414 let h1 = JSON.parse(g1); 415 if (h1) { 416 console.info(`${TAG} activeSubType: ${JSON.stringify(h1)}`); 417 for (let i1 = 0; i1 < this.inputMethods.length; i1++) { 418 if (this.inputMethods[i1].name === this.defaultInputMethod.name) { 419 this.defaultInputMethod = this.inputMethods[i1]; 420 let j1 = await inputMethod.getSetting().listInputMethodSubtype(this.inputMethods[i1]); 421 console.info(`${TAG} defaultSubTypes: ${JSON.stringify(j1)}`); 422 for (let k1 = 0; k1 < j1.length; k1++) { 423 for (let l1 = 0; l1 < h1.length; l1++) { 424 if (h1[l1].id === j1[k1].id) { 425 this.subTypes.push(j1[k1]); 426 this.activeSubtypes.push(h1[l1]); 427 } 428 } 429 } 430 } 431 } 432 console.info(`${TAG} this.subTypes: ${JSON.stringify(this.subTypes)}`); 433 console.info(`${TAG} this.activeSubtypes: ${JSON.stringify(this.activeSubtypes)}`); 434 } 435 } catch (m1) { 436 this.subTypes = []; 437 console.info(`${TAG} subTypes is empty, err = ${JSON.stringify(m1)}`); 438 } 439 } 440 441 async aboutToAppear() { 442 console.info(`${TAG} aboutToAppear`); 443 this.dialogWidth = NORMAL_DIALOG_WIDTH; 444 this.fontSize = NORMAL_FONT_SIZE; 445 this.imageSize = NORMAL_IMAGE_SIZE; 446 this.listItemHeight = NORMAL_ITEM_HEIGHT; 447 this.imageBtnWidth = NORMAL_IMAGE_BUTTON_WIDTH; 448 this.imageBtnHeight = NORMAL_IMAGE_BUTTON_HEIGHT; 449 this.columnPadding = NORMAL_COLUMN_PADDING; 450 this.fontPadding = NORMAL_FONT_PADDING; 451 this.listItemRadius = NORMAL_ITEM_RADIUS; 452 this.imageRadius = BIG_IMAGE_RADIUS; 453 await this.getDefaultInputMethodSubType(); 454 let n1 = inputMethodEngine.getInputMethodAbility(); 455 n1.on('keyboardHide', () => { 456 this.controller.close(); 457 }); 458 } 459 460 isDefaultInputMethodCurrentSubType(p1) { 461 var q1; 462 var r1; 463 var s1; 464 return ((q1 = this.defaultInputMethod) === null || q1 === void 0 ? void 0 : q1.name) === 465 ((r1 = this.currentInputMethod) === null || r1 === void 0 ? void 0 : r1.name) && 466 ((s1 = this.currentSub) === null || s1 === void 0 ? void 0 : s1.id) === p1; 467 } 468 469 InputMethodItem(t1, u1, v1, w1, x1, y1, z1 = null) { 470 this.observeComponentCreation2((b2, c2) => { 471 Column.create(); 472 Column.width('100%'); 473 Column.onClick(() => { 474 y1(); 475 }); 476 }, Column); 477 this.observeComponentCreation2((e2, f2) => { 478 Text.create(t1); 479 Text.fontSize(this.fontSize); 480 __Text__textStyle(); 481 Text.padding({ left: this.fontPadding, right: this.fontPadding }); 482 Text.height(this.listItemHeight); 483 Text.borderRadius(this.listItemRadius); 484 Text.fontColor(u1); 485 ViewStackProcessor.visualState('pressed'); 486 Text.backgroundColor(w1); 487 ViewStackProcessor.visualState('normal'); 488 Text.backgroundColor(v1); 489 ViewStackProcessor.visualState(); 490 }, Text); 491 Text.pop(); 492 this.observeComponentCreation2((g2, h2) => { 493 If.create(); 494 if (x1) { 495 this.ifElseBranchUpdateFunction(0, () => { 496 this.observeComponentCreation2((k2, l2) => { 497 Divider.create(); 498 __Divider__divider(); 499 }, Divider); 500 }); 501 } else { 502 this.ifElseBranchUpdateFunction(1, () => { 503 }); 504 } 505 }, If); 506 If.pop(); 507 Column.pop(); 508 } 509 510 initialRender() { 511 this.observeComponentCreation2((o2, p2) => { 512 Column.create(); 513 Column.width(this.dialogWidth); 514 Column.margin({ top: this.columnPadding }); 515 Column.borderRadius('16vp'); 516 Column.backgroundColor(this.listBgColor); 517 Column.padding(this.columnPadding); 518 Column.shadow(ShadowStyle.OUTER_DEFAULT_SM); 519 }, Column); 520 this.observeComponentCreation2((q2, r2) => { 521 If.create(); 522 if (this.inputMethodConfig && this.inputMethodConfig.bundleName.length > 0) { 523 this.ifElseBranchUpdateFunction(0, () => { 524 this.observeComponentCreation2((u2, v2) => { 525 Text.create({ 526 'id': -1, 527 'type': 10003, 528 params: ['sys.string.ohos_id_input_method_settings'], 529 'bundleName': '', 530 'moduleName': '' 531 }); 532 __Text__textStyle(); 533 Text.padding({ left: this.fontPadding, right: this.fontPadding }); 534 Text.height(this.listItemHeight); 535 Text.borderRadius(this.listItemRadius); 536 Text.fontSize(this.fontSize); 537 Text.fontColor(this.fontColor); 538 ViewStackProcessor.visualState('pressed'); 539 Text.backgroundColor(this.pressedColor); 540 ViewStackProcessor.visualState('normal'); 541 Text.backgroundColor(this.listBgColor); 542 ViewStackProcessor.visualState(); 543 Text.onClick(() => { 544 if (this.inputMethodConfig) { 545 let x2 = getContext(this); 546 x2.startAbility({ 547 bundleName: this.inputMethodConfig.bundleName, 548 moduleName: this.inputMethodConfig.moduleName, 549 abilityName: this.inputMethodConfig.abilityName, 550 uri: 'set_input' 551 }); 552 } 553 }); 554 }, Text); 555 Text.pop(); 556 this.observeComponentCreation2((y2, z2) => { 557 Divider.create(); 558 __Divider__divider(); 559 }, Divider); 560 }); 561 } else { 562 this.ifElseBranchUpdateFunction(1, () => { 563 }); 564 } 565 }, If); 566 If.pop(); 567 this.observeComponentCreation2((b3, c3) => { 568 Scroll.create(); 569 Scroll.width('100%'); 570 Scroll.constraintSize({ maxHeight: this.maxListNum > 0 ? this.maxListNum * this.listItemHeight : '100%' }); 571 Scroll.scrollBar(BarState.Off); 572 }, Scroll); 573 this.observeComponentCreation2((d3, e3) => { 574 Column.create(); 575 Column.width('100%'); 576 }, Column); 577 this.observeComponentCreation2((f3, g3) => { 578 ForEach.create(); 579 const h3 = (j3, k3) => { 580 const l3 = j3; 581 this.InputMethodItem.bind(this)(this.activeSubtypes[k3].name, 582 this.isDefaultInputMethodCurrentSubType(l3.id) ? this.selectedFontColor : this.fontColor, 583 this.isDefaultInputMethodCurrentSubType(l3.id) ? this.selectedColor : this.listBgColor, 584 this.pressedColor, 585 this.inputMethods.length > 1 || k3 < this.subTypes.length, 586 () => { 587 this.switchMethodSub(l3); 588 }); 589 }; 590 this.forEachUpdateFunction(f3, this.subTypes, h3, (n3) => JSON.stringify(n3), true, false); 591 }, ForEach); 592 ForEach.pop(); 593 this.observeComponentCreation2((o3, p3) => { 594 ForEach.create(); 595 const q3 = (s3, t3) => { 596 const u3 = s3; 597 this.observeComponentCreation2((w3, x3) => { 598 If.create(); 599 if (this.subTypes.length === 0 || (this.defaultInputMethod && u3.name !== this.defaultInputMethod.name)) { 600 this.ifElseBranchUpdateFunction(0, () => { 601 var z3; 602 var a4; 603 this.InputMethodItem.bind(this)(this.inputMethods[t3].label, 604 ((z3 = this.currentInputMethod) === null || z3 === void 0 ? void 0 : z3.name) === u3.name ? 605 this.selectedFontColor : this.fontColor, 606 ((a4 = this.currentInputMethod) === null || a4 === void 0 ? void 0 : a4.name) === u3.name ? 607 this.selectedColor : this.listBgColor, 608 this.pressedColor, 609 t3 < this.inputMethods.length - 1, 610 () => { 611 this.switchMethod(u3); 612 }); 613 }); 614 } else { 615 this.ifElseBranchUpdateFunction(1, () => { 616 }); 617 } 618 }, If); 619 If.pop(); 620 }; 621 this.forEachUpdateFunction(o3, this.inputMethods, q3, (d4) => JSON.stringify(d4), true, false); 622 }, ForEach); 623 ForEach.pop(); 624 Column.pop(); 625 Scroll.pop(); 626 this.observeComponentCreation2((e4, f4) => { 627 If.create(); 628 if (this.patternOptions && this.showHand) { 629 this.ifElseBranchUpdateFunction(0, () => { 630 this.observeComponentCreation2((i4, j4) => { 631 Divider.create(); 632 __Divider__divider(); 633 }, Divider); 634 this.observeComponentCreation2((k4, l4) => { 635 Row.create(); 636 Row.width('100%'); 637 Row.height(this.listItemHeight); 638 Row.justifyContent(FlexAlign.SpaceEvenly); 639 }, Row); 640 this.observeComponentCreation2((m4, n4) => { 641 ForEach.create(); 642 const o4 = (q4, r4) => { 643 const s4 = q4; 644 this.observeComponentCreation2((u4, v4) => { 645 Row.create(); 646 Row.justifyContent(FlexAlign.Center); 647 Row.size({ width: this.imageBtnWidth, height: this.imageBtnHeight }); 648 Row.borderRadius(this.imageRadius); 649 ViewStackProcessor.visualState('pressed'); 650 Row.backgroundColor(this.pressedColor); 651 ViewStackProcessor.visualState('normal'); 652 Row.backgroundColor(this.listBgColor); 653 ViewStackProcessor.visualState(); 654 Row.onClick(() => { 655 this.switchPositionPattern(r4); 656 }); 657 }, Row); 658 this.observeComponentCreation2((x4, y4) => { 659 Image.create(r4 === this.patternMode ? s4.selectedIcon : s4.icon); 660 Image.size({ width: this.imageSize, height: this.imageSize }); 661 Image.objectFit(ImageFit.Contain); 662 }, Image); 663 Row.pop(); 664 }; 665 this.forEachUpdateFunction(m4, this.patternOptions.patterns, o4, (z4) => JSON.stringify(z4), true, false); 666 }, ForEach); 667 ForEach.pop(); 668 Row.pop(); 669 }); 670 } else { 671 this.ifElseBranchUpdateFunction(1, () => { 672 }); 673 } 674 }, If); 675 If.pop(); 676 Column.pop(); 677 } 678 679 switchPositionPattern(b5) { 680 if (this.patternOptions) { 681 this.patternMode = b5; 682 AppStorage.set('patternMode', this.patternMode); 683 console.info(`${TAG} this.handMode = ${this.patternMode}`); 684 this.patternOptions.action(this.patternMode); 685 this.controller.close(); 686 } 687 } 688 689 async switchMethod(c5) { 690 if (this.currentInputMethod && this.currentInputMethod.name !== c5.name) { 691 let d5 = await inputMethod.getSetting().listInputMethodSubtype(c5); 692 inputMethod.switchCurrentInputMethodAndSubtype(c5, d5[0], (f5, g5) => { 693 if (g5) { 694 this.currentInputMethod = c5; 695 } 696 this.controller.close(); 697 }); 698 } 699 } 700 701 switchMethodSub(h5) { 702 if (this.currentInputMethod && this.defaultInputMethod) { 703 if (this.currentInputMethod.name !== this.defaultInputMethod.name) { 704 inputMethod.switchCurrentInputMethodAndSubtype(this.defaultInputMethod, h5, () => { 705 this.currentInputMethod = this.defaultInputMethod; 706 this.currentSub = h5; 707 this.controller.close(); 708 }); 709 } else { 710 inputMethod.switchCurrentInputMethodSubtype(h5, () => { 711 this.currentSub = h5; 712 this.controller.close(); 713 }); 714 } 715 } 716 } 717 718 rerender() { 719 this.updateDirtyElements(); 720 } 721} 722 723export default { 724 InputMethodListDialog 725};