ImageAndTextPageComponent.ets
3.2 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
import { ContentDetailDTO } from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { ImageAndTextWebComponent } from './ImageAndTextWebComponent';
@Component
export struct ImageAndTextPageComponent {
scroller: Scroller = new Scroller();
@State relId: string= ''
@State contentId: string= ''
@State relType: string= ''
@State detailData: ContentDetailDTO = {} as ContentDetailDTO
build(){
RelativeContainer() {
RelativeContainer(){
Image($r('app.media.icon_ren_min_ri_bao'))
.width(70)
.height(28)
.alignRules({top:{anchor: "__container__", align: VerticalAlign.Top},
left:{anchor: "__container__", align: HorizontalAlign.Start}})
Text(this.detailData.publishTime)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize($r('app.float.font_size_13'))
.alignRules({top:{anchor: "__container__", align: VerticalAlign.Top},
right:{anchor: "__container__", align: HorizontalAlign.End}})
}
.width('100%')
.id('image_text_detail_top')
.alignRules({top:{anchor: "__container__", align: VerticalAlign.Top}})
Image($r('app.media.line'))
.width('100%')
.height(6)
.objectFit(ImageFit.Contain)
.id('image_text_detail_top_line')
.alignRules({top:{anchor: "image_text_detail_top", align: VerticalAlign.Bottom}})
.margin({top: 10})
Scroll(this.scroller) {
Column() {
ImageAndTextWebComponent({detailData: this.detailData})
}
.width('100%')
}
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.Off)
.alignRules({top:{anchor: "image_text_detail_top_line", align: VerticalAlign.Bottom}})
.id('image_text_detail_content')
RelativeContainer(){
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.alignRules({left:{anchor: "__container__", align: HorizontalAlign.Start},
center:{anchor: "__container__", align: VerticalAlign.Center}})
Row(){
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({left: 24})
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({left: 24})
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({left: 24})
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
.margin({left: 24})
}
.alignItems(VerticalAlign.Center)
.alignRules({right:{anchor: "__container__", align: HorizontalAlign.End},
center:{anchor: "__container__", align: VerticalAlign.Center}})
}
.width('100%')
.height(56)
.alignRules({bottom:{anchor: "__container__", align: VerticalAlign.Bottom}})
}
.width('100%')
.height('100%')
.padding({left: 16, right: 16})
.backgroundColor(Color.White)
}
async aboutToAppear() {
let detailBean = await DetailViewModel.getDetailPageData(this.relId, this.contentId, this.relType)
this.detailData = detailBean;
}
aboutToDisappear() {
}
}