| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- interface DList {
- id:number
- textContent:string
- time:string
- icon:Resource
- isPassed:Boolean
- isCurrent:Boolean
- }
- @Component
- export struct Time {
- @State list:DList[] = [
- {
- id: 1,
- textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。',
- time:'15:01',
- icon:$r('app.media.icon'),
- isPassed:true,
- isCurrent:false
- },
- {
- id: 2,
- textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
- time:'15:02',
- icon:$r('app.media.icon'),
- isPassed:false,
- isCurrent:true
- },
- {
- id: 3,
- textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。在页面内容很多时,若用户需快速定位,可拖拽滚动条,如下图所示。',
- time:'15:03',
- icon:$r('app.media.icon'),
- isPassed:false,
- isCurrent:false
- },
- {
- id: 4,
- textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
- time:'15:04',
- icon:$r('app.media.icon'),
- isPassed:false,
- isCurrent:false
- },
- {
- id: 5,
- textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
- time:'15:04',
- icon:$r('app.media.icon'),
- isPassed:false,
- isCurrent:false
- },
- {
- id: 6,
- textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
- time:'15:04',
- icon:$r('app.media.icon'),
- isPassed:false,
- isCurrent:false
- },
- {
- id: 7,
- textContent: '当列表项高度(宽度)超出屏幕高度(宽度)时,列表可以沿垂直(水平)方向滚动。',
- time:'15:04',
- icon:$r('app.media.icon'),
- isPassed:false,
- isCurrent:false
- },
- ]
- @State listLength:Number = this.list.length;
- build() {
- Column(){
- List(){
- ForEach(this.list,(item:DList)=>{
- ListItem(){
- Column(){
- Row(){
- Image(item.isPassed || item.isCurrent? $r('app.media.icon') : $r('app.media.icon'))
- .width(item.isCurrent?16:10)
- .height(item.isCurrent?16:10)
- .margin({right:item.isCurrent?8:5})
- Text(item.time)
- }.margin({left:item.isCurrent?-8:-5})
- Column(){
- Row(){
- Text(){
- Span(item.textContent)
- ImageSpan(item.icon)
- .width(20)
- .height(20)
- .verticalAlign(ImageSpanAlignment.BOTTOM)
- }
- }
- .padding({left:10})
- }
- .border({width:{left:item.id == this.listLength ? 0 : 1 },color:item.isPassed?'#e3bbbb':'#dddddd'})
- }
- .alignItems(HorizontalAlign.Start)
- .width('80%')
- .margin({bottom:10})
- }
- })
- }.alignListItem(ListItemAlign.Center)
- }
- }
- }
|