Main coves client
1import 'package:flutter/material.dart';
2
3import '../../constants/app_colors.dart';
4import '../../widgets/icons/bluesky_icons.dart';
5import 'communities_screen.dart';
6import 'create_post_screen.dart';
7import 'feed_screen.dart';
8import 'notifications_screen.dart';
9import 'profile_screen.dart';
10
11class MainShellScreen extends StatefulWidget {
12 const MainShellScreen({super.key});
13
14 @override
15 State<MainShellScreen> createState() => _MainShellScreenState();
16}
17
18class _MainShellScreenState extends State<MainShellScreen> {
19 int _selectedIndex = 0;
20
21 void _onItemTapped(int index) {
22 setState(() {
23 _selectedIndex = index;
24 });
25 }
26
27 void _onCommunitiesTap() {
28 setState(() {
29 _selectedIndex = 1; // Switch to communities tab
30 });
31 }
32
33 void _onNavigateToFeed() {
34 setState(() {
35 _selectedIndex = 0; // Switch to feed tab
36 });
37 }
38
39 @override
40 Widget build(BuildContext context) {
41 return Scaffold(
42 body: IndexedStack(
43 index: _selectedIndex,
44 children: [
45 FeedScreen(onSearchTap: _onCommunitiesTap),
46 const CommunitiesScreen(),
47 CreatePostScreen(onNavigateToFeed: _onNavigateToFeed),
48 const NotificationsScreen(),
49 const ProfileScreen(),
50 ],
51 ),
52 bottomNavigationBar: Container(
53 decoration: const BoxDecoration(
54 color: Color(0xFF0B0F14),
55 border: Border(top: BorderSide(color: Color(0xFF0B0F14), width: 0.5)),
56 ),
57 child: SafeArea(
58 child: SizedBox(
59 height: 48,
60 child: Row(
61 mainAxisAlignment: MainAxisAlignment.spaceAround,
62 children: [
63 _buildNavItem(0, 'home', 'Home'),
64 _buildNavItem(1, 'communities', 'Communities'),
65 _buildNavItem(2, 'plus', 'Create'),
66 _buildNavItem(3, 'bell', 'Notifications'),
67 _buildNavItem(4, 'person', 'Me'),
68 ],
69 ),
70 ),
71 ),
72 ),
73 );
74 }
75
76 Widget _buildNavItem(int index, String iconName, String label) {
77 final isSelected = _selectedIndex == index;
78 final color =
79 isSelected
80 ? AppColors.primary
81 : const Color(0xFFB6C2D2).withValues(alpha: 0.6);
82
83 // Use filled variant when selected, outline when not
84 Widget icon;
85 switch (iconName) {
86 case 'home':
87 icon = BlueSkyIcon.homeSimple(color: color);
88 break;
89 case 'communities':
90 icon = Icon(
91 isSelected ? Icons.workspaces : Icons.workspaces_outlined,
92 color: color,
93 size: 24,
94 );
95 break;
96 case 'plus':
97 icon = BlueSkyIcon.plus(color: color);
98 break;
99 case 'bell':
100 icon =
101 isSelected
102 ? BlueSkyIcon.bellFilled(color: color)
103 : BlueSkyIcon.bellOutline(color: color);
104 break;
105 case 'person':
106 icon = BlueSkyIcon.personSimple(color: color);
107 break;
108 default:
109 icon = BlueSkyIcon.homeOutline(color: color);
110 }
111
112 return Expanded(
113 child: InkWell(
114 onTap: () => _onItemTapped(index),
115 splashColor: Colors.transparent,
116 highlightColor: Colors.transparent,
117 child: icon,
118 ),
119 );
120 }
121}