1/* 2 * Copyright (c) 2022-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 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 promptAction from '@ohos.promptAction' 33import Logger from '../util/Logger' 34 35const TAG: string = 'Lottie' 36const SELECT_OPACITY: number = 0.5 37const BUTTON_OPACITY: number = 0.8 38 39@Entry 40@Component 41struct Lottie { 42 private settings: RenderingContextSettings = new RenderingContextSettings(true) 43 private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) 44 private settingsYear: RenderingContextSettings = new RenderingContextSettings(true) 45 private contextYear: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settingsYear) 46 private scroller: Scroller = new Scroller() 47 private animateItem: any = null 48 private animateName: string = 'grunt' 49 private animationResources: string | Resource = $r('app.string.select_please') 50 private controller: TabsController = new TabsController() 51 @State valueS: AnimationStatus = AnimationStatus.Initial 52 @State imagePath: Resource = $r('app.media.play') 53 @State isPlaying: boolean = true 54 55 callbackItem() { 56 Logger.info(TAG, 'grunt loopComplete') 57 } 58 59 build() { 60 Column() { 61 Canvas(this.context) 62 .width('540px') 63 .height('360px') 64 .backgroundColor(Color.Gray) 65 .onDisAppear(() => { 66 lottie.destroy(this.animateName) 67 }) 68 .margin({ top: 10 }) 69 70 Canvas(this.contextYear) 71 .width('540px') 72 .height('360px') 73 .backgroundColor(Color.Gray) 74 .onReady(() => { 75 let animation = lottie.loadAnimation({ 76 container: this.contextYear, 77 renderer: 'canvas', 78 loop: true, 79 autoplay: true, 80 name: 'year', 81 path: 'common/lottie/data.json', 82 }) 83 animation.addEventListener('loopComplete', this.callbackItem) 84 }) 85 .onDisAppear(() => { 86 lottie.destroy('year') 87 }) 88 .margin({ bottom: 10 }) 89 90 Scroll(this.scroller) { 91 Column() { 92 Row() { 93 Text($r('app.string.select')) 94 .fontSize(16) 95 .fontColor($r('app.color.font_color')) 96 .fontWeight(FontWeight.Medium) 97 .opacity(SELECT_OPACITY) 98 99 Column() { 100 Text(this.animationResources) 101 .fontSize(16) 102 .fontColor($r('app.color.font_color')) 103 .fontWeight(FontWeight.Medium) 104 .width('50%') 105 .textAlign(TextAlign.End) 106 } 107 .id('selectAnimationBtn') 108 .bindMenu([ 109 { 110 value: 'grunt动画', 111 action: () => { 112 this.animateItem = lottie.loadAnimation({ 113 container: this.context, 114 renderer: 'canvas', 115 loop: true, 116 autoplay: true, 117 name: this.animateName, 118 path: 'common/lottie/grunt.json', 119 }) 120 this.animationResources = 'grunt' 121 } 122 }, 123 { 124 value: 'year动画', 125 action: () => { 126 lottie.loadAnimation({ 127 container: this.contextYear, 128 renderer: 'canvas', 129 loop: true, 130 autoplay: true, 131 name: 'year', 132 path: 'common/lottie/data.json', 133 }) 134 this.animationResources = 'year' 135 } 136 }, 137 ]) 138 } 139 .width('100%') 140 .justifyContent(FlexAlign.SpaceBetween) 141 .backgroundColor('#FFFFFF') 142 .padding(10) 143 .borderRadius(24) 144 .margin({ bottom: 8 }) 145 146 Column() { 147 Row() { 148 Column() { 149 Image($r('app.media.suspend')) 150 .width(30) 151 .height(30) 152 .onClick(() => { 153 this.isPlaying = !this.isPlaying 154 lottie.togglePause() 155 if (!this.isPlaying) { 156 this.imagePath = $r('app.media.suspend') 157 } else { 158 this.imagePath = $r('app.media.play') 159 } 160 }) 161 162 Text($r('app.string.play_pause')) 163 .fontSize(14) 164 .fontColor($r('app.color.font_color')) 165 .fontWeight(FontWeight.Medium) 166 .opacity(BUTTON_OPACITY) 167 .margin({ top: 6 }) 168 .fontFamily('Microsoft YaHei') 169 } 170 .id('play') 171 .width('25%') 172 173 Column() { 174 Image($r('app.media.stop_playing')) 175 .objectFit(ImageFit.Cover) 176 .width(30) 177 .height(30) 178 .onClick(() => { 179 lottie.stop() 180 this.isPlaying = false 181 }) 182 183 Text($r('app.string.stop')) 184 .fontSize(14) 185 .fontColor($r('app.color.font_color')) 186 .fontWeight(FontWeight.Medium) 187 .opacity(BUTTON_OPACITY) 188 .margin({ top: 6 }) 189 .fontFamily('Microsoft YaHei') 190 } 191 .width('25%') 192 .id('suspend') 193 194 Column() { 195 Image($r('app.media.pause')) 196 .objectFit(ImageFit.Cover) 197 .width(30) 198 .height(30) 199 .onClick(() => { 200 lottie.pause() 201 this.isPlaying = false 202 }) 203 204 Text($r('app.string.pause')) 205 .fontSize(14) 206 .fontColor($r('app.color.font_color')) 207 .fontWeight(FontWeight.Medium) 208 .opacity(BUTTON_OPACITY) 209 .margin({ top: 6 }) 210 .fontFamily('Microsoft YaHei') 211 } 212 .width('25%') 213 .id('pause') 214 215 Column() { 216 Image($r('app.media.start')) 217 .width(30) 218 .height(30) 219 .objectFit(ImageFit.Fill) 220 .onClick(() => { 221 lottie.play() 222 this.isPlaying = true 223 }) 224 225 Text($r('app.string.start_play')) 226 .fontSize(14) 227 .fontColor($r('app.color.font_color')) 228 .fontWeight(FontWeight.Medium) 229 .opacity(BUTTON_OPACITY) 230 .margin({ top: 6 }) 231 .fontFamily('Microsoft YaHei') 232 } 233 .width('25%') 234 .id('startPlay') 235 } 236 237 Row() { 238 Column() { 239 Image($r('app.media.speed')) 240 .width(30) 241 .height(30) 242 .objectFit(ImageFit.Fill) 243 .bindMenu([ 244 { 245 value: '×1', 246 action: () => { 247 lottie.setSpeed(1) 248 } 249 }, 250 { 251 value: '×2', 252 action: () => { 253 lottie.setSpeed(2) 254 } 255 }, 256 { 257 value: '×3', 258 action: () => { 259 lottie.setSpeed(5) 260 } 261 } 262 ]) 263 264 Text($r('app.string.speed')) 265 .fontSize(14) 266 .fontColor($r('app.color.font_color')) 267 .fontWeight(FontWeight.Medium) 268 .opacity(BUTTON_OPACITY) 269 .margin({ top: 6 }) 270 .fontFamily('Microsoft YaHei') 271 } 272 .width('25%') 273 .id('speed') 274 275 Column() { 276 Image($r('app.media.forward')) 277 .width(30) 278 .height(30) 279 .objectFit(ImageFit.Fill) 280 .bindMenu([ 281 { 282 value: '正向', 283 action: () => { 284 lottie.setDirection(1) 285 } 286 }, 287 { 288 value: '反向', 289 action: () => { 290 lottie.setDirection(-1) 291 } 292 } 293 ]) 294 295 Text($r('app.string.play_order')) 296 .fontSize(14) 297 .fontColor($r('app.color.font_color')) 298 .fontWeight(FontWeight.Medium) 299 .opacity(BUTTON_OPACITY) 300 .margin({ top: 6 }) 301 .fontFamily('Microsoft YaHei') 302 } 303 .width('25%') 304 .id('playOrder') 305 306 Column() { 307 Image($r('app.media.ic_public_delete_filled')) 308 .width(30) 309 .height(30) 310 .onClick(() => { 311 if (this.animateItem !== null) { 312 lottie.destroy() 313 this.animateItem = null 314 } 315 }) 316 317 Text($r('app.string.destruction_animation')) 318 .fontSize(14) 319 .fontColor($r('app.color.font_color')) 320 .fontWeight(FontWeight.Medium) 321 .opacity(BUTTON_OPACITY) 322 .margin({ top: 6 }) 323 .fontFamily('Microsoft YaHei') 324 } 325 .width('25%') 326 .id('destroyAnimation') 327 } 328 .width('100%') 329 .justifyContent(FlexAlign.Start) 330 .margin({ top: 10 }) 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 promptAction.showToast({ 696 message: $r('app.string.use_ae_fps') 697 }); 698 } 699 }) 700 701 Text($r('app.string.float_integer')) 702 .fontSize(14) 703 .fontColor($r('app.color.font_color')) 704 .fontWeight(FontWeight.Medium) 705 .opacity(BUTTON_OPACITY) 706 .margin({ top: 6 }) 707 .fontFamily('Microsoft YaHei') 708 } 709 .width('50%') 710 } 711 } 712 .justifyContent(FlexAlign.SpaceEvenly) 713 .borderRadius(24) 714 .width('100%') 715 .height('100%') 716 .backgroundColor($r('app.color.tab_content_background')) 717 } 718 .tabBar($r('app.string.cycle')) 719 720 TabContent() { 721 Column() { 722 Row() { 723 Column() { 724 Image($r('app.media.destination')) 725 .width(30) 726 .height(30) 727 .bindMenu([ 728 { 729 value: '250帧时停止', 730 action: (() => { 731 if (this.animateItem !== null) { 732 this.animateItem.goToAndStop(250, true) 733 } 734 }) 735 }, 736 { 737 value: '5000ms时停止', 738 action: (() => { 739 if (this.animateItem !== null) { 740 this.animateItem.goToAndStop(5000, false) 741 } 742 }) 743 } 744 ]) 745 Text($r('app.string.animation_stop')) 746 .fontSize(14) 747 .fontColor($r('app.color.font_color')) 748 .fontWeight(FontWeight.Medium) 749 .opacity(BUTTON_OPACITY) 750 .margin({ top: 6 }) 751 .fontFamily('Microsoft YaHei') 752 } 753 .width('50%') 754 755 Column() { 756 Image($r('app.media.begin')) 757 .width(30) 758 .height(30) 759 .bindMenu([ 760 { 761 value: '从250帧开始播放', 762 action: (() => { 763 if (this.animateItem !== null) { 764 this.animateItem.goToAndPlay(250, true); 765 } 766 }) 767 }, 768 { 769 value: '从12000ms开始播放', 770 action: (() => { 771 if (this.animateItem !== null) { 772 this.animateItem.goToAndPlay(12000, false) 773 } 774 }) 775 } 776 ]) 777 778 Text($r('app.string.animation_play')) 779 .fontSize(14) 780 .fontColor($r('app.color.font_color')) 781 .fontWeight(FontWeight.Medium) 782 .opacity(BUTTON_OPACITY) 783 .margin({ top: 6 }) 784 .fontFamily('Microsoft YaHei') 785 } 786 .width('50%') 787 } 788 789 Row() { 790 Column() { 791 Image($r('app.media.refresh')) 792 .width(30) 793 .height(30) 794 .onClick(() => { 795 if (this.animateItem !== null) { 796 this.animateItem.resize() 797 } 798 }) 799 800 Text($r('app.string.refresh_animation')) 801 .fontSize(14) 802 .fontColor($r('app.color.font_color')) 803 .fontWeight(FontWeight.Medium) 804 .opacity(BUTTON_OPACITY) 805 .margin({ top: 6 }) 806 .fontFamily('Microsoft YaHei') 807 } 808 .width('50%') 809 810 Column() { 811 Image($r('app.media.destory')) 812 .width(30) 813 .height(30) 814 .onClick(() => { 815 if (this.animateItem !== null) { 816 this.animateItem.destroy(this.animateName) 817 this.animateItem = null 818 } 819 }) 820 821 Text($r('app.string.destruction_grunt_animation')) 822 .fontSize(14) 823 .fontColor($r('app.color.font_color')) 824 .fontWeight(FontWeight.Medium) 825 .opacity(BUTTON_OPACITY) 826 .margin({ top: 6 }) 827 .fontFamily('Microsoft YaHei') 828 } 829 .width('50%') 830 } 831 } 832 .justifyContent(FlexAlign.SpaceEvenly) 833 .borderRadius(24) 834 .width('100%') 835 .height('100%') 836 .backgroundColor($r('app.color.tab_content_background')) 837 } 838 .tabBar($r('app.string.playback_position')) 839 840 TabContent() { 841 Column() { 842 Row() { 843 Column() { 844 Image($r('app.media.addevent')) 845 .width(30) 846 .height(30) 847 .onClick(() => { 848 if (this.animateItem !== null) { 849 this.animateItem.addEventListener('loopComplete', this.callbackItem) 850 promptAction.showToast({ 851 message: 'grunt loopComplete' 852 }); 853 } 854 }) 855 856 Text($r('app.string.add_listen')) 857 .fontSize(14) 858 .fontColor($r('app.color.font_color')) 859 .fontWeight(FontWeight.Medium) 860 .opacity(BUTTON_OPACITY) 861 .margin({ top: 6 }) 862 .fontFamily('Microsoft YaHei') 863 } 864 .width('50%') 865 866 Column() { 867 Image($r('app.media.delete')) 868 .width(30) 869 .height(30) 870 .onClick(() => { 871 if (this.animateItem !== null) { 872 this.animateItem.stop() 873 } 874 }) 875 876 Text($r('app.string.delete_listen')) 877 .fontSize(14) 878 .fontColor($r('app.color.font_color')) 879 .fontWeight(FontWeight.Medium) 880 .opacity(BUTTON_OPACITY) 881 .margin({ top: 6 }) 882 .fontFamily('Microsoft YaHei') 883 } 884 .width('50%') 885 } 886 887 Row() { 888 Column() { 889 Image($r('app.media.addall')) 890 .width(30) 891 .height(30) 892 .onClick(() => { 893 if (this.animateItem !== null) { 894 this.animateItem.pause() 895 } 896 }) 897 898 Text($r('app.string.triggers_all_callbacks')) 899 .padding({ left: 5, right: 5 }) 900 .fontSize(14) 901 .fontColor($r('app.color.font_color')) 902 .fontWeight(FontWeight.Medium) 903 .opacity(BUTTON_OPACITY) 904 .margin({ top: 6 }) 905 .fontFamily('Microsoft YaHei') 906 } 907 .width('50%') 908 909 Column() { 910 Image($r("app.media.delete_all")) 911 .width(30) 912 .height(30) 913 .onClick(() => { 914 if (this.animateItem !== null) { 915 this.animateItem.play() 916 } 917 }) 918 919 Text($r('app.string.delete_all_Listen')) 920 .fontSize(14) 921 .fontColor($r('app.color.font_color')) 922 .fontWeight(FontWeight.Medium) 923 .opacity(BUTTON_OPACITY) 924 .margin({ top: 6 }) 925 .fontFamily('Microsoft YaHei') 926 } 927 .width('50%') 928 } 929 } 930 .justifyContent(FlexAlign.SpaceEvenly) 931 .borderRadius(24) 932 .width('100%') 933 .height('100%') 934 .backgroundColor($r('app.color.tab_content_background')) 935 } 936 .tabBar($r('app.string.listen')) 937 } 938 .vertical(true) 939 .scrollable(true) 940 .barMode(BarMode.Fixed) 941 .barWidth(100) 942 .barHeight(230) 943 .animationDuration(0) 944 .onChange((index: number) => { 945 Logger.info(TAG, index.toString()) 946 }) 947 .borderRadius(24) 948 .backgroundColor('#FFFFFF') 949 } 950 .width('100%') 951 .height(230) 952 .margin({ bottom: 8 }) 953 } 954 } 955 .scrollBar(BarState.Off) 956 .height('100%') 957 .padding({ left: 10, right: 10, bottom: '720px' }) 958 } 959 .alignItems(HorizontalAlign.Center) 960 .justifyContent(FlexAlign.Center) 961 .backgroundColor('#F1F3F5') 962 .width('100%') 963 .height('100%') 964 } 965}