forked from Tencent/tdesign-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtd_fab_page.dart
More file actions
182 lines (170 loc) · 4.57 KB
/
td_fab_page.dart
File metadata and controls
182 lines (170 loc) · 4.57 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
178
179
180
181
182
import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import '../annotation/demo.dart';
import '../base/example_widget.dart';
class TDFabPage extends StatefulWidget {
const TDFabPage({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _TDFabPageState();
}
class _TDFabPageState extends State<TDFabPage> {
bool showBorder = false;
@override
Widget build(BuildContext context) {
return ExamplePage(title: tdTitle(), exampleCodeGroup: 'fab', children: [
ExampleModule(title: '组件类型', children: [
ExampleItem(desc: 'Icon Fab 纯图标悬浮按钮', builder: _buildPureIconFab),
ExampleItem(
desc: 'Icon Fab with Text 图标加文字悬浮按钮', builder: _buildTextFab)
]),
ExampleModule(title: '组件状态', children: [
ExampleItem(desc: 'Fab Theme 悬浮按钮主题', builder: _buildThemeFab),
ExampleItem(desc: 'Fab Shape 悬浮按钮形状', builder: _buildShapeFab),
ExampleItem(desc: 'Fab Size 悬浮按钮尺寸', builder: _buildSizeFab)
])
]);
}
@Demo(group: 'fab')
Widget _buildPureIconFab(BuildContext context) {
return _buildRowDemo([
const TDFab(
theme: TDFabTheme.primary,
)
]);
}
@Demo(group: 'fab')
Widget _buildTextFab(BuildContext context) {
return _buildRowDemo([
const TDFab(
theme: TDFabTheme.primary,
text: 'Floating',
)
]);
}
@Demo(group: 'fab')
Widget _buildThemeFab(BuildContext context) {
return _buildRowDemoWidthDescription([
{
'component': const TDFab(
theme: TDFabTheme.primary,
),
'desc': 'Primary'
},
{
'component': const TDFab(
theme: TDFabTheme.defaultTheme,
),
'desc': 'Default'
},
{
'component': const TDFab(
theme: TDFabTheme.light,
),
'desc': 'Light'
},
{
'component': const TDFab(
theme: TDFabTheme.danger,
),
'desc': 'Danger'
},
]);
}
@Demo(group: 'fab')
Widget _buildShapeFab(BuildContext context) {
return _buildRowDemoWidthDescription([
{
'component': const TDFab(
theme: TDFabTheme.primary,
shape: TDFabShape.circle,
),
'desc': 'Circle'
},
{
'component': const TDFab(
theme: TDFabTheme.primary,
shape: TDFabShape.square,
),
'desc': 'Square'
},
]);
}
@Demo(group: 'fab')
Widget _buildSizeFab(BuildContext context) {
return _buildRowDemoWidthDescription([
{
'component': const TDFab(
theme: TDFabTheme.primary,
size: TDFabSize.large,
),
'desc': 'Large'
},
{
'component': const TDFab(
theme: TDFabTheme.primary,
size: TDFabSize.medium,
),
'desc': 'Medium'
},
{
'component': const TDFab(
theme: TDFabTheme.primary,
size: TDFabSize.small,
),
'desc': 'Small'
},
{
'component': const TDFab(
theme: TDFabTheme.primary,
size: TDFabSize.extraSmall,
),
'desc': 'extraSmall'
},
]);
}
Widget _buildRowDemo(List<TDFab> fabs) {
return Padding(
padding: const EdgeInsets.only(
left: 16,
),
child: Row(
children: fabs
.map((fab) => Padding(
padding: const EdgeInsets.only(right: 80),
child: fab,
))
.toList(),
),
);
}
Widget _buildRowDemoWidthDescription(List<Map<String, dynamic>> fabs) {
return Padding(
padding: const EdgeInsets.only(left: 16, top: 4, right: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: fabs
.map(
(fab) => Padding(
padding: const EdgeInsets.only(right: 30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
// spacing: 24,
children: [
SizedBox(
height: 48,
child: Column(children: [fab['component']]),
),
const SizedBox(height: 24),
TDText(
fab['desc'],
style: const TextStyle(fontSize: 14),
)
],
),
),
)
.toList(),
),
);
}
}