Feat: Fügt Benachrichtigungen für nicht überprüfte Transaktionen hinzu
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:drift/drift.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:routemaster/routemaster.dart';
|
||||
|
||||
import '../Entities/drift_database.dart';
|
||||
import '../Pages/Dialog/dialog_action.dart';
|
||||
@@ -13,6 +14,8 @@ import '../Pages/Dialog/dialog_input_field_type_enum.dart';
|
||||
import '../Pages/Dialog/dialog_type_enum.dart';
|
||||
import '../Pages/Dialog/dynamic_dialog.dart';
|
||||
import '../Repositories/transaction_repository.dart';
|
||||
import '../Services/navigation_service.dart';
|
||||
import '../Services/transaction_service.dart';
|
||||
import 'account_controller.dart';
|
||||
import 'port_controller.dart';
|
||||
|
||||
@@ -72,13 +75,31 @@ class TransactionController {
|
||||
});
|
||||
|
||||
if (!kIsWeb) {
|
||||
final ReceivePort receivePort = ReceivePort()
|
||||
final ReceivePort updateTransactionsReceivePort = ReceivePort()
|
||||
..listen((_) {
|
||||
Logger().i('Received update-transactions signal');
|
||||
unawaited(updateTransactions());
|
||||
});
|
||||
|
||||
PortController().addPort(receivePort.sendPort, 'update-transactions');
|
||||
PortController().addPort(
|
||||
updateTransactionsReceivePort.sendPort,
|
||||
'update-transactions',
|
||||
);
|
||||
|
||||
final ReceivePort gotToTransactionsReceivePort = ReceivePort()
|
||||
..listen((final value) {
|
||||
Logger().i('Received go-to-transactions signal');
|
||||
|
||||
final List<Transaction> transactions =
|
||||
TransactionService.transactionsFromString(value);
|
||||
|
||||
goToTransactions(transactions: transactions);
|
||||
});
|
||||
|
||||
PortController().addPort(
|
||||
gotToTransactionsReceivePort.sendPort,
|
||||
'go-to-transactions',
|
||||
);
|
||||
}
|
||||
|
||||
unawaited(updateTransactions());
|
||||
@@ -121,6 +142,21 @@ class TransactionController {
|
||||
}
|
||||
}
|
||||
|
||||
/// Wechselt zur Übersicht über die Transaktionen
|
||||
void goToTransactions({final List<Transaction>? transactions}) {
|
||||
final BuildContext? context = NavigationService.getCurrentBuildContext();
|
||||
|
||||
if (context != null && transactions != null) {
|
||||
if (transactions.length == 1) {
|
||||
Routemaster.of(
|
||||
context,
|
||||
).push('/trend', queryParameters: {'name': transactions.first.name});
|
||||
}
|
||||
|
||||
Routemaster.of(context).replace('/trend');
|
||||
}
|
||||
}
|
||||
|
||||
/// Startet den Prozess, um eine neue Transaktion anzulegen
|
||||
void newTransactionHandler() {
|
||||
unawaited(_newTransactionDialog?.show());
|
||||
|
||||
Reference in New Issue
Block a user