Files
food_hub_app/lib/views/home.dart
2025-11-20 18:43:09 +08:00

69 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:food_hub_app/layout/drawer.dart';
import 'package:food_hub_app/layout/nav_bar.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<StatefulWidget> createState() => _HomePage();
}
class _HomePage extends State<HomePage> {
int _currentIndex = 0;
List<Widget> get tabPages => pageInfos.map((item) => item.page).toList();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('食光集', style: TextStyle(color: Colors.white)),
backgroundColor: Theme.of(context).colorScheme.primary,
leading: Builder(
builder: (context) {
return IconButton(
icon: const Icon(Icons.menu),
color: Colors.white,
onPressed: () => Scaffold.of(context).openDrawer(),
);
},
),
actions: [
Row(
children: [
IconButton(
icon: Icon(Icons.search, color: Colors.white),
onPressed: () {
// 搜索功能
},
),
IconButton(
icon: Icon(Icons.add, color: Colors.white),
onPressed: () {
buildBottomSheet(context);
},
),
],
),
],
),
// backgroundColor: Color(0xFFF5F5F5),
drawer: SettingsDrawer(),
body: Padding(
padding: EdgeInsets.all(10),
child: tabPages[_currentIndex],
),
bottomNavigationBar: buildBottomNavBar(
currentIndex: _currentIndex,
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
);
}
}