BioFlux/lib/widgets/main_navigation_frame.dart
2026-01-22 16:33:07 +08:00

79 lines
2.7 KiB
Dart

import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import '../screens/home_screen.dart';
import '../screens/message_screen.dart';
import '../screens/settings_screen.dart';
import '../screens/stats_screen.dart';
import '../services/hydration_service.dart';
class MainNavigationFrame extends StatefulWidget {
const MainNavigationFrame({super.key});
@override
State<MainNavigationFrame> createState() => _MainNavigationFrameState();
}
class _MainNavigationFrameState extends State<MainNavigationFrame> {
int _currentIndex = 0;
final List<Widget> _pages = [
const HomeScreen(),
const MessageScreen(),
const StatsScreen(),
const SettingsScreen(),
];
@override
Widget build(BuildContext context) {
final service = context.watch<HydrationService>();
final activeColor = service.dynamicWaterColor;
return Scaffold(
extendBody: true,
body: _pages[_currentIndex],
bottomNavigationBar: Container(
margin: const EdgeInsets.only(left: 20, right: 20, bottom: 30),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.8),
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
color: activeColor.withOpacity(0.15),
blurRadius: 25,
offset: const Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(30),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
child: BottomNavigationBar(
currentIndex: _currentIndex,
onTap: (index) => setState(() => _currentIndex = index),
backgroundColor: Colors.transparent,
elevation: 0,
type: BottomNavigationBarType.fixed,
selectedItemColor: activeColor,
unselectedItemColor: Colors.grey.shade400,
selectedLabelStyle: GoogleFonts.montserrat(fontSize: 10, fontWeight: FontWeight.w600),
unselectedLabelStyle: GoogleFonts.montserrat(fontSize: 10),
showSelectedLabels: false,
showUnselectedLabels: false,
items: const [
BottomNavigationBarItem(icon: Icon(Icons.water_drop_rounded), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.notifications_none_rounded), label: 'Msg'),
BottomNavigationBarItem(icon: Icon(Icons.bar_chart_rounded), label: 'Stats'),
BottomNavigationBarItem(icon: Icon(Icons.settings_outlined), label: 'Settings'),
],
),
),
),
),
);
}
}