forked from Tencent/tdesign-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtd_cell_page.dart
More file actions
174 lines (167 loc) · 5.33 KB
/
td_cell_page.dart
File metadata and controls
174 lines (167 loc) · 5.33 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
import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import '../../base/example_widget.dart';
import '../annotation/demo.dart';
class TDCellPage extends StatelessWidget {
const TDCellPage({super.key});
@override
Widget build(BuildContext context) {
return ExamplePage(
title: tdTitle(context),
desc: '一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容。',
exampleCodeGroup: 'cell',
children: const [
ExampleModule(title: '组件类型', children: [
ExampleItem(desc: '单行单元格', builder: _buildSimple),
ExampleItem(desc: '多行单元格', builder: _buildDesSimple),
]),
ExampleModule(title: '组件样式', children: [
ExampleItem(desc: '卡片单元格', builder: _buildCard),
]),
],
test: const [
ExampleItem(desc: '自定义内边距-padding', builder: _buildPadding),
ExampleItem(desc: '长标题、内容,指定note宽度', builder: _buildTestContent),
],
);
}
}
@Demo(group: 'cell')
Widget _buildSimple(BuildContext context) {
// 可统一修改样式
var style = TDCellStyle(context: context);
return TDCellGroup(
style: style,
cells: [
// 可单独修改样式
TDCell(
arrow: true,
title: '单行标题',
style: TDCellStyle.cellStyle(context),
),
TDCell(
arrow: true,
title: '单行标题',
required: true,
onClick: (cell) {
print('单行标题');
},
onLongPress: (cell) {
print('onLongPress 单行标题');
},
),
const TDCell(
arrow: true,
title: '单行标题',
noteWidget: TDBadge(TDBadgeType.message, count: '8'),
),
const TDCell(
arrow: false,
title: '单行标题',
rightIconWidget: TDSwitch(isOn: true),
),
const TDCell(
arrow: true,
title: '单行标题',
note: '辅助信息',
),
const TDCell(
arrow: true,
title: '单行标题',
leftIcon: TDIcons.lock_on,
),
const TDCell(arrow: false, title: '单行标题'),
],
);
}
@Demo(group: 'cell')
Widget _buildDesSimple(BuildContext context) {
return const TDCellGroup(
cells: [
TDCell(arrow: true, title: '单行标题', description: '一段很长很长的内容文字'),
TDCell(
arrow: true,
title: '单行标题',
description: '一段很长很长的内容文字',
required: true),
TDCell(
arrow: true,
title: '单行标题',
description: '一段很长很长的内容文字',
noteWidget: TDBadge(TDBadgeType.message, count: '8')),
TDCell(
arrow: false,
title: '单行标题',
description: '一段很长很长的内容文字',
rightIconWidget: TDSwitch(isOn: true)),
TDCell(
arrow: true, title: '单行标题', description: '一段很长很长的内容文字', note: '辅助信息'),
TDCell(
arrow: true,
title: '单行标题',
description: '一段很长很长的内容文字一段很长很长的内容文字一段很长很长的内',
leftIcon: TDIcons.lock_on),
TDCell(
arrow: false,
title: '单行标题',
description: '一段很长很长的内容文字一段很长很长的内容文字一段很长很长的内'),
TDCell(
arrow: false,
title: '多行高度不定,长文本自动换行,该选项的描述是一段很长的内容',
description: '一段很长很长的内容文字一段很长很长的内容文字一段很长很长的内'),
TDCell(
arrow: true,
title: '多行带头像',
description: '一段很长很长的内容文字一段很长很长的内容文字一段很长很长的内容',
image: AssetImage('assets/img/td_avatar_1.png'),
),
// NetworkImage('https://tdesign.gtimg.com/mobile/demos/avatar1.png')),
TDCell(
arrow: true,
title: '多行带图片',
description: '一段很长很长的内容文字',
image: AssetImage('assets/img/image.png'),
imageCircle: 8,
),
],
);
}
@Demo(group: 'cell')
Widget _buildCard(BuildContext context) {
return const TDCellGroup(
theme: TDCellGroupTheme.cardTheme,
cells: [
TDCell(arrow: true, title: '单行标题'),
TDCell(arrow: true, title: '单行标题', required: true),
TDCell(arrow: true, title: '单行标题'),
],
);
}
@Demo(group: 'cell')
Widget _buildPadding(BuildContext context) {
var style = TDCellStyle(context: context);
style.padding = const EdgeInsets.all(30);
return TDCellGroup(
theme: TDCellGroupTheme.cardTheme,
cells: [
TDCell(
arrow: true,
title: 'padding-all-30',
style: style,
onClick: (cell) {
print('padding-all-30');
},
),
],
);
}
@Demo(group: 'cell')
Widget _buildTestContent(BuildContext context) {
return const TDCell(
title: '这是标题,非常长的标题',
note: '这是一个很长很长的note字段,测试长内容,你说这内容长不长!',
noteMaxLine: 2,
noteMaxWidth: 200,
arrow: true,
);
}