CueComptent.ets 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import { common } from '@kit.AbilityKit';
  2. import { CommonConstants } from '../common/constants/CommonConstants';
  3. import { VideoItem } from '../viewmodel/VideoItem';
  4. import { ArrayUtil, FileUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
  5. import MediaTable from '../common/util/MediaTable';
  6. import { taskpool } from '@kit.ArkTS';
  7. import { CueTrack, millisecondsToTime } from '../common/util/CueUtils';
  8. // 批量删除
  9. @Component
  10. export struct CueComptent {
  11. @Prop title: string = ''
  12. @Prop isLongNameRoLL: boolean = true
  13. @State curIndex:number = -1
  14. onDoItemClick = (item: CueTrack, index: number) => {
  15. }
  16. onCancel = () => {
  17. }
  18. @Prop cueTracks: CueTrack[]
  19. @StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
  20. context = this.getUIContext().getHostContext() as common.UIAbilityContext
  21. async aboutToAppear() {
  22. }
  23. build() {
  24. Column() {
  25. Row(){
  26. Text(this.title).fontSize(16)
  27. .margin({ left: 25 })
  28. .maxLines(1)
  29. .layoutWeight(1)
  30. .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
  31. Button({ type: ButtonType.Circle, stateEffect: true }){
  32. Image($r('app.media.close'))
  33. .fillColor($r('app.color.text_color'))
  34. .width(28)
  35. .height(28)
  36. }
  37. .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.8 })
  38. .fontSize(13)
  39. .width(35)
  40. .padding({left:5})
  41. .margin({ right: 18 })
  42. .onClick(() => {
  43. this.onCancel()
  44. })
  45. .backgroundColor(Color.Transparent)
  46. }
  47. .margin({ top: 20, bottom: 10 })
  48. .height(38)
  49. this.getListView()
  50. }
  51. .backgroundColor($r('app.color.start_window_background'))
  52. .backgroundBlurStyle(BlurStyle.Regular)
  53. .height('90%')
  54. .width('100%')
  55. }
  56. @Builder
  57. getListView() {
  58. List() {
  59. ForEach(this.cueTracks, (item: CueTrack, index: number) => {
  60. ListItem() {
  61. Button({ type: ButtonType.Normal, stateEffect: true }) {
  62. Row() {
  63. Row(){
  64. SymbolGlyph($r('sys.symbol.media_center'))
  65. .fontColor([this.themeColor])
  66. .fontSize(25)
  67. .effectStrategy(1)
  68. Text(item.title || 'Unknown Title')
  69. .fontSize(14)
  70. .padding({ left: 6 })
  71. .fontColor(this.curIndex==index?this.themeColor:$r('app.color.text_color'))
  72. .maxLines(1)
  73. .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
  74. Text(item.performer || '')
  75. .fontSize(11)
  76. .padding({ left: 8 })
  77. .fontColor(this.curIndex==index?this.themeColor:Color.Gray)
  78. .maxLines(1)
  79. .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
  80. }
  81. .layoutWeight(1)
  82. .margin({ left: 10 })
  83. Blank()
  84. Text(millisecondsToTime(item.duration||0))
  85. .fontSize(14)
  86. .margin({ right: 10 })
  87. .fontColor(Color.Gray)
  88. }
  89. }
  90. .backgroundColor(Color.Transparent)
  91. .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
  92. .transition(TransitionEffect.move(TransitionEdge.BOTTOM).animation({ duration: 600, curve: Curve.Ease, delay: 60*index }))
  93. .width('100%')
  94. .height(50)
  95. .padding({ left: 15, right: 15 })
  96. .onClick(() => {
  97. this.curIndex=index
  98. this.onDoItemClick(item, index)
  99. })
  100. }
  101. }) // 使用唯一标识符作为key
  102. }
  103. .layoutWeight(1)
  104. .borderRadius(20)
  105. .scrollBar(BarState.Off)
  106. .divider({
  107. strokeWidth: 0.2,
  108. color: Color.Gray,
  109. startMargin: 25,
  110. endMargin: 25
  111. })
  112. }
  113. }