@@ -8,7 +8,7 @@ import '../../../ui/widgets/rounded_icon.dart';
88import '../../../model/bank_account.dart' ;
99import '../../../providers/currency_provider.dart' ;
1010import '../../../ui/device.dart' ;
11- import 'accounts_tab .dart' ;
11+ import '../../../ui/widgets/transaction_type_button .dart' ;
1212
1313class AccountsPieChart extends ConsumerWidget {
1414 const AccountsPieChart ({
@@ -24,7 +24,7 @@ class AccountsPieChart extends ConsumerWidget {
2424
2525 @override
2626 Widget build (BuildContext context, WidgetRef ref) {
27- final selectedAccountIndex = ref.watch (selectedAccountIndexProvider );
27+ final selectedIndex = ref.watch (selectedListIndexProvider );
2828 final currencyState = ref.watch (currencyStateNotifier);
2929 return SizedBox (
3030 height: 200 ,
@@ -37,7 +37,7 @@ class AccountsPieChart extends ConsumerWidget {
3737 centerSpaceRadius: 70 ,
3838 sectionsSpace: 0 ,
3939 borderData: FlBorderData (show: false ),
40- sections: showingSections (selectedAccountIndex ),
40+ sections: showingSections (selectedIndex ),
4141 pieTouchData: PieTouchData (
4242 touchCallback: (FlTouchEvent event, pieTouchResponse) {
4343 // expand category when tapped
@@ -46,7 +46,7 @@ class AccountsPieChart extends ConsumerWidget {
4646 pieTouchResponse.touchedSection == null ) {
4747 return ;
4848 }
49- ref.read (selectedAccountIndexProvider .notifier).state =
49+ ref.read (selectedListIndexProvider .notifier).state =
5050 pieTouchResponse.touchedSection! .touchedSectionIndex;
5151 },
5252 ),
@@ -55,30 +55,27 @@ class AccountsPieChart extends ConsumerWidget {
5555 Column (
5656 mainAxisSize: MainAxisSize .min,
5757 children: [
58- (selectedAccountIndex != - 1 )
59- ? RoundedIcon (
60- icon: accountIconList[
61- accounts[selectedAccountIndex].symbol] ??
62- Icons .swap_horiz_rounded,
63- backgroundColor: accountColorList[
64- accounts[selectedAccountIndex].color],
65- padding: const EdgeInsets .all (Sizes .sm),
66- )
67- : const SizedBox (),
58+ if (selectedIndex != - 1 )
59+ RoundedIcon (
60+ icon: accountIconList[accounts[selectedIndex].symbol] ??
61+ Icons .swap_horiz_rounded,
62+ backgroundColor:
63+ accountColorList[accounts[selectedIndex].color],
64+ padding: const EdgeInsets .all (Sizes .sm),
65+ ),
6866 Text (
69- (selectedAccountIndex != - 1 )
70- ? "${amounts [accounts [selectedAccountIndex ].id ]!.toStringAsFixed (2 )} ${currencyState .selectedCurrency .symbol }"
67+ (selectedIndex != - 1 )
68+ ? "${amounts [accounts [selectedIndex ].id ]!.toStringAsFixed (2 )} ${currencyState .selectedCurrency .symbol }"
7169 : "${total .toStringAsFixed (2 )} ${currencyState .selectedCurrency .symbol }" ,
7270 style: Theme .of (context).textTheme.headlineLarge? .copyWith (
73- color: ((selectedAccountIndex != - 1 &&
74- amounts[accounts[selectedAccountIndex].id]! >
75- 0 ) ||
76- (selectedAccountIndex == - 1 && total > 0 ))
71+ color: ((selectedIndex != - 1 &&
72+ amounts[accounts[selectedIndex].id]! > 0 ) ||
73+ (selectedIndex == - 1 && total > 0 ))
7774 ? green
7875 : red),
7976 ),
80- (selectedAccountIndex != - 1 )
81- ? Text (accounts[selectedAccountIndex ].name)
77+ (selectedIndex != - 1 )
78+ ? Text (accounts[selectedIndex ].name)
8279 : const Text ("Total" ),
8380 ],
8481 ),
0 commit comments