page_exception.dart
2.66 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
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/page_empty.dart';
import 'package:one_key/widgets/page_error.dart';
import 'package:one_key/widgets/page_loading.dart';
class ExceptionPage extends StatefulWidget {
final PageState pageState;
final VoidCallback callback;
final String emptyMsg;
final String emptyImg;
final String showMsg;
final Color defalutColor;
final String showText;
const ExceptionPage(
{Key key,
this.pageState = PageState.Loading,
this.callback,
this.emptyMsg = "数据为空",
this.emptyImg = 'bg_error',
this.showMsg = '',
this.defalutColor = MyColours.color_ffffff,
this.showText})
: super(key: key);
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return ExceptionPageState();
}
}
class ExceptionPageState extends State<ExceptionPage> {
@override
Widget build(BuildContext context) {
// TODO: implement build
Widget page = ErrorPage(
content: "哎呀~网络好像走失了呢",
callback: widget.callback,
);
switch (widget.pageState) {
case PageState.Loading:
page = LoadingPage(
defalutColor: widget.defalutColor, showMsg: widget.showMsg);
break;
case PageState.ConnectivityTimeOut:
page = ErrorPage(
content: "请求超时啦~刷新一下看看",
callback: widget.callback,
);
break;
case PageState.ConnectivityError:
page = ErrorPage(
content: "哎呀~网络好像走失了呢",
callback: widget.callback,
);
break;
case PageState.Empty:
page = EmptyPage(
content: widget.emptyMsg,
imgname: widget.emptyImg,
showText: widget.showText,
callback: widget.callback,
);
break;
case PageState.First:
page = Container(
width: 0,
height: 10,
color: Colors.white,
);
break;
case PageState.NoPermission:
page = ErrorPage(
content: "未获取到通讯录权限",
callback: widget.callback,
btnTitle: '开启权限',
);
break;
case PageState.Statics:
page = EmptyPage(
content: widget.emptyMsg,
imgname: widget.emptyImg,
bgcolor: MyColours.color_f5f5f5,
);
break;
default:
page = ErrorPage(
content: "哎呀~网络好像走失了呢",
callback: widget.callback,
);
break;
}
return page;
}
}