feat: can refresh history and certs data with swipe down

This commit is contained in:
poka 2024-01-07 20:45:44 +01:00
parent bc415b56e8
commit 3177392604
5 changed files with 43 additions and 36 deletions

View File

@ -15,6 +15,7 @@ class DuniterIndexer with ChangeNotifier {
List listIndexerEndpoints = [];
bool isLoadingIndexer = false;
bool hasNextPage = false;
Future<QueryResult<Object?>?> Function()? refetch;
void reload() {
notifyListeners();

View File

@ -32,13 +32,12 @@ class _ActivityScreenState extends State<ActivityScreen> {
@override
Widget build(BuildContext context) {
Provider.of<DuniterIndexer>(context, listen: true);
final duniterIndexer = Provider.of<DuniterIndexer>(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,

View File

@ -97,21 +97,25 @@ class CertsList extends StatelessWidget {
// Build history list
return SizedBox(
height: windowHeight,
child: ListView(
key: keyListTransactions,
children: <Widget>[
result.data == null
? Column(children: <Widget>[
ScaledSizedBox(height: 50),
Text(
"noTransactionToDisplay".tr(),
style: scaledTextStyle(fontSize: 18),
)
])
: Column(children: <Widget>[
CertTile(listCerts: listCerts),
])
],
child: RefreshIndicator(
color: orangeC,
onRefresh: () async => refetch!.call(),
child: ListView(
key: keyListTransactions,
children: <Widget>[
result.data == null
? Column(children: <Widget>[
ScaledSizedBox(height: 50),
Text(
"noTransactionToDisplay".tr(),
style: scaledTextStyle(fontSize: 18),
)
])
: Column(children: <Widget>[
CertTile(listCerts: listCerts),
])
],
),
),
);
},

View File

@ -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: <Widget>[
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: <Widget>[
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 &&

View File

@ -90,7 +90,7 @@ class _TransactionInProgressTuleState extends State<TransactionInProgressTule> {
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(