main_screens.dart
import 'package:class_carrot_market_v1/screens/home/home_screen.dart';
import 'package:class_carrot_market_v1/screens/my_carrot/my_carrot_screen.dart';
import 'package:class_carrot_market_v1/screens/near_me/near_me.dart';
import 'package:class_carrot_market_v1/screens/neighorhood_life/neighorhood_lift_screen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'chatting/chatting_screen.dart';
class MainScreens extends StatefulWidget {
const MainScreens({super.key});
State<MainScreens> createState() => _MainScreensState();
}
class _MainScreensState extends State<MainScreens> {
int _selectedIndex = 0;
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(
index: _selectedIndex,
children: [
HomeScreen(),
NeighborhoodLifeScreen(),
NearMe(),
ChattingScreen(),
MyCarrotScreen(),
],
),
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.white,
type: BottomNavigationBarType.fixed,
currentIndex: _selectedIndex,
onTap: (newIndex) {
setState(() {
_selectedIndex = newIndex;
});
},
items: [
BottomNavigationBarItem(icon: Icon(CupertinoIcons.home), label: '홈'),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.square_on_square), label: '동네생활'),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.placemark), label: '내 근처'),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.chat_bubble_2), label: '채팅'),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.person), label: '나의 당근'),
],
),
);
}
}