Improved layout, fixed transaction popup
This commit is contained in:
@@ -96,22 +96,21 @@ class ChartBloc extends Bloc<ChartEvent, ChartState> {
|
||||
|
||||
ChartState _computeStateScopedStats(ChartState state) {
|
||||
double globalTotal = 0;
|
||||
double scoppedTotal = 0;
|
||||
List<ChartItem> scopedCategoriesPositiveTotals = [];
|
||||
List<ChartItem> scopedCategoriesNegativeTotals = [];
|
||||
Map<int, FlSpot> scopedMonthlyTotals = {};
|
||||
Map<int, Map<String, double>> scopedCategoriesMonthlyTotals = {};
|
||||
|
||||
for(var transaction in state.transactions) {
|
||||
double subTotal = globalTotal + transaction.value;
|
||||
globalTotal = subTotal;
|
||||
globalTotal += transaction.value;
|
||||
double subTotal = globalTotal;
|
||||
|
||||
if (transaction.date.year != state.currentYear) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state.accountsTotals.containsKey(transaction.category)) {
|
||||
continue;
|
||||
}
|
||||
scoppedTotal += transaction.value;
|
||||
|
||||
TransactionLine transactionLine = TransactionLine(transaction: transaction, subTotal: subTotal);
|
||||
|
||||
@@ -155,7 +154,6 @@ class ChartBloc extends Bloc<ChartEvent, ChartState> {
|
||||
a?[transaction.category] = transaction.value.abs() + (a[transaction.category] ?? 0);
|
||||
scopedCategoriesMonthlyTotals[transaction.date.month] = a!;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<ChartItem> scopedCategoriesPositiveTotalsPercents = [];
|
||||
@@ -205,6 +203,7 @@ class ChartBloc extends Bloc<ChartEvent, ChartState> {
|
||||
scopedSimplifiedCategoriesNegativeTotalsPercents.sort((a, b) => a.value.compareTo(b.value));
|
||||
|
||||
return state.copyWith(
|
||||
scoppedProfit: scoppedTotal,
|
||||
scopedCategoriesPositiveTotals: scopedCategoriesPositiveTotals,
|
||||
scopedCategoriesPositiveTotalsPercents: scopedCategoriesPositiveTotalsPercents,
|
||||
scopedCategoriesNegativeTotals: scopedCategoriesNegativeTotals,
|
||||
|
||||
@@ -29,6 +29,8 @@ final class ChartState extends Equatable {
|
||||
final List<FlSpot> scopedMonthlyTotals;
|
||||
final Map<int, Map<String, double>> scopedCategoriesMonthlyTotals;
|
||||
|
||||
final double scoppedProfit;
|
||||
|
||||
const ChartState({
|
||||
this.transactions = const [],
|
||||
this.transactionsLines = const [],
|
||||
@@ -50,6 +52,7 @@ final class ChartState extends Equatable {
|
||||
this.scopedSimplifiedCategoriesNegativeTotalsPercents = const [],
|
||||
this.scopedMonthlyTotals = const [],
|
||||
this.scopedCategoriesMonthlyTotals = const {},
|
||||
this.scoppedProfit = 0,
|
||||
});
|
||||
|
||||
ChartState copyWith({
|
||||
@@ -73,6 +76,7 @@ final class ChartState extends Equatable {
|
||||
List<ChartItem>? scopedSimplifiedCategoriesNegativeTotalsPercents,
|
||||
List<FlSpot>? scopedMonthlyTotals,
|
||||
Map<int, Map<String, double>>? scopedCategoriesMonthlyTotals,
|
||||
double? scoppedProfit,
|
||||
}) {
|
||||
return ChartState(
|
||||
transactions: transactions ?? this.transactions,
|
||||
@@ -95,6 +99,7 @@ final class ChartState extends Equatable {
|
||||
scopedSimplifiedCategoriesNegativeTotalsPercents: scopedSimplifiedCategoriesNegativeTotalsPercents ?? this.scopedSimplifiedCategoriesNegativeTotalsPercents,
|
||||
scopedMonthlyTotals: scopedMonthlyTotals ?? this.scopedMonthlyTotals,
|
||||
scopedCategoriesMonthlyTotals: scopedCategoriesMonthlyTotals ?? this.scopedCategoriesMonthlyTotals,
|
||||
scoppedProfit: scoppedProfit ?? this.scoppedProfit,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,6 +123,7 @@ final class ChartState extends Equatable {
|
||||
scopedSimplifiedCategoriesNegativeTotalsPercents,
|
||||
scopedMonthlyTotals,
|
||||
scopedCategoriesMonthlyTotals,
|
||||
scoppedProfit,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user