import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import '../../core/chat/chat_request_notifier.dart'; import '../../core/theme/halo_tokens.dart'; import 'widgets/bestie_tab_bar.dart'; /// Shell scaffold for the 3-tab mitra UI: Home / Chat / Profil. /// /// Used as the `builder` of a `StatefulShellRoute.indexedStack` in /// `router.dart`. Renders the active branch's navigator in the body and /// `BestieTabBar` at the bottom. /// /// Tab content is owned by each branch route — this widget only owns the /// scaffold + tab bar. class ShellScreen extends ConsumerWidget { const ShellScreen({super.key, required this.navigationShell}); final StatefulNavigationShell navigationShell; @override Widget build(BuildContext context, WidgetRef ref) { // Watch the chat-request state so the badge updates when new requests // arrive (or are accepted/declined). We don't use the value directly — // we want the rebuild trigger, then read the count via the notifier. ref.watch(chatRequestProvider); final chatBadge = ref.read(chatRequestProvider.notifier).activeRequestCount; return Scaffold( backgroundColor: HaloTokens.bg, body: navigationShell, bottomNavigationBar: BestieTabBar( activeIndex: navigationShell.currentIndex, chatBadgeCount: chatBadge, onTap: (i) => navigationShell.goBranch( i, // Re-tapping the active tab pops back to the branch root. initialLocation: i == navigationShell.currentIndex, ), ), ); } }