From b8f0547563927ac4ddd73ae781588a316b51a552 Mon Sep 17 00:00:00 2001 From: mrhcjones <150591975+TheHCJ@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:11:22 +0000 Subject: [PATCH] Added scroll to top button to unified feeds --- lib/home/_feed.dart | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/home/_feed.dart b/lib/home/_feed.dart index 5a7d0e4..7a9ef73 100644 --- a/lib/home/_feed.dart +++ b/lib/home/_feed.dart @@ -56,9 +56,6 @@ class _FeedScreenState extends State user.possiblySensitive = false; user.screenName = "ForYou"; - dynamic forYouTweets = ForYouTweets( - user: user, type: 'profile', includeReplies: false, pinnedTweets: [], pref: PrefService.of(context)); - return Provider(create: (context) { var model = GroupModel(widget.id); model.loadGroup(); @@ -68,6 +65,7 @@ class _FeedScreenState extends State var model = context.read(); return NestedScrollView( + controller: widget.scrollController, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( @@ -91,10 +89,24 @@ class _FeedScreenState extends State DropdownMenuItem(value: L10n.current.foryou, child: Text(L10n.current.foryou)) ]), actions: _tab == 1 - ? [...createCommonAppBarActions(context)] + ? [ + IconButton( + icon: const Icon(Icons.arrow_upward), + onPressed: () async { + await widget.scrollController + .animateTo(0, duration: const Duration(seconds: 1), curve: Curves.easeInOut); + }), + ...createCommonAppBarActions(context) + ] : [ IconButton( icon: const Icon(Icons.more_vert), onPressed: () => showFeedSettings(context, model)), + IconButton( + icon: const Icon(Icons.arrow_upward), + onPressed: () async { + await widget.scrollController + .animateTo(0, duration: const Duration(seconds: 1), curve: Curves.easeInOut); + }), IconButton( icon: const Icon(Icons.refresh), onPressed: () async { @@ -109,7 +121,8 @@ class _FeedScreenState extends State SubscriptionGroupScreenContent( id: widget.id, ), - forYouTweets, + ForYouTweets( + user: user, type: 'profile', includeReplies: false, pinnedTweets: [], pref: PrefService.of(context)), ][_tab]); }); }