rup-project/app/lib/screens/main_screen.dart

136 lines
4.3 KiB
Dart

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<MainScreen> createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
int _selectedIndex = 0;
// 탭별 화면 리스트
final List<Widget> _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/home_icon.svg', 0),
),
label: '',
),
BottomNavigationBarItem(
icon: Padding(
padding: EdgeInsets.only(bottom: 10.h),
child: _buildSvgIcon('assets/icons/appointment_icon.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/shop_icon.svg', 3),
),
label: '상점',
),
BottomNavigationBarItem(
icon: Padding(
padding: EdgeInsets.only(bottom: 10.h),
child: _buildSvgIcon('assets/icons/my_icon.svg', 4),
),
label: '내 정보',
),
],
),
),
),
);
}
}