import 'package:flutter/material.dart'; import 'pages/photo_page.dart'; import 'pages/categories_page.dart'; import 'pages/add_photo_page.dart'; void main() { runApp(const SnapWishApp()); } class SnapWishApp extends StatelessWidget { const SnapWishApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'SnapWish', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MainPage(), routes: { '/add-photo': (context) => const AddPhotoPage(), }, ); } } class MainPage extends StatefulWidget { const MainPage({super.key}); @override State createState() => _MainPageState(); } class _MainPageState extends State { int _currentIndex = 0; final List _pages = [ const PhotoPage(), const CategoriesPage(), ]; @override Widget build(BuildContext context) { return Scaffold( body: _pages[_currentIndex], floatingActionButton: FloatingActionButton( onPressed: () { Navigator.pushNamed(context, '/add-photo'); }, child: const Icon(Icons.add), ), bottomNavigationBar: NavigationBar( selectedIndex: _currentIndex, onDestinationSelected: (index) { setState(() { _currentIndex = index; }); }, destinations: const [ NavigationDestination( icon: Icon(Icons.photo_library), label: '照片', ), NavigationDestination( icon: Icon(Icons.folder), label: '分类', ), ], ), ); } }