state_layout.dart
1.71 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
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:Parlando/res/resources.dart';
import 'package:Parlando/util/theme_utils.dart';
import 'package:Parlando/widgets/load_image.dart';
/// design/9暂无状态页面/index.html#artboard3
class StateLayout extends StatelessWidget {
const StateLayout({Key? key, required this.type, this.hintText})
: super(key: key);
final StateType type;
final String? hintText;
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
if (type == StateType.loading)
const CupertinoActivityIndicator(radius: 16.0)
else
if (type != StateType.empty)
Opacity(
opacity: context.isDark ? 0.5 : 1,
child: LoadAssetImage(
'state/${type.img}',
width: 120,
),
),
const SizedBox(width: double.infinity, height: Dimens.gap_dp16,),
Text(
hintText ?? type.hintText,
style: Theme.of(context).textTheme.subtitle2?.copyWith(fontSize: Dimens.font_sp14),
),
Gaps.vGap50,
],
);
}
}
enum StateType {
/// 订单
order,
/// 商品
goods,
/// 无网络
network,
/// 消息
message,
/// 无提现账号
account,
/// 加载中
loading,
/// 空
empty
}
extension StateTypeExtension on StateType {
String get img => <String>[
'zwdd', 'zwsp',
'zwwl', 'zwxx',
'zwzh', '', '']
[index];
String get hintText => <String>[
'暂无订单', '暂无商品',
'无网络连接', '暂无消息',
'马上添加提现账号吧', '', ''
][index];
}