fix: show correct indicator on pie chart

This commit is contained in:
Matyáš Caras 2024-02-26 23:26:11 +01:00
parent af04accabf
commit bd17e12e1b
Signed by untrusted user who does not match committer: hernik
GPG key ID: 2A3175F98820C5C6

View file

@ -428,11 +428,39 @@ class _CategoriesPieChartState extends State<CategoriesPieChart> {
(index) => Padding(
padding: const EdgeInsets.all(8),
child: Indicator(
size: touchedIndex == index ? 18 : 16,
size: (touchedIndex != -1 &&
touchedIndex ==
widget.categories
.where(
(element) => widget.entries
.where(
(w) =>
w.category.id ==
element
.id, // TODO: more elegant fix
)
.isNotEmpty,
)
.toList()
.indexOf(widget.categories[index]))
? 18
: 16,
color: widget.categories[index].color,
text: widget.categories[index].name,
textStyle: TextStyle(
fontWeight: (touchedIndex == index)
fontWeight: (touchedIndex != -1 &&
touchedIndex ==
widget.categories
.where(
(element) => widget.entries
.where(
(w) =>
w.category.id == element.id,
)
.isNotEmpty,
)
.toList()
.indexOf(widget.categories[index]))
? FontWeight.bold
: FontWeight.normal,
),