ENewspaperListDialog.ets
3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { NewspaperListBean, NewspaperListItemBean, NewspaperPositionItemBean } from 'wdBean'
@CustomDialog
export struct ENewspaperListDialog {
@State currentPageNum: string = '01'
controller: CustomDialogController
newspaperListBean: NewspaperListBean = {} as NewspaperListBean
build() {
Column() {
Row() {
Text(this.currentPageNum)
.fontSize($r('app.float.font_size_36'))
.fontColor($r('app.color.color_222222'))
Text('版')
.fontSize($r('app.float.font_size_16'))
.fontColor($r('app.color.color_222222'))
.margin({ bottom: 6 })
Image($r('app.media.icon_triangle_black'))
.width($r('app.float.border_radius_6'))
.height($r('app.float.border_radius_6'))
.margin({ left: 2, bottom: 6 })
}
.alignItems(VerticalAlign.Bottom)
.margin({ top: 25, left: 15 })
.alignSelf(ItemAlign.Start)
Image($r('app.media.line'))
.width('100%')
.height(6)
.margin({ top: 20, left: 16, right: 16 })
.objectFit(ImageFit.Contain)
List() {
ForEach(this.newspaperListBean?.list, (item: NewspaperListItemBean, index: number) => {
ForEach(item.items, (positionItem: NewspaperPositionItemBean, itemIndex: number) => {
ListItem() {
Column(){
if (itemIndex == 0) {
Text(item.pageNum + item.pageName)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_ED2800'))
.margin({ top: 16 })
.maxLines(1)
}
if (positionItem.shortTitle) {
Text(positionItem.shortTitle)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_222222'))
.margin({ top: 16 })
.maxLines(2)
}
if (positionItem.title) {
Text(positionItem.title)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.margin({ top: 16 })
.maxLines(2)
}
if (positionItem.downTitle) {
Text(positionItem.downTitle)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_222222'))
.margin({ top: 16 })
.maxLines(2)
}
if (positionItem.newsTxt) {
Text(positionItem.newsTxt)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_999999'))
.margin({ top: 16, bottom: 16 })
.maxLines(5)
}
}
.alignItems(HorizontalAlign.Start)
}
})
})
}
.width('100%')
.margin({ top: 16, left: 16, right: 16 })
.scrollBar(BarState.Off)
.divider({
strokeWidth: 1,
color: '#EDEDED'
})
.onScrollIndex((firstIndex: number) => {
this.updateCurrentPageNum(firstIndex)
})
}
.width('100%')
.height(674)
.backgroundColor(Color.White)
}
updateCurrentPageNum(firstIndex: number): void {
if (this.newspaperListBean.list && this.newspaperListBean.list.length > 0) {
let index = 0;
for (let itemBean of this.newspaperListBean.list) {
if (itemBean.items && itemBean.items.length > 0){
for (let item of itemBean.items){
index++
if (index == firstIndex){
this.currentPageNum = itemBean.pageNum
return
}
}
}
}
}
}
}