1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16let componentUtils = requireNapi('arkui.componentUtils'); 17let display = requireNapi('display'); 18let inputMethod = requireNapi('inputMethod'); 19let inputMethodEngine = requireNapi('inputMethodEngine'); 20let settings = requireNapi('settings'); 21 22function __Divider__divider() { 23 Divider.height('1px'); 24 Divider.color('#10000000'); 25 Divider.margin({ left: 12, right: 12 }); 26} 27 28function __Text__textStyle() { 29 Text.width('100%'); 30 Text.fontWeight(400); 31 Text.maxLines(1); 32} 33 34const TAG = 'InputMethodListDialog'; 35const BIG_IMAGE_SIZE = 30; 36const NORMAL_IMAGE_SIZE = 24; 37const SCREEN_SIZE = 1920; 38const BIG_SCREEN_DPI = 1280; 39const NORMAL_SCREEN_DPI = 360; 40const BIG_DIALOG_WIDTH = 196; 41const NORMAL_DIALOG_WIDTH = 156; 42const BIG_FONT_SIZE = 20; 43const NORMAL_FONT_SIZE = 16; 44const BIG_ITEM_HEIGHT = 60; 45const NORMAL_ITEM_HEIGHT = 48; 46const NORMAL_IMAGE_BUTTON_WIDTH = 40; 47const NORMAL_IMAGE_BUTTON_HEIGHT = 32; 48const BIG_IMAGE_BUTTON_WIDTH = 50; 49const BIG_IMAGE_BUTTON_HEIGHT = 40; 50const NORMAL_COLUMN_PADDING = 4; 51const BIG_COLUMN_PADDING = 5; 52const NORMAL_IMAGE_RADIUS = 8; 53const BIG_IMAGE_RADIUS = 10; 54const NORMAL_FONT_PADDING = 12; 55const BIG_FONT_PADDING = 20; 56const NORMAL_ITEM_RADIUS = 16; 57const BIG_ITEM_RADIUS = 12; 58 59export class InputMethodListDialog extends ViewPU { 60 constructor(t, e, i, o = -1, n = void 0) { 61 super(t, i, o); 62 'function' === typeof n && (this.paramsGenerator_ = n); 63 this.borderBgColor = '#00ffffff'; 64 this.listBgColor = '#ffffff'; 65 this.pressedColor = '#1A000000'; 66 this.selectedColor = '#220A59F7'; 67 this.fontColor = '#E6000000'; 68 this.selectedFontColor = '#0A59F7'; 69 this.__listItemHeight = new ObservedPropertySimplePU(48, this, 'listItemHeight'); 70 this.__listItemRadius = new ObservedPropertySimplePU(8, this, 'listItemRadius'); 71 this.__inputMethods = new ObservedPropertyObjectPU([], this, 'inputMethods'); 72 this.__fontSize = new ObservedPropertySimplePU(16, this, 'fontSize'); 73 this.__fontPadding = new ObservedPropertySimplePU(12, this, 'fontPadding'); 74 this.__dialogWidth = new ObservedPropertySimplePU(156, this, 'dialogWidth'); 75 this.__imageSize = new ObservedPropertySimplePU(24, this, 'imageSize'); 76 this.__imageBtnWidth = new ObservedPropertySimplePU(40, this, 'imageBtnWidth'); 77 this.__imageBtnHeight = new ObservedPropertySimplePU(32, this, 'imageBtnHeight'); 78 this.__columnPadding = new ObservedPropertySimplePU(4, this, 'columnPadding'); 79 this.__imageRadius = new ObservedPropertySimplePU(8, this, 'imageRadius'); 80 this.__subTypes = new ObservedPropertyObjectPU([], this, 'subTypes'); 81 this.__showHand = new ObservedPropertySimplePU(!1, this, 'showHand'); 82 this.__inputMethodConfig = new ObservedPropertyObjectPU(void 0, this, 'inputMethodConfig'); 83 this.__maxHeight = new ObservedPropertySimplePU(1, this, 'maxHeight'); 84 this.__defaultInputMethod = new ObservedPropertyObjectPU(void 0, this, 'defaultInputMethod'); 85 this.__currentInputMethod = new ObservedPropertyObjectPU(void 0, this, 'currentInputMethod'); 86 this.__currentSub = new ObservedPropertyObjectPU(void 0, this, 'currentSub'); 87 this.__viewOpacity = new ObservedPropertySimplePU(0, this, 'viewOpacity'); 88 this.__patternMode = this.createStorageLink('patternMode', 0, 'patternMode'); 89 this.controller = new CustomDialogController({ builder: void 0 }, this); 90 this.patternOptions = void 0; 91 this.setInitiallyProvidedValue(e); 92 } 93 94 setInitiallyProvidedValue(t) { 95 void 0 !== t.borderBgColor && (this.borderBgColor = t.borderBgColor); 96 void 0 !== t.listBgColor && (this.listBgColor = t.listBgColor); 97 void 0 !== t.pressedColor && (this.pressedColor = t.pressedColor); 98 void 0 !== t.selectedColor && (this.selectedColor = t.selectedColor); 99 void 0 !== t.fontColor && (this.fontColor = t.fontColor); 100 void 0 !== t.selectedFontColor && (this.selectedFontColor = t.selectedFontColor); 101 void 0 !== t.listItemHeight && (this.listItemHeight = t.listItemHeight); 102 void 0 !== t.listItemRadius && (this.listItemRadius = t.listItemRadius); 103 void 0 !== t.inputMethods && (this.inputMethods = t.inputMethods); 104 void 0 !== t.fontSize && (this.fontSize = t.fontSize); 105 void 0 !== t.fontPadding && (this.fontPadding = t.fontPadding); 106 void 0 !== t.dialogWidth && (this.dialogWidth = t.dialogWidth); 107 void 0 !== t.imageSize && (this.imageSize = t.imageSize); 108 void 0 !== t.imageBtnWidth && (this.imageBtnWidth = t.imageBtnWidth); 109 void 0 !== t.imageBtnHeight && (this.imageBtnHeight = t.imageBtnHeight); 110 void 0 !== t.columnPadding && (this.columnPadding = t.columnPadding); 111 void 0 !== t.imageRadius && (this.imageRadius = t.imageRadius); 112 void 0 !== t.subTypes && (this.subTypes = t.subTypes); 113 void 0 !== t.showHand && (this.showHand = t.showHand); 114 void 0 !== t.inputMethodConfig && (this.inputMethodConfig = t.inputMethodConfig); 115 void 0 !== t.maxHeight && (this.maxHeight = t.maxHeight); 116 void 0 !== t.defaultInputMethod && (this.defaultInputMethod = t.defaultInputMethod); 117 void 0 !== t.currentInputMethod && (this.currentInputMethod = t.currentInputMethod); 118 void 0 !== t.currentSub && (this.currentSub = t.currentSub); 119 void 0 !== t.viewOpacity && (this.viewOpacity = t.viewOpacity); 120 void 0 !== t.controller && (this.controller = t.controller); 121 void 0 !== t.patternOptions && (this.patternOptions = t.patternOptions); 122 } 123 124 updateStateVars(t) { 125 } 126 127 purgeVariableDependenciesOnElmtId(t) { 128 this.__listItemHeight.purgeDependencyOnElmtId(t); 129 this.__listItemRadius.purgeDependencyOnElmtId(t); 130 this.__inputMethods.purgeDependencyOnElmtId(t); 131 this.__fontSize.purgeDependencyOnElmtId(t); 132 this.__fontPadding.purgeDependencyOnElmtId(t); 133 this.__dialogWidth.purgeDependencyOnElmtId(t); 134 this.__imageSize.purgeDependencyOnElmtId(t); 135 this.__imageBtnWidth.purgeDependencyOnElmtId(t); 136 this.__imageBtnHeight.purgeDependencyOnElmtId(t); 137 this.__columnPadding.purgeDependencyOnElmtId(t); 138 this.__imageRadius.purgeDependencyOnElmtId(t); 139 this.__subTypes.purgeDependencyOnElmtId(t); 140 this.__showHand.purgeDependencyOnElmtId(t); 141 this.__inputMethodConfig.purgeDependencyOnElmtId(t); 142 this.__maxHeight.purgeDependencyOnElmtId(t); 143 this.__defaultInputMethod.purgeDependencyOnElmtId(t); 144 this.__currentInputMethod.purgeDependencyOnElmtId(t); 145 this.__currentSub.purgeDependencyOnElmtId(t); 146 this.__viewOpacity.purgeDependencyOnElmtId(t); 147 this.__patternMode.purgeDependencyOnElmtId(t); 148 } 149 150 aboutToBeDeleted() { 151 this.__listItemHeight.aboutToBeDeleted(); 152 this.__listItemRadius.aboutToBeDeleted(); 153 this.__inputMethods.aboutToBeDeleted(); 154 this.__fontSize.aboutToBeDeleted(); 155 this.__fontPadding.aboutToBeDeleted(); 156 this.__dialogWidth.aboutToBeDeleted(); 157 this.__imageSize.aboutToBeDeleted(); 158 this.__imageBtnWidth.aboutToBeDeleted(); 159 this.__imageBtnHeight.aboutToBeDeleted(); 160 this.__columnPadding.aboutToBeDeleted(); 161 this.__imageRadius.aboutToBeDeleted(); 162 this.__subTypes.aboutToBeDeleted(); 163 this.__showHand.aboutToBeDeleted(); 164 this.__inputMethodConfig.aboutToBeDeleted(); 165 this.__maxHeight.aboutToBeDeleted(); 166 this.__defaultInputMethod.aboutToBeDeleted(); 167 this.__currentInputMethod.aboutToBeDeleted(); 168 this.__currentSub.aboutToBeDeleted(); 169 this.__viewOpacity.aboutToBeDeleted(); 170 this.__patternMode.aboutToBeDeleted(); 171 SubscriberManager.Get().delete(this.id__()); 172 this.aboutToBeDeletedInternal(); 173 } 174 175 get listItemHeight() { 176 return this.__listItemHeight.get(); 177 } 178 179 set listItemHeight(t) { 180 this.__listItemHeight.set(t); 181 } 182 183 get listItemRadius() { 184 return this.__listItemRadius.get(); 185 } 186 187 set listItemRadius(t) { 188 this.__listItemRadius.set(t); 189 } 190 191 get inputMethods() { 192 return this.__inputMethods.get(); 193 } 194 195 set inputMethods(t) { 196 this.__inputMethods.set(t); 197 } 198 199 get fontSize() { 200 return this.__fontSize.get(); 201 } 202 203 set fontSize(t) { 204 this.__fontSize.set(t); 205 } 206 207 get fontPadding() { 208 return this.__fontPadding.get(); 209 } 210 211 set fontPadding(t) { 212 this.__fontPadding.set(t); 213 } 214 215 get dialogWidth() { 216 return this.__dialogWidth.get(); 217 } 218 219 set dialogWidth(t) { 220 this.__dialogWidth.set(t); 221 } 222 223 get imageSize() { 224 return this.__imageSize.get(); 225 } 226 227 set imageSize(t) { 228 this.__imageSize.set(t); 229 } 230 231 get imageBtnWidth() { 232 return this.__imageBtnWidth.get(); 233 } 234 235 set imageBtnWidth(t) { 236 this.__imageBtnWidth.set(t); 237 } 238 239 get imageBtnHeight() { 240 return this.__imageBtnHeight.get(); 241 } 242 243 set imageBtnHeight(t) { 244 this.__imageBtnHeight.set(t); 245 } 246 247 get columnPadding() { 248 return this.__columnPadding.get(); 249 } 250 251 set columnPadding(t) { 252 this.__columnPadding.set(t); 253 } 254 255 get imageRadius() { 256 return this.__imageRadius.get(); 257 } 258 259 set imageRadius(t) { 260 this.__imageRadius.set(t); 261 } 262 263 get subTypes() { 264 return this.__subTypes.get(); 265 } 266 267 set subTypes(t) { 268 this.__subTypes.set(t); 269 } 270 271 get showHand() { 272 return this.__showHand.get(); 273 } 274 275 set showHand(t) { 276 this.__showHand.set(t); 277 } 278 279 get inputMethodConfig() { 280 return this.__inputMethodConfig.get(); 281 } 282 283 set inputMethodConfig(t) { 284 this.__inputMethodConfig.set(t); 285 } 286 287 get maxHeight() { 288 return this.__maxHeight.get(); 289 } 290 291 set maxHeight(t) { 292 this.__maxHeight.set(t); 293 } 294 295 get defaultInputMethod() { 296 return this.__defaultInputMethod.get(); 297 } 298 299 set defaultInputMethod(t) { 300 this.__defaultInputMethod.set(t); 301 } 302 303 get currentInputMethod() { 304 return this.__currentInputMethod.get(); 305 } 306 307 set currentInputMethod(t) { 308 this.__currentInputMethod.set(t); 309 } 310 311 get currentSub() { 312 return this.__currentSub.get(); 313 } 314 315 set currentSub(t) { 316 this.__currentSub.set(t); 317 } 318 319 get viewOpacity() { 320 return this.__viewOpacity.get(); 321 } 322 323 set viewOpacity(t) { 324 this.__viewOpacity.set(t); 325 } 326 327 get patternMode() { 328 return this.__patternMode.get(); 329 } 330 331 set patternMode(t) { 332 this.__patternMode.set(t); 333 } 334 335 setController(t) { 336 this.controller = t; 337 } 338 339 async getDefaultInputMethodSubType() { 340 console.info(`${TAG} getDefaultInputMethodSubType`); 341 this.inputMethodConfig = inputMethod.getSystemInputMethodConfigAbility(); 342 this.inputMethodConfig && console.info(`${TAG} inputMethodConfig: ${JSON.stringify(this.inputMethodConfig)}`); 343 this.inputMethods = await inputMethod.getSetting().getInputMethods(!0); 344 this.defaultInputMethod = inputMethod.getDefaultInputMethod(); 345 this.currentInputMethod = inputMethod.getCurrentInputMethod(); 346 let t = 0; 347 for (let e = 0; e < this.inputMethods.length; e++) { 348 if (this.inputMethods[e].name === this.defaultInputMethod.name) { 349 t = e; 350 break; 351 } 352 } 353 this.inputMethods.splice(t, 1); 354 this.inputMethods.unshift(this.defaultInputMethod); 355 this.currentSub = inputMethod.getCurrentInputMethodSubtype(); 356 console.info(`${TAG} defaultInput: ${JSON.stringify(this.defaultInputMethod)}`); 357 if (this.defaultInputMethod.name === this.currentInputMethod.name && this.patternOptions) { 358 if (void 0 === AppStorage.get('patternMode')) { 359 this.patternOptions.defaultSelected ? this.patternMode = this.patternOptions.defaultSelected : 360 this.patternMode = 0; 361 AppStorage.setOrCreate('patternMode', this.patternMode); 362 } else { 363 this.patternMode = AppStorage.get('patternMode'); 364 } 365 this.showHand = !0; 366 } 367 let e = await inputMethod.getSetting().listInputMethodSubtype(this.defaultInputMethod); 368 console.info(`${TAG} defaultSubTypes: ${JSON.stringify(e)}`); 369 let i = getContext(this); 370 try { 371 let t = await settings.getValue(i, settings.input.ACTIVATED_INPUT_METHOD_SUB_MODE); 372 if (t) { 373 console.info(`${TAG} activeSubType: ${t}`); 374 for (let e = 0; e < this.inputMethods.length; e++) { 375 if (this.inputMethods[e].name === this.defaultInputMethod.name) { 376 this.defaultInputMethod = this.inputMethods[e]; 377 let i = await inputMethod.getSetting().listInputMethodSubtype(this.inputMethods[e]); 378 for (let e = 0; e < i.length; e++) { 379 -1 !== t.indexOf(i[e].id) && this.subTypes.push(i[e]); 380 } 381 } 382 } 383 } 384 } catch (t) { 385 this.subTypes = []; 386 console.info(`${TAG} subTypes is empty, err = ${JSON.stringify(t)}`); 387 } 388 let o = 0 === this.subTypes.length ? this.inputMethods.length : this.subTypes.length + this.inputMethods.length - 1; 389 o += this.inputMethodConfig && this.inputMethodConfig.bundleName.length > 0 ? 1 : 0; 390 o += this.patternOptions && this.showHand ? 1 : 0; 391 let n = o * this.listItemHeight + 2 * this.columnPadding; 392 let s = componentUtils.getRectangleById("inputDialog"); 393 this.maxHeight = px2vp(s.size.height + s.windowOffset.y) - 10; 394 this.maxHeight > n && (this.maxHeight = n); 395 console.info(`${TAG} this.maxHeight: ${this.maxHeight}`); 396 this.viewOpacity = 1; 397 } 398 399 aboutToAppear() { 400 console.info(`${TAG} aboutToAppear`); 401 let t = display.getDefaultDisplaySync(); 402 if (t.width > 1920) { 403 this.dialogWidth = 196 * px2vp(t.width) / 1280; 404 this.fontSize = 20 * px2vp(t.width) / 1280; 405 this.imageSize = 30 * px2vp(t.width) / 1280; 406 this.listItemHeight = 60 * px2vp(t.width) / 360; 407 this.imageBtnWidth = 50 * px2vp(t.width) / 1280; 408 this.imageBtnHeight = 40 * px2vp(t.width) / 1280; 409 this.columnPadding = 5 * px2vp(t.width) / 1280; 410 this.fontPadding = 20 * px2vp(t.width) / 1280; 411 this.listItemRadius = 12 * px2vp(t.width) / 1280; 412 this.imageRadius = 10; 413 } else { 414 this.dialogWidth = 156 * px2vp(t.width) / 360; 415 this.fontSize = 16 * px2vp(t.width) / 360; 416 this.imageSize = 24 * px2vp(t.width) / 360; 417 this.listItemHeight = 48 * px2vp(t.width) / 360; 418 this.imageBtnWidth = 40 * px2vp(t.width) / 360; 419 this.imageBtnHeight = 32 * px2vp(t.width) / 360; 420 this.columnPadding = 4 * px2vp(t.width) / 360; 421 this.fontPadding = 12 * px2vp(t.width) / 360; 422 this.listItemRadius = 16 * px2vp(t.width) / 360; 423 this.imageRadius = 8; 424 } 425 this.getDefaultInputMethodSubType(); 426 inputMethodEngine.getInputMethodAbility().on('keyboardHide', (() => { 427 this.controller.close(); 428 })); 429 } 430 431 initialRender() { 432 this.observeComponentCreation2(((t, e) => { 433 Stack.create({ alignContent: Alignment.BottomStart }); 434 Stack.id('inputDialog'); 435 Stack.height('100%'); 436 Stack.width('100%'); 437 Stack.opacity(this.viewOpacity); 438 Stack.backgroundColor(this.borderBgColor); 439 Stack.transition(TransitionEffect.translate({ y: 400 }).combine(TransitionEffect.scale({ 440 x: 1, 441 y: 0 442 })).animation({ duration: 500 })); 443 Stack.onAppear((() => { 444 let t = componentUtils.getRectangleById('inputDialog'); 445 this.maxHeight = px2vp(t.size.height + t.windowOffset.y) - 10; 446 })); 447 Stack.onClick((() => { 448 this.controller.close(); 449 })) 450 }), Stack); 451 this.observeComponentCreation2(((t, e) => { 452 Column.create(); 453 Column.width(this.dialogWidth); 454 Column.margin({ top: this.columnPadding }); 455 Column.borderRadius('16vp'); 456 Column.backgroundColor(this.listBgColor); 457 Column.height(this.maxHeight); 458 Column.padding(this.columnPadding); 459 Column.shadow(ShadowStyle.OUTER_DEFAULT_SM); 460 }), Column); 461 this.observeComponentCreation2(((t, e) => { 462 If.create(); 463 this.inputMethodConfig && this.inputMethodConfig.bundleName.length > 0 ? this.ifElseBranchUpdateFunction(0, (() => { 464 this.observeComponentCreation2(((t, e) => { 465 Text.create({ 466 id: -1, 467 type: 10003, 468 params: ['sys.string.ohos_id_input_method_settings'], 469 bundleName: '', 470 moduleName: '' 471 }); 472 __Text__textStyle(); 473 Text.padding({ left: this.fontPadding, right: this.fontPadding }); 474 Text.height(this.listItemHeight); 475 Text.borderRadius(this.listItemRadius); 476 Text.fontSize(this.fontSize); 477 Text.fontColor(this.fontColor); 478 ViewStackProcessor.visualState('pressed'); 479 Text.backgroundColor(this.pressedColor); 480 ViewStackProcessor.visualState('normal'); 481 Text.backgroundColor(this.listBgColor); 482 ViewStackProcessor.visualState(); 483 Text.onClick((() => { 484 if (this.inputMethodConfig) { 485 getContext(this).startAbility({ 486 bundleName: this.inputMethodConfig.bundleName, 487 moduleName: this.inputMethodConfig.moduleName, 488 abilityName: this.inputMethodConfig.abilityName 489 }); 490 } 491 })); 492 }), Text); 493 Text.pop(); 494 this.observeComponentCreation2(((t, e) => { 495 Divider.create(); 496 __Divider__divider(); 497 }), Divider); 498 })) : this.ifElseBranchUpdateFunction(1, (() => { 499 })); 500 }), If); 501 If.pop(); 502 this.observeComponentCreation2(((t, e) => { 503 Scroll.create(); 504 Scroll.width('100%'); 505 Scroll.scrollBar(BarState.Off); 506 Scroll.layoutWeight(1); 507 }), Scroll); 508 this.observeComponentCreation2(((t, e) => { 509 Column.create(); 510 Column.width('100%'); 511 }), Column); 512 this.observeComponentCreation2(((t, e) => { 513 ForEach.create(); 514 this.forEachUpdateFunction(t, this.subTypes, ((t, e) => { 515 const i = t; 516 this.observeComponentCreation2(((t, e) => { 517 Column.create(); 518 Column.width('100%'); 519 Column.onClick((() => { 520 this.switchMethodSub(i); 521 })); 522 }), Column); 523 this.observeComponentCreation2(((t, e) => { 524 Text.create(i.label); 525 Text.fontSize(this.fontSize); 526 __Text__textStyle(); 527 Text.padding({ left: this.fontPadding, right: this.fontPadding }); 528 Text.height(this.listItemHeight); 529 Text.borderRadius(this.listItemRadius); 530 Text.fontColor(this.currentSub && this.currentSub.id === i.id && this.currentSub.name === i.name ? 531 this.selectedFontColor : this.fontColor); 532 ViewStackProcessor.visualState('pressed'); 533 Text.backgroundColor(this.pressedColor); 534 ViewStackProcessor.visualState('normal'); 535 Text.backgroundColor(this.currentSub && this.currentSub.id === i.id && this.currentSub.name === i.name ? 536 this.selectedColor : this.listBgColor); 537 ViewStackProcessor.visualState(); 538 }), Text); 539 Text.pop(); 540 this.observeComponentCreation2(((t, i) => { 541 If.create(); 542 this.inputMethods.length > 1 || e < this.subTypes.length ? this.ifElseBranchUpdateFunction(0, (() => { 543 this.observeComponentCreation2(((t, e) => { 544 Divider.create(); 545 __Divider__divider(); 546 }), Divider); 547 })) : this.ifElseBranchUpdateFunction(1, (() => { 548 })); 549 }), If); 550 If.pop(); 551 Column.pop(); 552 }), (t => JSON.stringify(t)),!0,!1); 553 }), ForEach); 554 ForEach.pop(); 555 this.observeComponentCreation2(((t, e) => { 556 ForEach.create(); 557 this.forEachUpdateFunction(t, this.inputMethods, ((t, e) => { 558 const i = t; 559 this.observeComponentCreation2(((t, o) => { 560 If.create(); 561 0 === this.subTypes.length || this.defaultInputMethod && i.name !== this.defaultInputMethod.name ? 562 this.ifElseBranchUpdateFunction(0, (() => { 563 this.observeComponentCreation2(((t, e) => { 564 Text.create(i.label); 565 Text.fontSize(this.fontSize); 566 __Text__textStyle(); 567 Text.padding({ left: this.fontPadding, right: this.fontPadding }); 568 Text.height(this.listItemHeight); 569 Text.borderRadius(this.listItemRadius); 570 Text.fontColor(this.currentSub && this.currentSub.id === i.id && this.currentSub.name === i.name ? 571 this.selectedFontColor : this.fontColor); 572 ViewStackProcessor.visualState('pressed'); 573 Text.backgroundColor(this.pressedColor); 574 ViewStackProcessor.visualState('normal'); 575 Text.backgroundColor(this.currentInputMethod && this.currentInputMethod.name === i.name ? 576 this.selectedColor : this.listBgColor); 577 ViewStackProcessor.visualState(); 578 Text.onClick((() => { 579 this.switchMethod(i); 580 })) 581 }), Text); 582 Text.pop(); 583 this.observeComponentCreation2(((t, i) => { 584 If.create(); 585 e < this.inputMethods.length - 1 ? this.ifElseBranchUpdateFunction(0, (() => { 586 this.observeComponentCreation2(((t, e) => { 587 Divider.create(); 588 __Divider__divider(); 589 }), Divider); 590 })) : this.ifElseBranchUpdateFunction(1, (() => { 591 })) 592 }), If); 593 If.pop(); 594 })) : this.ifElseBranchUpdateFunction(1, (() => { 595 })) 596 }), If); 597 If.pop(); 598 }), (t => JSON.stringify(t)),!0,!1); 599 }), ForEach); 600 ForEach.pop(); 601 Column.pop(); 602 Scroll.pop(); 603 this.observeComponentCreation2(((t, e) => { 604 If.create(); 605 this.patternOptions && this.showHand ? this.ifElseBranchUpdateFunction(0, (() => { 606 this.observeComponentCreation2(((t, e) => { 607 Divider.create(); 608 __Divider__divider(); 609 }), Divider); 610 this.observeComponentCreation2(((t, e) => { 611 Row.create(); 612 Row.width('100%'); 613 Row.height(this.listItemHeight);; 614 Row.justifyContent(FlexAlign.SpaceEvenly); 615 }), Row); 616 this.observeComponentCreation2(((t, e) => { 617 ForEach.create(); 618 this.forEachUpdateFunction(t, this.patternOptions.patterns, ((t, e) => { 619 const i = t; 620 this.observeComponentCreation2(((t, i) => { 621 Row.create(); 622 Row.justifyContent(FlexAlign.Center); 623 Row.size({ width: this.imageBtnWidth, height: this.imageBtnHeight }); 624 Row.borderRadius(this.imageRadius); 625 ViewStackProcessor.visualState('pressed'); 626 Row.backgroundColor(this.pressedColor); 627 ViewStackProcessor.visualState('normal'); 628 Row.backgroundColor(this.listBgColor); 629 ViewStackProcessor.visualState(); 630 Row.onClick((() => { 631 this.switchPositionPattern(e); 632 })) 633 }), Row); 634 this.observeComponentCreation2(((t, o) => { 635 Image.create(e === this.patternMode ? i.selectedIcon : i.icon); 636 Image.size({ width: this.imageSize, height: this.imageSize }); 637 Image.objectFit(ImageFit.Contain); 638 }), Image); 639 Row.pop(); 640 }), (t => JSON.stringify(t)),!0,!1); 641 }), ForEach); 642 ForEach.pop(); 643 Row.pop(); 644 })) : this.ifElseBranchUpdateFunction(1, (() => { 645 })); 646 }), If); 647 If.pop(); 648 Column.pop(); 649 Stack.pop(); 650 } 651 652 switchPositionPattern(t) { 653 if (this.patternOptions) { 654 this.patternMode = t; 655 AppStorage.set('patternMode', this.patternMode); 656 console.info(`${TAG} this.handMode = ${this.patternMode}`); 657 this.patternOptions.action(this.patternMode); 658 this.controller.close(); 659 } 660 } 661 662 async switchMethod(t) { 663 if (this.currentInputMethod && this.currentInputMethod.name !== t.name) { 664 let e = await inputMethod.getSetting().listInputMethodSubtype(t); 665 inputMethod.switchCurrentInputMethodAndSubtype(t, e[0], ((e, i) => { 666 i && (this.currentInputMethod = t); 667 this.controller.close(); 668 })); 669 } 670 } 671 672 switchMethodSub(t) { 673 this.currentInputMethod && this.defaultInputMethod && 674 (this.currentInputMethod.name !== this.defaultInputMethod.name ? 675 inputMethod.switchCurrentInputMethodAndSubtype(this.defaultInputMethod, t, (() => { 676 this.currentInputMethod = this.defaultInputMethod; 677 this.currentSub = t; 678 this.controller.close(); 679 })) : inputMethod.switchCurrentInputMethodSubtype(t, (() => { 680 this.currentSub = t; 681 this.controller.close(); 682 }))); 683 } 684 685 rerender() { 686 this.updateDirtyElements(); 687 } 688} 689 690export default { 691 InputMethodListDialog 692};