1/* 2 * Copyright (c) 2022-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 16/* 17 * Copyright (C) 2022-2023 Huawei Device Co., Ltd. 18 * Licensed under the MIT License, Version 2.0 (the 'License'); 19 * you may not use this file except in compliance with the License. 20 * You may obtain a copy of the License at 21 * 22 * https://mit-license.org/ 23 * 24 * Unless required by applicable law or agreed to in writing, software 25 * distributed under the License is distributed on an 'AS IS' BASIS, 26 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 * See the License for the specific language governing permissions and 28 * limitations under the License. 29 */ 30 31import lottie from '@ohos/lottie' 32import Logger from '../util/Logger' 33 34const TAG: string = 'Lottie' 35const SELECT_OPACITY: number = 0.5 36const BUTTON_OPACITY: number = 0.8 37 38@Entry 39@Component 40struct Lottie { 41 private settings: RenderingContextSettings = new RenderingContextSettings(true) 42 private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) 43 private settingsYear: RenderingContextSettings = new RenderingContextSettings(true) 44 private contextYear: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settingsYear) 45 private scroller: Scroller = new Scroller() 46 private animateItem: any = null 47 private animateName: string = 'grunt' 48 private animationResources: string | Resource = $r('app.string.select_please') 49 private controller: TabsController = new TabsController() 50 @State valueS: AnimationStatus = AnimationStatus.Initial 51 @State imagePath: Resource = $r('app.media.play') 52 @State isPlaying: boolean = true 53 54 callbackItem() { 55 Logger.info(TAG, 'grunt loopComplete') 56 } 57 58 build() { 59 Column() { 60 Canvas(this.context) 61 .width('540px') 62 .height('360px') 63 .backgroundColor(Color.Gray) 64 .onDisAppear(() => { 65 lottie.destroy(this.animateName) 66 }) 67 .margin({ top: 10 }) 68 69 Canvas(this.contextYear) 70 .width('540px') 71 .height('360px') 72 .backgroundColor(Color.Gray) 73 .onReady(() => { 74 let animation = lottie.loadAnimation({ 75 container: this.contextYear, 76 renderer: 'canvas', 77 loop: true, 78 autoplay: true, 79 name: 'year', 80 path: 'common/lottie/data.json', 81 }) 82 animation.addEventListener('loopComplete', this.callbackItem) 83 }) 84 .onDisAppear(() => { 85 lottie.destroy('year') 86 }) 87 .margin({ bottom: 10 }) 88 89 Scroll(this.scroller) { 90 Column() { 91 Row() { 92 Animator('__lottie_ets') 93 94 Text($r('app.string.select')) 95 .fontSize(16) 96 .fontColor($r('app.color.font_color')) 97 .fontWeight(FontWeight.Medium) 98 .opacity(SELECT_OPACITY) 99 100 Column() { 101 Text(this.animationResources) 102 .fontSize(16) 103 .fontColor($r('app.color.font_color')) 104 .fontWeight(FontWeight.Medium) 105 .width('50%') 106 .textAlign(TextAlign.End) 107 } 108 .id('selectAnimationBtn') 109 .bindMenu([ 110 { 111 value: 'grunt动画', 112 action: () => { 113 this.animateItem = lottie.loadAnimation({ 114 container: this.context, 115 renderer: 'canvas', 116 loop: true, 117 autoplay: true, 118 name: this.animateName, 119 path: 'common/lottie/grunt.json', 120 }) 121 this.animationResources = 'grunt' 122 } 123 }, 124 { 125 value: 'year动画', 126 action: () => { 127 lottie.loadAnimation({ 128 container: this.contextYear, 129 renderer: 'canvas', 130 loop: true, 131 autoplay: true, 132 name: 'year', 133 path: 'common/lottie/data.json', 134 }) 135 this.animationResources = 'year' 136 } 137 }, 138 ]) 139 } 140 .width('100%') 141 .justifyContent(FlexAlign.SpaceBetween) 142 .backgroundColor('#FFFFFF') 143 .padding(10) 144 .borderRadius(24) 145 .margin({ bottom: 8 }) 146 147 Column() { 148 Row() { 149 Column() { 150 Image($r('app.media.suspend')) 151 .width(30) 152 .height(30) 153 .onClick(() => { 154 this.isPlaying = !this.isPlaying 155 lottie.togglePause() 156 if (!this.isPlaying) { 157 this.imagePath = $r('app.media.suspend') 158 } else { 159 this.imagePath = $r('app.media.play') 160 } 161 }) 162 163 Text($r('app.string.play_pause')) 164 .fontSize(14) 165 .fontColor($r('app.color.font_color')) 166 .fontWeight(FontWeight.Medium) 167 .opacity(BUTTON_OPACITY) 168 .margin({ top: 6 }) 169 .fontFamily('Microsoft YaHei') 170 } 171 .id('play') 172 .width('25%') 173 174 Column() { 175 Image($r('app.media.stop_playing')) 176 .objectFit(ImageFit.Cover) 177 .width(30) 178 .height(30) 179 .onClick(() => { 180 lottie.stop() 181 this.isPlaying = false 182 }) 183 184 Text($r('app.string.stop')) 185 .fontSize(14) 186 .fontColor($r('app.color.font_color')) 187 .fontWeight(FontWeight.Medium) 188 .opacity(BUTTON_OPACITY) 189 .margin({ top: 6 }) 190 .fontFamily('Microsoft YaHei') 191 } 192 .width('25%') 193 .id('suspend') 194 195 Column() { 196 Image($r('app.media.pause')) 197 .objectFit(ImageFit.Cover) 198 .width(30) 199 .height(30) 200 .onClick(() => { 201 lottie.pause() 202 this.isPlaying = false 203 }) 204 205 Text($r('app.string.pause')) 206 .fontSize(14) 207 .fontColor($r('app.color.font_color')) 208 .fontWeight(FontWeight.Medium) 209 .opacity(BUTTON_OPACITY) 210 .margin({ top: 6 }) 211 .fontFamily('Microsoft YaHei') 212 } 213 .width('25%') 214 .id('pause') 215 216 Column() { 217 Image($r('app.media.start')) 218 .width(30) 219 .height(30) 220 .objectFit(ImageFit.Fill) 221 .onClick(() => { 222 lottie.play() 223 this.isPlaying = true 224 }) 225 226 Text($r('app.string.start_play')) 227 .fontSize(14) 228 .fontColor($r('app.color.font_color')) 229 .fontWeight(FontWeight.Medium) 230 .opacity(BUTTON_OPACITY) 231 .margin({ top: 6 }) 232 .fontFamily('Microsoft YaHei') 233 } 234 .width('25%') 235 .id('startPlay') 236 } 237 238 Row() { 239 Column() { 240 Image($r('app.media.speed')) 241 .width(30) 242 .height(30) 243 .objectFit(ImageFit.Fill) 244 .bindMenu([ 245 { 246 value: '×1', 247 action: () => { 248 lottie.setSpeed(1) 249 } 250 }, 251 { 252 value: '×2', 253 action: () => { 254 lottie.setSpeed(2) 255 } 256 }, 257 { 258 value: '×3', 259 action: () => { 260 lottie.setSpeed(5) 261 } 262 } 263 ]) 264 265 Text($r('app.string.speed')) 266 .fontSize(14) 267 .fontColor($r('app.color.font_color')) 268 .fontWeight(FontWeight.Medium) 269 .opacity(BUTTON_OPACITY) 270 .margin({ top: 6 }) 271 .fontFamily('Microsoft YaHei') 272 } 273 .width('25%') 274 .id('speed') 275 276 Column() { 277 Image($r('app.media.forward')) 278 .width(30) 279 .height(30) 280 .objectFit(ImageFit.Fill) 281 .bindMenu([ 282 { 283 value: '正向', 284 action: () => { 285 lottie.setDirection(1) 286 } 287 }, 288 { 289 value: '反向', 290 action: () => { 291 lottie.setDirection(-1) 292 } 293 } 294 ]) 295 296 Text($r('app.string.play_order')) 297 .fontSize(14) 298 .fontColor($r('app.color.font_color')) 299 .fontWeight(FontWeight.Medium) 300 .opacity(BUTTON_OPACITY) 301 .margin({ top: 6 }) 302 .fontFamily('Microsoft YaHei') 303 } 304 .width('25%') 305 .id('playOrder') 306 307 Column() { 308 Image($r('app.media.ic_public_delete_filled')) 309 .width(30) 310 .height(30) 311 .onClick(() => { 312 if (this.animateItem !== null) { 313 lottie.destroy() 314 this.animateItem = null 315 } 316 }) 317 318 Text($r('app.string.destruction_animation')) 319 .fontSize(14) 320 .fontColor($r('app.color.font_color')) 321 .fontWeight(FontWeight.Medium) 322 .opacity(BUTTON_OPACITY) 323 .margin({ top: 6 }) 324 .fontFamily('Microsoft YaHei') 325 } 326 .width('25%') 327 .id('destroyAnimation') 328 } 329 .width('100%') 330 .justifyContent(FlexAlign.Start) 331 } 332 .justifyContent(FlexAlign.SpaceAround) 333 .backgroundColor('#FFFFFF') 334 .padding(10) 335 .borderRadius(24) 336 .margin({ bottom: 8 }) 337 338 Column() { 339 Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { 340 TabContent() { 341 Column() { 342 Text($r('app.string.display_effect')) 343 .fontSize(14) 344 .margin({ top: 10, bottom: 10 }) 345 346 Column() { 347 Row() { 348 Column() { 349 Image($r('app.media.start_stop')) 350 .width(30) 351 .height(30) 352 .onClick(() => { 353 lottie.togglePause(this.animateName) 354 }) 355 356 Text($r('app.string.play_pause')) 357 .fontSize(14) 358 .fontColor($r('app.color.font_color')) 359 .fontWeight(FontWeight.Medium) 360 .opacity(BUTTON_OPACITY) 361 .margin({ top: 6 }) 362 .fontFamily('Microsoft YaHei') 363 } 364 .width('33%') 365 .id('stop') 366 367 Column() { 368 Image($r('app.media.stop_playing')) 369 .width(30) 370 .height(30) 371 .onClick(() => { 372 lottie.stop(this.animateName) 373 }) 374 375 Text($r('app.string.stop')) 376 .fontSize(14) 377 .fontColor($r('app.color.font_color')) 378 .fontWeight(FontWeight.Medium) 379 .opacity(BUTTON_OPACITY) 380 .margin({ top: 6 }) 381 .fontFamily('Microsoft YaHei') 382 }.width('33%') 383 384 Column() { 385 Image($r('app.media.pause')) 386 .width(30) 387 .height(30) 388 .onClick(() => { 389 lottie.pause(this.animateName) 390 }) 391 392 Text($r('app.string.pause')) 393 .fontSize(14) 394 .fontColor($r('app.color.font_color')) 395 .fontWeight(FontWeight.Medium) 396 .opacity(BUTTON_OPACITY) 397 .margin({ top: 6 }) 398 .fontFamily('Microsoft YaHei') 399 } 400 .width('33%') 401 } 402 403 Row() { 404 Column() { 405 Image($r('app.media.start')) 406 .width(30) 407 .height(30) 408 .onClick(() => { 409 lottie.play(this.animateName) 410 }) 411 412 Text($r('app.string.start_play')) 413 .fontSize(14) 414 .fontColor($r('app.color.font_color')) 415 .fontWeight(FontWeight.Medium) 416 .opacity(BUTTON_OPACITY) 417 .margin({ top: 6 }) 418 .fontFamily('Microsoft YaHei') 419 } 420 .width('33%') 421 422 Column() { 423 Image($r('app.media.speed')) 424 .width(30) 425 .height(30) 426 .onClick(() => { 427 lottie.setSpeed(2, this.animateName) 428 }) 429 430 Text($r('app.string.double_speed')) 431 .fontSize(14) 432 .fontColor($r('app.color.font_color')) 433 .fontWeight(FontWeight.Medium) 434 .opacity(BUTTON_OPACITY) 435 .margin({ top: 6 }) 436 .fontFamily('Microsoft YaHei') 437 } 438 .width('33%') 439 440 Column() { 441 Image($r('app.media.forward')) 442 .width(30) 443 .height(30) 444 .onClick(() => { 445 lottie.setDirection(-1, this.animateName) 446 }) 447 448 Text($r('app.string.reverse_playback')) 449 .fontSize(14) 450 .fontColor($r('app.color.font_color')) 451 .fontWeight(FontWeight.Medium) 452 .opacity(BUTTON_OPACITY) 453 .margin({ top: 6 }) 454 .fontFamily('Microsoft YaHei') 455 } 456 .width('33%') 457 } 458 } 459 .justifyContent(FlexAlign.SpaceAround) 460 .height('65%') 461 } 462 .width('100%') 463 .height('100%') 464 .borderRadius(24) 465 .backgroundColor($r('app.color.tab_content_background')) 466 } 467 .tabBar($r('app.string.play_pause')) 468 469 TabContent() { 470 Column() { 471 Text($r('app.string.display_effect_this')) 472 .fontSize(14) 473 .margin({ top: 10, bottom: 10 }) 474 Column() { 475 476 Row() { 477 Column() { 478 Image($r('app.media.start_stop')) 479 .width(30) 480 .height(30) 481 .onClick(() => { 482 if (this.animateItem !== null) { 483 this.animateItem.togglePause() 484 } 485 }) 486 487 Text($r('app.string.play_pause')) 488 .fontSize(14) 489 .fontColor($r('app.color.font_color')) 490 .fontWeight(FontWeight.Medium) 491 .opacity(BUTTON_OPACITY) 492 .margin({ top: 6 }) 493 .fontFamily('Microsoft YaHei') 494 } 495 .width('33%') 496 497 Column() { 498 Image($r('app.media.stop_playing')) 499 .width(30) 500 .height(30) 501 .onClick(() => { 502 if (this.animateItem !== null) { 503 this.animateItem.stop() 504 } 505 }) 506 507 Text($r('app.string.stop')) 508 .fontSize(14) 509 .fontColor($r('app.color.font_color')) 510 .fontWeight(FontWeight.Medium) 511 .opacity(BUTTON_OPACITY) 512 .margin({ top: 6 }) 513 .fontFamily('Microsoft YaHei') 514 } 515 .width('33%') 516 517 Column() { 518 Image($r('app.media.pause')) 519 .width(30) 520 .height(30) 521 .onClick(() => { 522 if (this.animateItem !== null) { 523 this.animateItem.pause() 524 } 525 }) 526 527 Text($r('app.string.pause')) 528 .fontSize(14) 529 .fontColor($r('app.color.font_color')) 530 .fontWeight(FontWeight.Medium) 531 .opacity(BUTTON_OPACITY) 532 .margin({ top: 6 }) 533 .fontFamily('Microsoft YaHei') 534 } 535 .width('33%') 536 } 537 538 Row() { 539 Column() { 540 Image($r('app.media.start')) 541 .width(30) 542 .height(30) 543 .onClick(() => { 544 if (this.animateItem !== null) { 545 this.animateItem.play() 546 } 547 }) 548 Text($r('app.string.start_play')) 549 .fontSize(14) 550 .fontColor($r('app.color.font_color')) 551 .fontWeight(FontWeight.Medium) 552 .opacity(BUTTON_OPACITY) 553 .margin({ top: 6 }) 554 .fontFamily('Microsoft YaHei') 555 } 556 .width('33%') 557 558 Column() { 559 Image($r('app.media.speed')) 560 .width(30) 561 .height(30) 562 .onClick(() => { 563 if (this.animateItem !== null) { 564 this.animateItem.setSpeed(5) 565 } 566 }) 567 568 Text($r('app.string.five_speed')) 569 .fontSize(14) 570 .fontColor($r('app.color.font_color')) 571 .fontWeight(FontWeight.Medium) 572 .opacity(BUTTON_OPACITY) 573 .margin({ top: 6 }) 574 .fontFamily('Microsoft YaHei') 575 } 576 .width('33%') 577 578 Column() { 579 Image($r('app.media.forward')) 580 .width(30) 581 .height(30) 582 .onClick(() => { 583 if (this.animateItem !== null) { 584 this.animateItem.setDirection(-1) 585 } 586 }) 587 588 Text($r('app.string.reverse_playback')) 589 .fontSize(14) 590 .fontColor($r('app.color.font_color')) 591 .fontWeight(FontWeight.Medium) 592 .opacity(BUTTON_OPACITY) 593 .margin({ top: 6 }) 594 .fontFamily('Microsoft YaHei') 595 } 596 .width('33%') 597 } 598 } 599 .justifyContent(FlexAlign.SpaceEvenly) 600 .height('65%') 601 } 602 .borderRadius(24) 603 .width('100%') 604 .height('100%') 605 .backgroundColor($r('app.color.tab_content_background')) 606 } 607 .tabBar($r('app.string.play_pause')) 608 609 TabContent() { 610 Column() { 611 Row() { 612 Column() { 613 Image($r('app.media.loop')) 614 .width(30) 615 .height(30) 616 .onClick(() => { 617 if (this.animateItem !== null) { 618 this.animateItem.setSegment(20, 30) 619 } 620 }) 621 622 Text($r('app.string.fragment_cycle')) 623 .fontSize(14) 624 .fontColor($r('app.color.font_color')) 625 .fontWeight(FontWeight.Medium) 626 .opacity(BUTTON_OPACITY) 627 .margin({ top: 6 }) 628 .fontFamily('Microsoft YaHei') 629 } 630 .width('50%') 631 632 Column() { 633 Image($r('app.media.loop')) 634 .width(30) 635 .height(30) 636 .onClick(() => { 637 if (this.animateItem !== null) { 638 this.animateItem.playSegments([[5, 15], [20, 30]], true) 639 } 640 }) 641 642 Text($r('app.string.play_segments')) 643 .padding({ left: 5, right: 5 }) 644 .fontSize(14) 645 .fontColor($r('app.color.font_color')) 646 .fontWeight(FontWeight.Medium) 647 .opacity(BUTTON_OPACITY) 648 .margin({ top: 6 }) 649 .fontFamily('Microsoft YaHei') 650 } 651 .width('50%') 652 } 653 654 Row() { 655 Column() { 656 Image($r('app.media.reset')) 657 .width(30) 658 .height(30) 659 .bindMenu([ 660 { 661 value: '即时生效播放', 662 action: (() => { 663 if (this.animateItem !== null) { 664 this.animateItem.resetSegments(true) 665 } 666 }) 667 }, 668 { 669 value: '延迟到下轮循环播放再生效', 670 action: (() => { 671 if (this.animateItem !== null) { 672 this.animateItem.resetSegments(false) 673 } 674 }) 675 } 676 ]) 677 678 Text($r('app.string.reset_play')) 679 .fontSize(14) 680 .fontColor($r('app.color.font_color')) 681 .fontWeight(FontWeight.Medium) 682 .opacity(BUTTON_OPACITY) 683 .margin({ top: 6 }) 684 .fontFamily('Microsoft YaHei') 685 } 686 .width('50%') 687 688 Column() { 689 Image($r('app.media.subframe')) 690 .width(30) 691 .height(30) 692 .onClick(() => { 693 if (this.animateItem !== null) { 694 this.animateItem.setSubframe(false) 695 } 696 }) 697 698 Text($r('app.string.float_integer')) 699 .fontSize(14) 700 .fontColor($r('app.color.font_color')) 701 .fontWeight(FontWeight.Medium) 702 .opacity(BUTTON_OPACITY) 703 .margin({ top: 6 }) 704 .fontFamily('Microsoft YaHei') 705 } 706 .width('50%') 707 } 708 } 709 .justifyContent(FlexAlign.SpaceEvenly) 710 .borderRadius(24) 711 .width('100%') 712 .height('100%') 713 .backgroundColor($r('app.color.tab_content_background')) 714 } 715 .tabBar($r('app.string.cycle')) 716 717 TabContent() { 718 Column() { 719 Row() { 720 Column() { 721 Image($r('app.media.destination')) 722 .width(30) 723 .height(30) 724 .bindMenu([ 725 { 726 value: '250帧时停止', 727 action: (() => { 728 if (this.animateItem !== null) { 729 this.animateItem.goToAndStop(250, true) 730 } 731 }) 732 }, 733 { 734 value: '5000ms时停止', 735 action: (() => { 736 if (this.animateItem !== null) { 737 this.animateItem.goToAndStop(5000, false) 738 } 739 }) 740 } 741 ]) 742 Text($r('app.string.animation_stop')) 743 .fontSize(14) 744 .fontColor($r('app.color.font_color')) 745 .fontWeight(FontWeight.Medium) 746 .opacity(BUTTON_OPACITY) 747 .margin({ top: 6 }) 748 .fontFamily('Microsoft YaHei') 749 } 750 .width('50%') 751 752 Column() { 753 Image($r('app.media.begin')) 754 .width(30) 755 .height(30) 756 .bindMenu([ 757 { 758 value: '从250帧开始播放', 759 action: (() => { 760 if (this.animateItem !== null) { 761 this.animateItem.goToAndPlay(250, true); 762 } 763 }) 764 }, 765 { 766 value: '从12000ms开始播放', 767 action: (() => { 768 if (this.animateItem !== null) { 769 this.animateItem.goToAndPlay(12000, false) 770 } 771 }) 772 } 773 ]) 774 775 Text($r('app.string.animation_play')) 776 .fontSize(14) 777 .fontColor($r('app.color.font_color')) 778 .fontWeight(FontWeight.Medium) 779 .opacity(BUTTON_OPACITY) 780 .margin({ top: 6 }) 781 .fontFamily('Microsoft YaHei') 782 } 783 .width('50%') 784 } 785 786 Row() { 787 Column() { 788 Image($r('app.media.refresh')) 789 .width(30) 790 .height(30) 791 .onClick(() => { 792 if (this.animateItem !== null) { 793 this.animateItem.resize() 794 } 795 }) 796 797 Text($r('app.string.refresh_animation')) 798 .fontSize(14) 799 .fontColor($r('app.color.font_color')) 800 .fontWeight(FontWeight.Medium) 801 .opacity(BUTTON_OPACITY) 802 .margin({ top: 6 }) 803 .fontFamily('Microsoft YaHei') 804 } 805 .width('50%') 806 807 Column() { 808 Image($r('app.media.destory')) 809 .width(30) 810 .height(30) 811 .onClick(() => { 812 if (this.animateItem !== null) { 813 this.animateItem.destroy(this.animateName) 814 this.animateItem = null 815 } 816 }) 817 818 Text($r('app.string.destruction_grunt_animation')) 819 .fontSize(14) 820 .fontColor($r('app.color.font_color')) 821 .fontWeight(FontWeight.Medium) 822 .opacity(BUTTON_OPACITY) 823 .margin({ top: 6 }) 824 .fontFamily('Microsoft YaHei') 825 } 826 .width('50%') 827 } 828 } 829 .justifyContent(FlexAlign.SpaceEvenly) 830 .borderRadius(24) 831 .width('100%') 832 .height('100%') 833 .backgroundColor($r('app.color.tab_content_background')) 834 } 835 .tabBar($r('app.string.playback_position')) 836 837 TabContent() { 838 Column() { 839 Row() { 840 Column() { 841 Image($r('app.media.addevent')) 842 .width(30) 843 .height(30) 844 .onClick(() => { 845 if (this.animateItem !== null) { 846 this.animateItem.addEventListener('loopComplete', this.callbackItem) 847 } 848 }) 849 850 Text($r('app.string.add_listen')) 851 .fontSize(14) 852 .fontColor($r('app.color.font_color')) 853 .fontWeight(FontWeight.Medium) 854 .opacity(BUTTON_OPACITY) 855 .margin({ top: 6 }) 856 .fontFamily('Microsoft YaHei') 857 } 858 .width('50%') 859 860 Column() { 861 Image($r('app.media.delete')) 862 .width(30) 863 .height(30) 864 .onClick(() => { 865 if (this.animateItem !== null) { 866 this.animateItem.stop() 867 } 868 }) 869 870 Text($r('app.string.delete_listen')) 871 .fontSize(14) 872 .fontColor($r('app.color.font_color')) 873 .fontWeight(FontWeight.Medium) 874 .opacity(BUTTON_OPACITY) 875 .margin({ top: 6 }) 876 .fontFamily('Microsoft YaHei') 877 } 878 .width('50%') 879 } 880 881 Row() { 882 Column() { 883 Image($r('app.media.addall')) 884 .width(30) 885 .height(30) 886 .onClick(() => { 887 if (this.animateItem !== null) { 888 this.animateItem.pause() 889 } 890 }) 891 892 Text($r('app.string.triggers_all_callbacks')) 893 .padding({ left: 5, right: 5 }) 894 .fontSize(14) 895 .fontColor($r('app.color.font_color')) 896 .fontWeight(FontWeight.Medium) 897 .opacity(BUTTON_OPACITY) 898 .margin({ top: 6 }) 899 .fontFamily('Microsoft YaHei') 900 } 901 .width('50%') 902 903 Column() { 904 Image($r("app.media.delete_all")) 905 .width(30) 906 .height(30) 907 .onClick(() => { 908 if (this.animateItem !== null) { 909 this.animateItem.play() 910 } 911 }) 912 913 Text($r('app.string.delete_all_Listen')) 914 .fontSize(14) 915 .fontColor($r('app.color.font_color')) 916 .fontWeight(FontWeight.Medium) 917 .opacity(BUTTON_OPACITY) 918 .margin({ top: 6 }) 919 .fontFamily('Microsoft YaHei') 920 } 921 .width('50%') 922 } 923 } 924 .justifyContent(FlexAlign.SpaceEvenly) 925 .borderRadius(24) 926 .width('100%') 927 .height('100%') 928 .backgroundColor($r('app.color.tab_content_background')) 929 } 930 .tabBar($r('app.string.listen')) 931 } 932 .vertical(true) 933 .scrollable(true) 934 .barMode(BarMode.Fixed) 935 .barWidth(100) 936 .barHeight(230) 937 .animationDuration(0) 938 .onChange((index: number) => { 939 Logger.info(TAG, index.toString()) 940 }) 941 .borderRadius(24) 942 .backgroundColor('#FFFFFF') 943 } 944 .width('100%') 945 .height(230) 946 .margin({ bottom: 8 }) 947 } 948 } 949 .scrollBar(BarState.Off) 950 .height('100%') 951 .padding({ left: 10, right: 10, bottom: '720px' }) 952 } 953 .alignItems(HorizontalAlign.Center) 954 .justifyContent(FlexAlign.Center) 955 .backgroundColor('#F1F3F5') 956 .width('100%') 957 .height('100%') 958 } 959}