import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'home_screen.dart'; import 'reservation_screen.dart'; import 'mungnyangz_screen.dart'; import 'shop_screen.dart'; import 'my_info_screen.dart'; import '../theme/app_colors.dart'; class MainScreen extends StatefulWidget { const MainScreen({super.key}); @override State createState() => _MainScreenState(); } class _MainScreenState extends State { int _selectedIndex = 0; // 탭별 화면 리스트 final List _screens = [ const HomeScreen(), const ReservationScreen(), const MungNyangzScreen(), const ShopScreen(), const MyInfoScreen(), ]; void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } // SVG 아이콘 빌더 (선택 여부에 따라 색상 변경) Widget _buildSvgIcon(String assetName, int index) { return SvgPicture.asset( assetName, width: 24, height: 24, colorFilter: ColorFilter.mode( _selectedIndex == index ? AppColors.highlight : AppColors.inactive, // 선택됨: 강조색, 안됨: 비활성화색 BlendMode.srcIn, ), ); } @override Widget build(BuildContext context) { return Scaffold( body: IndexedStack(index: _selectedIndex, children: _screens), bottomNavigationBar: BottomNavigationBar( currentIndex: _selectedIndex, onTap: _onItemTapped, type: BottomNavigationBarType.fixed, selectedItemColor: AppColors.highlight, unselectedItemColor: AppColors.inactive, selectedLabelStyle: TextStyle( fontFamily: 'SCDream', fontSize: 12, fontWeight: FontWeight.w500, // Medium ), unselectedLabelStyle: TextStyle( fontFamily: 'SCDream', fontSize: 12, fontWeight: FontWeight.w400, // Regular ), showUnselectedLabels: true, items: [ BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.only(bottom: 10), child: _buildSvgIcon('assets/icons/homeicon.svg', 0), ), label: '홈', ), BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.only(bottom: 10), child: _buildSvgIcon('assets/icons/appointmenticon.svg', 1), ), label: '예약/조회', ), BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.only(bottom: 10), child: Image.asset( _selectedIndex == 2 ? 'assets/img/catdog_on.png' : 'assets/img/catdog_off.png', width: 24, height: 24, ), ), label: '멍냥즈', ), BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.only(bottom: 10), child: _buildSvgIcon('assets/icons/shopicon.svg', 3), ), label: '상점', ), BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.only(bottom: 10), child: _buildSvgIcon('assets/icons/myicon.svg', 4), ), label: '내 정보', ), ], ), ); } }