Time.ets 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. interface DList {
  2. id:number
  3. textContent:string
  4. time:string
  5. icon:Resource
  6. isPassed:Boolean
  7. isCurrent:Boolean
  8. }
  9. @Component
  10. export struct Time {
  11. @State list:DList[] = [
  12. {
  13. id: 1,
  14. textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。',
  15. time:'15:01',
  16. icon:$r('app.media.icon'),
  17. isPassed:true,
  18. isCurrent:false
  19. },
  20. {
  21. id: 2,
  22. textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
  23. time:'15:02',
  24. icon:$r('app.media.icon'),
  25. isPassed:false,
  26. isCurrent:true
  27. },
  28. {
  29. id: 3,
  30. textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。',
  31. time:'15:03',
  32. icon:$r('app.media.icon'),
  33. isPassed:false,
  34. isCurrent:false
  35. },
  36. {
  37. id: 4,
  38. textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
  39. time:'15:04',
  40. icon:$r('app.media.icon'),
  41. isPassed:false,
  42. isCurrent:false
  43. },
  44. {
  45. id: 5,
  46. textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
  47. time:'15:04',
  48. icon:$r('app.media.icon'),
  49. isPassed:false,
  50. isCurrent:false
  51. },
  52. {
  53. id: 6,
  54. textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
  55. time:'15:04',
  56. icon:$r('app.media.icon'),
  57. isPassed:false,
  58. isCurrent:false
  59. },
  60. {
  61. id: 7,
  62. textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
  63. time:'15:04',
  64. icon:$r('app.media.icon'),
  65. isPassed:false,
  66. isCurrent:false
  67. },
  68. ]
  69. @State listLength:Number = this.list.length;
  70. build() {
  71. Column(){
  72. List(){
  73. ForEach(this.list,(item:DList)=>{
  74. ListItem(){
  75. Column(){
  76. Row(){
  77. Image(item.isPassed || item.isCurrent? $r('app.media.icon') : $r('app.media.icon'))
  78. .width(item.isCurrent?16:10)
  79. .height(item.isCurrent?16:10)
  80. .margin({right:item.isCurrent?8:5})
  81. Text(item.time)
  82. }.margin({left:item.isCurrent?-8:-5})
  83. Column(){
  84. Row(){
  85. Text(){
  86. Span(item.textContent)
  87. ImageSpan(item.icon)
  88. .width(20)
  89. .height(20)
  90. .verticalAlign(ImageSpanAlignment.BOTTOM)
  91. }
  92. }
  93. .padding({left:10})
  94. }
  95. .border({width:{left:item.id == this.listLength ? 0 : 1 },color:item.isPassed?'#e3bbbb':'#dddddd'})
  96. }
  97. .alignItems(HorizontalAlign.Start)
  98. .width('80%')
  99. .margin({bottom:10})
  100. }
  101. })
  102. }.alignListItem(ListItemAlign.Center)
  103. }
  104. }
  105. }