forked from Tencent/tdesign-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtd_result_page.dart
More file actions
177 lines (163 loc) · 4.97 KB
/
td_result_page.dart
File metadata and controls
177 lines (163 loc) · 4.97 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import '../../base/example_widget.dart';
import '../annotation/demo.dart';
class TDResultPage extends StatelessWidget {
const TDResultPage({super.key});
@override
Widget build(BuildContext context) {
return ExamplePage(
title: 'Result 结果',
desc: '反馈结果状态。',
exampleCodeGroup: 'result',
children: [
ExampleModule(title: '组件类型', children: [
ExampleItem(
desc: '基础结果', ignoreCode: true, builder: _buildBasicResult),
ExampleItem(
desc: '带描述的结果',
ignoreCode: true,
builder: _buildResultWithDescription),
ExampleItem(desc: '自定义结果', builder: _buildCustomResultContent),
ExampleItem(
desc: '页面示例', ignoreCode: true, builder: _buildPageExample),
]),
],
);
}
Widget _buildBasicResult(BuildContext context) {
return Column(
// spacing: 32,
children: [
CodeWrapper(builder: _buildBasicResultSuccess),
const SizedBox(height: 32),
CodeWrapper(builder: _buildBasicResultError),
const SizedBox(height: 32),
CodeWrapper(builder: _buildBasicResultWarning),
const SizedBox(height: 32),
CodeWrapper(builder: _buildBasicResultDefault),
],
);
}
Widget _buildResultWithDescription(BuildContext context) {
return Column(
// spacing: 32,
children: [
CodeWrapper(builder: _buildResultWithDescriptionSuccess),
const SizedBox(height: 32),
CodeWrapper(builder: _buildResultWithDescriptionError),
const SizedBox(height: 32),
CodeWrapper(builder: _buildResultWithDescriptionWarning),
const SizedBox(height: 32),
CodeWrapper(builder: _buildResultWithDescriptionDefault),
],
);
}
Widget _buildPageExample(BuildContext context) {
return TDButton(
text: '页面示例跳转',
theme: TDButtonTheme.primary,
size: TDButtonSize.large,
isBlock: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
title: const Text('Result 结果'),
),
body: Column(
// spacing: 48,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const TDResult(
title: '成功状态',
theme: TDResultTheme.success,
description: '描述文字',
),
const SizedBox(height: 48),
TDButton(
text: '返回',
theme: TDButtonTheme.primary,
size: TDButtonSize.large,
isBlock: true,
onTap: () => Navigator.pop(context),
),
],
),
),
),
);
},
);
}
@Demo(group: 'result')
TDResult _buildBasicResultSuccess(BuildContext context) {
return const TDResult(
title: '成功状态',
theme: TDResultTheme.success,
);
}
@Demo(group: 'result')
TDResult _buildBasicResultError(BuildContext context) {
return const TDResult(
title: '失败状态',
theme: TDResultTheme.error,
);
}
@Demo(group: 'result')
TDResult _buildBasicResultWarning(BuildContext context) {
return const TDResult(
title: '警示状态',
theme: TDResultTheme.warning,
);
}
@Demo(group: 'result')
TDResult _buildBasicResultDefault(BuildContext context) {
return const TDResult(
title: '默认状态',
theme: TDResultTheme.defaultTheme,
);
}
@Demo(group: 'result')
TDResult _buildResultWithDescriptionSuccess(BuildContext context) {
return const TDResult(
title: '成功状态',
theme: TDResultTheme.success,
description: '描述文字',
);
}
@Demo(group: 'result')
TDResult _buildResultWithDescriptionError(BuildContext context) {
return const TDResult(
title: '失败状态',
theme: TDResultTheme.error,
description: '描述文字',
);
}
@Demo(group: 'result')
TDResult _buildResultWithDescriptionWarning(BuildContext context) {
return const TDResult(
title: '警示状态',
theme: TDResultTheme.warning,
description: '描述文字',
);
}
@Demo(group: 'result')
TDResult _buildResultWithDescriptionDefault(BuildContext context) {
return const TDResult(
title: '默认状态',
theme: TDResultTheme.defaultTheme,
description: '描述文字',
);
}
@Demo(group: 'result')
TDResult _buildCustomResultContent(BuildContext context) {
return TDResult(
title: '自定义结果',
icon: Image.asset('assets/img/illustration.png'),
description: '描述文字',
);
}
}