140 lines
4.0 KiB
Dart
140 lines
4.0 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',
|
|
debugShowCheckedModeBanner: false,
|
|
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(
|
|
extendBody: true, // 允许内容延伸到导航栏区域
|
|
body: Stack(
|
|
children: [
|
|
_pages[_currentIndex],
|
|
// 悬浮底部导航组件
|
|
Positioned(
|
|
left: 20,
|
|
right: 20,
|
|
bottom: 80,
|
|
child: Container(
|
|
height: 70,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.95),
|
|
borderRadius: BorderRadius.circular(35),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.2),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 5),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
// 照片标签按钮
|
|
IconButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
_currentIndex = 0;
|
|
});
|
|
},
|
|
icon: Icon(
|
|
Icons.photo_library,
|
|
color: _currentIndex == 0
|
|
? Colors.deepPurple
|
|
: Colors.grey,
|
|
size: 28,
|
|
),
|
|
),
|
|
|
|
// 添加按钮
|
|
GestureDetector(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, '/add-photo');
|
|
},
|
|
child: Container(
|
|
width: 50,
|
|
height: 50,
|
|
decoration: BoxDecoration(
|
|
color: Colors.deepPurple,
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.deepPurple.withOpacity(0.3),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 3),
|
|
),
|
|
],
|
|
),
|
|
child: const Icon(
|
|
Icons.add,
|
|
color: Colors.white,
|
|
size: 30,
|
|
),
|
|
),
|
|
),
|
|
|
|
// 分类标签按钮
|
|
IconButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
_currentIndex = 1;
|
|
});
|
|
},
|
|
icon: Icon(
|
|
Icons.folder,
|
|
color: _currentIndex == 1
|
|
? Colors.deepPurple
|
|
: Colors.grey,
|
|
size: 28,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|