forked from ikicodedev/calendar_timeline
/
year_item.dart
49 lines (45 loc) · 1.37 KB
/
year_item.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
import 'package:flutter/material.dart';
/// Creates a Widget to represent the years. By default it will show the smaller version
/// in the months row. If [small] is set to false it will show the bigger version for the
/// years row. In the smaller version the [onTap] property is not available
class YearItem extends StatelessWidget {
final String name;
final Function onTap;
final bool isSelected;
final Color? color;
final bool small;
final bool shrink;
YearItem({
required this.name,
required this.onTap,
this.isSelected = false,
this.small = true,
this.color,
required this.shrink,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: small ? null : onTap as void Function()?,
child: Container(
decoration: isSelected || small
? BoxDecoration(
border: Border.all(color: color ?? Colors.black87, width: 1),
borderRadius: BorderRadius.circular(4),
)
: null,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 5.0),
child: Text(
name.toUpperCase(),
style: TextStyle(
fontSize: shrink ? 9 : small ? 12 : 20,
color: color ?? Colors.black87,
fontWeight: FontWeight.bold,
),
),
),
),
);
}
}