feat(feed): add scroll-to-top on feed tab re-tap

Tapping the feed tab while already on the feed screen now scrolls the
current feed to the top, matching common social media app behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Changed files
+22 -3
lib
+15 -2
lib/screens/home/feed_screen.dart
··· 19 19 final VoidCallback? onSearchTap; 20 20 21 21 @override 22 - State<FeedScreen> createState() => _FeedScreenState(); 22 + State<FeedScreen> createState() => FeedScreenState(); 23 23 } 24 24 25 - class _FeedScreenState extends State<FeedScreen> { 25 + class FeedScreenState extends State<FeedScreen> { 26 26 late PageController _pageController; 27 27 final Map<FeedType, ScrollController> _scrollControllers = {}; 28 28 late AuthProvider _authProvider; ··· 127 127 controller.position.maxScrollExtent - 200) { 128 128 context.read<MultiFeedProvider>().loadMore(type); 129 129 } 130 + } 131 + } 132 + 133 + /// Scroll the current feed to the top with animation 134 + void scrollToTop() { 135 + final currentFeed = context.read<MultiFeedProvider>().currentFeedType; 136 + final controller = _scrollControllers[currentFeed]; 137 + if (controller != null && controller.hasClients) { 138 + controller.animateTo( 139 + 0, 140 + duration: const Duration(milliseconds: 300), 141 + curve: Curves.easeOut, 142 + ); 130 143 } 131 144 } 132 145
+7 -1
lib/screens/home/main_shell_screen.dart
··· 17 17 18 18 class _MainShellScreenState extends State<MainShellScreen> { 19 19 int _selectedIndex = 0; 20 + final _feedScreenKey = GlobalKey<FeedScreenState>(); 20 21 21 22 void _onItemTapped(int index) { 23 + // If already on feed tab, scroll to top 24 + if (index == 0 && _selectedIndex == 0) { 25 + _feedScreenKey.currentState?.scrollToTop(); 26 + return; 27 + } 22 28 setState(() { 23 29 _selectedIndex = index; 24 30 }); ··· 42 48 body: IndexedStack( 43 49 index: _selectedIndex, 44 50 children: [ 45 - FeedScreen(onSearchTap: _onCommunitiesTap), 51 + FeedScreen(key: _feedScreenKey, onSearchTap: _onCommunitiesTap), 46 52 const CommunitiesScreen(), 47 53 CreatePostScreen(onNavigateToFeed: _onNavigateToFeed), 48 54 const NotificationsScreen(),