Skip to content

Commit e1726e0

Browse files
committed
add feed refresh action
1 parent d237388 commit e1726e0

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

app/lib/features/web_feed/presentation/screens/feed_list.dart

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020
import 'package:flutter/material.dart';
21+
import 'package:flutter_hooks/flutter_hooks.dart';
22+
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
2123
import 'package:hooks_riverpod/hooks_riverpod.dart';
2224
import 'package:weblibre/core/routing/routes.dart';
2325
import 'package:weblibre/features/web_feed/domain/providers.dart';
@@ -33,7 +35,37 @@ class FeedListScreen extends HookConsumerWidget {
3335
final feeds = ref.watch(feedListProvider);
3436

3537
return Scaffold(
36-
appBar: AppBar(title: const Text('Feeds')),
38+
appBar: AppBar(
39+
title: const Text('Feeds'),
40+
actions: [
41+
HookBuilder(
42+
builder: (context) {
43+
final future = useState<Future<void>?>(null);
44+
final state = useFuture(future.value);
45+
46+
if (state.connectionState == ConnectionState.waiting) {
47+
return const Padding(
48+
padding: EdgeInsets.all(12.0),
49+
child: SizedBox(
50+
width: 24,
51+
height: 24,
52+
child: CircularProgressIndicator(strokeWidth: 2.0),
53+
),
54+
);
55+
}
56+
57+
return IconButton(
58+
onPressed: () {
59+
future.value = ref
60+
.read(fetchArticlesControllerProvider.notifier)
61+
.fetchAllArticles();
62+
},
63+
icon: const Icon(MdiIcons.cloudSync),
64+
);
65+
},
66+
),
67+
],
68+
),
3769
body: feeds.when(
3870
skipLoadingOnReload: true,
3971
data: (feeds) {

0 commit comments

Comments
 (0)