82 lines
2.4 KiB
Dart
82 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:patbond_flutter/features/home/home_page.dart';
|
|
|
|
class MainShellPage extends StatefulWidget {
|
|
const MainShellPage({super.key});
|
|
|
|
@override
|
|
State<MainShellPage> createState() => _MainShellPageState();
|
|
}
|
|
|
|
class _MainShellPageState extends State<MainShellPage> {
|
|
int currentIndex = 0;
|
|
|
|
final pages = const [
|
|
HomePage(),
|
|
Center(child: Text('发现')),
|
|
Center(child: Text('发布')),
|
|
Center(child: Text('消息')),
|
|
Center(child: Text('我的')),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: pages[currentIndex],
|
|
bottomNavigationBar: NavigationBarTheme(
|
|
data: NavigationBarThemeData(
|
|
backgroundColor: Colors.white,
|
|
indicatorColor: Colors.red.shade50,
|
|
labelTextStyle: WidgetStateProperty.all(
|
|
const TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
iconTheme: WidgetStateProperty.resolveWith((states) {
|
|
if (states.contains(WidgetState.selected)) {
|
|
return const IconThemeData(color: Colors.red);
|
|
}
|
|
return const IconThemeData(color: Colors.grey);
|
|
}),
|
|
),
|
|
child: NavigationBar(
|
|
selectedIndex: currentIndex,
|
|
onDestinationSelected: (index) {
|
|
setState(() {
|
|
currentIndex = index;
|
|
});
|
|
},
|
|
destinations: const [
|
|
NavigationDestination(
|
|
icon: Icon(Icons.home_outlined),
|
|
selectedIcon: Icon(Icons.home),
|
|
label: '首页',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.explore_outlined),
|
|
selectedIcon: Icon(Icons.explore),
|
|
label: '发现',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.add_circle_outline),
|
|
selectedIcon: Icon(Icons.add_circle),
|
|
label: '发布',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.notifications_outlined),
|
|
selectedIcon: Icon(Icons.notifications),
|
|
label: '消息',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.person_outline),
|
|
selectedIcon: Icon(Icons.person),
|
|
label: '我的',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|