ErrorComponent.ets
1.7 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
import { CommonConstants } from 'wdConstant';
import { Logger } from 'wdKit';
const TAG = 'ErrorComponent';
/**
* failed失败/出错页面
*/
@Component
export struct ErrorComponent {
// private emptySize: SizeOptions = {};
@State emptyWidth: string | number = CommonConstants.FULL_PARENT;
@State emptyHeight: string | number = CommonConstants.FULL_PARENT;
/**
* The empty image width percentage setting.
*/
readonly EMPTY_IMAGE_WIDTH: string = '50%';
/**
* The empty image height percentage setting.
*/
readonly EMPTY_IMAGE_HEIGHT: string = '30%';
/**
* The empty data text component margin top.
*/
readonly EMPTY_TIP_TEXT_MARGIN_TOP: string = '2%';
/**
* The empty data text opacity.
*/
readonly TEXT_OPACITY: number = 0.4;
build() {
this.errorView();
}
/**
* 失败view
*/
@Builder
errorView() {
Column() {
// Image($r('app.media.ic_no_data'))
// .width(this.EMPTY_IMAGE_WIDTH)
// .height(this.EMPTY_IMAGE_HEIGHT)
// .objectFit(ImageFit.Contain)
// // .border({ width: 1, color: Color.Red, radius: 6 })
Text(this.buildFailedTip())
.fontSize($r('app.float.normal_text_size'))
.fontColor(Color.Black)
.fontWeight(FontWeight.Normal)
.opacity(this.TEXT_OPACITY)
.margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP })
.onClick((event: ClickEvent) => {
Logger.info(TAG, `errorView onClick event.source: ${event.source}`);
})
}
.justifyContent(FlexAlign.Center)
.width(this.emptyWidth)
.height(this.emptyHeight)
}
buildFailedTip(): Resource | string {
Logger.info(TAG, "buildFailedTip");
return $r('app.string.load_net_data_failed')
}
}