diff --git a/lib/providers/duniter_indexer.dart b/lib/providers/duniter_indexer.dart index 8076d26..f979250 100644 --- a/lib/providers/duniter_indexer.dart +++ b/lib/providers/duniter_indexer.dart @@ -15,6 +15,7 @@ class DuniterIndexer with ChangeNotifier { List listIndexerEndpoints = []; bool isLoadingIndexer = false; bool hasNextPage = false; + Future?> Function()? refetch; void reload() { notifyListeners(); diff --git a/lib/screens/activity.dart b/lib/screens/activity.dart index 390fc99..bc40dc4 100644 --- a/lib/screens/activity.dart +++ b/lib/screens/activity.dart @@ -32,13 +32,12 @@ class _ActivityScreenState extends State { @override Widget build(BuildContext context) { - Provider.of(context, listen: true); + final duniterIndexer = Provider.of(context, listen: true); return PopScope( - // onPopInvoked: (_) { - // duniterIndexer.fetchMoreCursor = - // duniterIndexer.pageInfo = duniterIndexer.transBC = null; - // }, + onPopInvoked: (_) { + duniterIndexer.refetch = duniterIndexer.transBC = null; + }, child: Scaffold( appBar: AppBar( elevation: 0, diff --git a/lib/widgets/certs_list.dart b/lib/widgets/certs_list.dart index 3c06680..a9eb820 100644 --- a/lib/widgets/certs_list.dart +++ b/lib/widgets/certs_list.dart @@ -97,21 +97,25 @@ class CertsList extends StatelessWidget { // Build history list return SizedBox( height: windowHeight, - child: ListView( - key: keyListTransactions, - children: [ - result.data == null - ? Column(children: [ - ScaledSizedBox(height: 50), - Text( - "noTransactionToDisplay".tr(), - style: scaledTextStyle(fontSize: 18), - ) - ]) - : Column(children: [ - CertTile(listCerts: listCerts), - ]) - ], + child: RefreshIndicator( + color: orangeC, + onRefresh: () async => refetch!.call(), + child: ListView( + key: keyListTransactions, + children: [ + result.data == null + ? Column(children: [ + ScaledSizedBox(height: 50), + Text( + "noTransactionToDisplay".tr(), + style: scaledTextStyle(fontSize: 18), + ) + ]) + : Column(children: [ + CertTile(listCerts: listCerts), + ]) + ], + ), ), ); }, diff --git a/lib/widgets/history_query.dart b/lib/widgets/history_query.dart index 35b360c..3820e10 100644 --- a/lib/widgets/history_query.dart +++ b/lib/widgets/history_query.dart @@ -64,6 +64,7 @@ class HistoryQuery extends StatelessWidget { }, ), builder: (QueryResult result, {fetchMore, refetch}) { + duniterIndexer.refetch = refetch; if (result.isLoading && result.data == null) { return const Center( child: CircularProgressIndicator( @@ -119,25 +120,27 @@ class HistoryQuery extends StatelessWidget { return NotificationListener( child: Builder( builder: (context) => Expanded( - child: ListView( - key: keyListTransactions, - controller: scrollController, - children: [ - if (transactionId != null) - TransactionInProgressTule( - address: address, transactionId: transactionId), - HistoryView( - result: result, - address: address, - ) - ], + child: RefreshIndicator( + color: orangeC, + onRefresh: () async => refetch!.call(), + child: ListView( + key: keyListTransactions, + controller: scrollController, + children: [ + if (transactionId != null) + TransactionInProgressTule( + address: address, + transactionId: transactionId), + HistoryView( + result: result, + address: address, + ) + ], + ), ), ), ), onNotification: (dynamic t) { - // if (duniterIndexer.pageInfo == null) { - // duniterIndexer.reload(); - // } if (t is ScrollEndNotification && scrollController.position.pixels >= scrollController.position.maxScrollExtent * 0.7 && diff --git a/lib/widgets/transaction_in_progress_tile.dart b/lib/widgets/transaction_in_progress_tile.dart index 461f823..4bd1560 100644 --- a/lib/widgets/transaction_in_progress_tile.dart +++ b/lib/widgets/transaction_in_progress_tile.dart @@ -90,7 +90,7 @@ class _TransactionInProgressTuleState extends State { translate: const Offset(0, -40), delay: const Duration(seconds: 2), duration: const Duration(milliseconds: 700), - onCompleted: () => duniterIndexer.reload(), + onCompleted: () async => duniterIndexer.refetch?.call(), child: Padding( padding: const EdgeInsets.all(8), child: Container(