click_item.dart
1.86 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
import 'package:flutter/material.dart';
import 'package:Parlando/res/resources.dart';
class ClickItem extends StatelessWidget {
const ClickItem({
Key? key,
this.onTap,
required this.title,
this.content = '',
this.textAlign = TextAlign.start,
this.maxLines = 1
}): super(key: key);
final GestureTapCallback? onTap;
final String title;
final String content;
final TextAlign textAlign;
final int maxLines;
@override
Widget build(BuildContext context) {
Widget child = Row(
//为了数字类文字居中
crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
children: <Widget>[
Text(title),
const Spacer(),
Gaps.hGap16,
Expanded(
flex: 4,
child: Text(
content,
maxLines: maxLines,
textAlign: maxLines == 1 ? TextAlign.right : textAlign,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.subtitle2?.copyWith(fontSize: Dimens.font_sp14),
),
),
Gaps.hGap8,
Opacity(
// 无点击事件时,隐藏箭头图标
opacity: onTap == null ? 0 : 1,
child: Padding(
padding: EdgeInsets.only(top: maxLines == 1 ? 0.0 : 2.0),
child: Images.arrowRight,
),
)
],
);
/// 分隔线
child = Container(
margin: const EdgeInsets.only(left: 15.0),
padding: const EdgeInsets.fromLTRB(0, 15.0, 15.0, 15.0),
constraints: const BoxConstraints(
minHeight: 50.0,
),
width: double.infinity,
decoration: BoxDecoration(
border: Border(
bottom: Divider.createBorderSide(context, width: 0.6),
),
),
child: child,
);
return InkWell(
onTap: onTap,
child: child,
);
}
}