75 lines
1.7 KiB
Dart
75 lines
1.7 KiB
Dart
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<MainPage> createState() => _MainPageState();
|
|
}
|
|
|
|
class _MainPageState extends State<MainPage> {
|
|
int _currentIndex = 0;
|
|
|
|
final List<Widget> _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: '分类',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|