import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; // Import screenutil 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.w, height: 24.h, 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: Container( padding: EdgeInsets.symmetric(vertical: 10.h), decoration: const BoxDecoration( color: Colors.white, border: Border(top: BorderSide(color: Color(0xFFEEEEEE), width: 1.0)), ), child: Theme( data: Theme.of(context).copyWith( splashColor: Colors.transparent, highlightColor: Colors.transparent, ), child: BottomNavigationBar( backgroundColor: Colors.white, elevation: 0, // Remove default shadow since we have a border currentIndex: _selectedIndex, onTap: _onItemTapped, type: BottomNavigationBarType.fixed, selectedItemColor: AppColors.highlight, unselectedItemColor: AppColors.inactive, selectedLabelStyle: TextStyle( fontFamily: 'SCDream', fontSize: 12.sp, fontWeight: FontWeight.w500, // Medium ), unselectedLabelStyle: TextStyle( fontFamily: 'SCDream', fontSize: 12.sp, fontWeight: FontWeight.w400, // Regular ), showUnselectedLabels: true, items: [ BottomNavigationBarItem( icon: Padding( padding: EdgeInsets.only(bottom: 10.h), child: _buildSvgIcon('assets/icons/homeicon.svg', 0), ), label: '홈', ), BottomNavigationBarItem( icon: Padding( padding: EdgeInsets.only(bottom: 10.h), child: _buildSvgIcon('assets/icons/appointmenticon.svg', 1), ), label: '예약/조회', ), BottomNavigationBarItem( icon: Padding( padding: EdgeInsets.only(bottom: 10.h), child: Image.asset( _selectedIndex == 2 ? 'assets/img/catdog_on.png' : 'assets/img/catdog_off.png', width: 29.w, height: 26.h, fit: BoxFit.cover, ), ), label: '멍냥즈', ), BottomNavigationBarItem( icon: Padding( padding: EdgeInsets.only(bottom: 10.h), child: _buildSvgIcon('assets/icons/shopicon.svg', 3), ), label: '상점', ), BottomNavigationBarItem( icon: Padding( padding: EdgeInsets.only(bottom: 10.h), child: _buildSvgIcon('assets/icons/myicon.svg', 4), ), label: '내 정보', ), ], ), ), ), ); } }