Skip to content
Snippets Groups Projects
Commit 31773926 authored by poka's avatar poka
Browse files

feat: can refresh history and certs data with swipe down

parent bc415b56
Branches
Tags
No related merge requests found
Pipeline #35187 waiting for manual action
...@@ -15,6 +15,7 @@ class DuniterIndexer with ChangeNotifier { ...@@ -15,6 +15,7 @@ class DuniterIndexer with ChangeNotifier {
List listIndexerEndpoints = []; List listIndexerEndpoints = [];
bool isLoadingIndexer = false; bool isLoadingIndexer = false;
bool hasNextPage = false; bool hasNextPage = false;
Future<QueryResult<Object?>?> Function()? refetch;
void reload() { void reload() {
notifyListeners(); notifyListeners();
......
...@@ -32,13 +32,12 @@ class _ActivityScreenState extends State<ActivityScreen> { ...@@ -32,13 +32,12 @@ class _ActivityScreenState extends State<ActivityScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Provider.of<DuniterIndexer>(context, listen: true); final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: true);
return PopScope( return PopScope(
// onPopInvoked: (_) { onPopInvoked: (_) {
// duniterIndexer.fetchMoreCursor = duniterIndexer.refetch = duniterIndexer.transBC = null;
// duniterIndexer.pageInfo = duniterIndexer.transBC = null; },
// },
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
......
...@@ -97,6 +97,9 @@ class CertsList extends StatelessWidget { ...@@ -97,6 +97,9 @@ class CertsList extends StatelessWidget {
// Build history list // Build history list
return SizedBox( return SizedBox(
height: windowHeight, height: windowHeight,
child: RefreshIndicator(
color: orangeC,
onRefresh: () async => refetch!.call(),
child: ListView( child: ListView(
key: keyListTransactions, key: keyListTransactions,
children: <Widget>[ children: <Widget>[
...@@ -113,6 +116,7 @@ class CertsList extends StatelessWidget { ...@@ -113,6 +116,7 @@ class CertsList extends StatelessWidget {
]) ])
], ],
), ),
),
); );
}, },
), ),
......
...@@ -64,6 +64,7 @@ class HistoryQuery extends StatelessWidget { ...@@ -64,6 +64,7 @@ class HistoryQuery extends StatelessWidget {
}, },
), ),
builder: (QueryResult result, {fetchMore, refetch}) { builder: (QueryResult result, {fetchMore, refetch}) {
duniterIndexer.refetch = refetch;
if (result.isLoading && result.data == null) { if (result.isLoading && result.data == null) {
return const Center( return const Center(
child: CircularProgressIndicator( child: CircularProgressIndicator(
...@@ -119,13 +120,17 @@ class HistoryQuery extends StatelessWidget { ...@@ -119,13 +120,17 @@ class HistoryQuery extends StatelessWidget {
return NotificationListener( return NotificationListener(
child: Builder( child: Builder(
builder: (context) => Expanded( builder: (context) => Expanded(
child: RefreshIndicator(
color: orangeC,
onRefresh: () async => refetch!.call(),
child: ListView( child: ListView(
key: keyListTransactions, key: keyListTransactions,
controller: scrollController, controller: scrollController,
children: <Widget>[ children: <Widget>[
if (transactionId != null) if (transactionId != null)
TransactionInProgressTule( TransactionInProgressTule(
address: address, transactionId: transactionId), address: address,
transactionId: transactionId),
HistoryView( HistoryView(
result: result, result: result,
address: address, address: address,
...@@ -134,10 +139,8 @@ class HistoryQuery extends StatelessWidget { ...@@ -134,10 +139,8 @@ class HistoryQuery extends StatelessWidget {
), ),
), ),
), ),
),
onNotification: (dynamic t) { onNotification: (dynamic t) {
// if (duniterIndexer.pageInfo == null) {
// duniterIndexer.reload();
// }
if (t is ScrollEndNotification && if (t is ScrollEndNotification &&
scrollController.position.pixels >= scrollController.position.pixels >=
scrollController.position.maxScrollExtent * 0.7 && scrollController.position.maxScrollExtent * 0.7 &&
......
...@@ -90,7 +90,7 @@ class _TransactionInProgressTuleState extends State<TransactionInProgressTule> { ...@@ -90,7 +90,7 @@ class _TransactionInProgressTuleState extends State<TransactionInProgressTule> {
translate: const Offset(0, -40), translate: const Offset(0, -40),
delay: const Duration(seconds: 2), delay: const Duration(seconds: 2),
duration: const Duration(milliseconds: 700), duration: const Duration(milliseconds: 700),
onCompleted: () => duniterIndexer.reload(), onCompleted: () async => duniterIndexer.refetch?.call(),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Container( child: Container(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment