-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
bullet_list.dart
115 lines (107 loc) · 3.04 KB
/
bullet_list.dart
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
import 'package:flutter/material.dart';
import 'package:shiori/domain/extensions/iterable_extensions.dart';
import 'styles.dart';
class BulletList extends StatelessWidget {
final List<String> items;
final IconData icon;
final double iconSize;
final Widget Function(int)? iconResolver;
final double fontSize;
final Function(int)? onDelete;
final EdgeInsets padding;
final bool addTooltip;
const BulletList({
Key? key,
required this.items,
this.icon = Icons.fiber_manual_record,
this.iconSize = 15,
this.iconResolver,
this.fontSize = 11,
this.onDelete,
this.padding = Styles.edgeInsetAll5,
this.addTooltip = true,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: items
.mapIndex(
(e, index) => _ListItem(
index: index,
title: e,
icon: icon,
fontSize: fontSize,
iconSize: iconSize,
iconResolver: iconResolver,
onDelete: onDelete,
padding: padding,
addTooltip: addTooltip,
),
)
.toList(),
);
}
}
class _ListItem extends StatelessWidget {
final int index;
final String title;
final IconData icon;
final double iconSize;
final Widget Function(int)? iconResolver;
final double fontSize;
final Function(int)? onDelete;
final EdgeInsets padding;
final bool addTooltip;
const _ListItem({
Key? key,
required this.index,
required this.title,
required this.icon,
required this.iconSize,
this.iconResolver,
required this.fontSize,
this.onDelete,
required this.padding,
required this.addTooltip,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: padding,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (iconResolver != null) iconResolver!(index) else Icon(icon, size: iconSize),
Expanded(
child: addTooltip
? Tooltip(
message: title,
child: Container(
margin: const EdgeInsets.only(left: 5),
child: Text(
title,
style: theme.textTheme.bodyText2!.copyWith(fontSize: fontSize),
),
),
)
: Container(
margin: const EdgeInsets.only(left: 5),
child: Text(
title,
style: theme.textTheme.bodyText2!.copyWith(fontSize: fontSize),
),
),
),
if (onDelete != null)
InkWell(
customBorder: const CircleBorder(),
child: Icon(Icons.delete, size: iconSize),
onTap: () => onDelete!(index),
),
],
),
);
}
}