feat:增加提醒事项

This commit is contained in:
2025-11-08 22:06:16 +08:00
parent 27f0638c01
commit d5ff4c9b02
30 changed files with 1490 additions and 199 deletions

View File

@@ -6,6 +6,35 @@ import '../provider/app_provider.dart';
class AppDrawer extends StatelessWidget {
const AppDrawer({super.key});
DrawerHeader buildDrawerHeader() {
return DrawerHeader(
decoration: BoxDecoration(color: Colors.blue.shade700),
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 30,
backgroundColor: Colors.white,
child: Icon(Icons.flash_on, color: Colors.blue, size: 40),
),
SizedBox(height: 10),
Text(
'闪灵',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
Text(
'记录每一刻的灵感',
style: TextStyle(color: Colors.white70, fontSize: 14),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Drawer(
@@ -13,41 +42,7 @@ class AppDrawer extends StatelessWidget {
padding: EdgeInsets.zero,
children: [
// 抽屉头部
DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue.shade700,
),
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 30,
backgroundColor: Colors.white,
child: Icon(
Icons.flash_on,
color: Colors.blue,
size: 40,
),
),
SizedBox(height: 10),
Text(
'闪灵',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
Text(
'记录每一刻的灵感',
style: TextStyle(
color: Colors.white70,
fontSize: 14,
),
),
],
),
),
buildDrawerHeader(),
// 菜单项
_buildDrawerItem(
@@ -58,20 +53,12 @@ class AppDrawer extends StatelessWidget {
Provider.of<AppProvider>(context, listen: false).changeTab(0);
},
),
_buildDrawerItem(
icon: Icons.note,
title: '笔记',
onTap: () {
Navigator.pop(context);
Provider.of<AppProvider>(context, listen: false).changeTab(1);
},
),
_buildDrawerItem(
icon: Icons.checklist,
title: '待办事项',
onTap: () {
Navigator.pop(context);
Provider.of<AppProvider>(context, listen: false).changeTab(2);
Provider.of<AppProvider>(context, listen: false).changeTab(1);
},
),
_buildDrawerItem(
@@ -79,7 +66,7 @@ class AppDrawer extends StatelessWidget {
title: '提醒任务',
onTap: () {
Navigator.pop(context);
Provider.of<AppProvider>(context, listen: false).changeTab(3);
Provider.of<AppProvider>(context, listen: false).changeTab(2);
},
),
@@ -137,4 +124,4 @@ class AppDrawer extends StatelessWidget {
onTap: onTap,
);
}
}
}

View File

@@ -1,6 +1,5 @@
import 'package:flisp_app/layout/app_drawer.dart';
import 'package:flisp_app/pages/flash_page.dart';
import 'package:flisp_app/pages/notes_Page.dart';
import 'package:flisp_app/pages/reminders_page.dart';
import 'package:flisp_app/pages/todo_page.dart';
import 'package:flisp_app/provider/app_provider.dart';
@@ -16,10 +15,10 @@ class MainScreen extends StatefulWidget {
class _MainScreenState extends State<MainScreen> {
final GlobalKey<TodoPageState> _todoPageKey = GlobalKey();
final GlobalKey<ReminderPageState> _reminderPageKey = GlobalKey();
List<BottomNavigationBarItem> navItems = [
BottomNavigationBarItem(icon: Icon(Icons.flash_on), label: '闪灵'),
BottomNavigationBarItem(icon: Icon(Icons.note), label: '笔记'),
BottomNavigationBarItem(icon: Icon(Icons.checklist), label: '待办'),
BottomNavigationBarItem(icon: Icon(Icons.notifications), label: '提醒'),
];
@@ -51,9 +50,14 @@ class _MainScreenState extends State<MainScreen> {
}
void _onPressFloatingButton(int index) {
if (index == 2) {
print(index);
if (index == 1) {
if (_todoPageKey.currentState != null) {
_todoPageKey.currentState!.showAddTodoDialog();
_todoPageKey.currentState!.showAddDialog();
}
} else if (index == 2) {
if (_reminderPageKey.currentState != null) {
_reminderPageKey.currentState!.showAddDialog();
}
}
}
@@ -92,18 +96,16 @@ class _MainScreenState extends State<MainScreen> {
case 0:
return const FlashPage();
case 1:
return const NotesPage();
return TodoPage(key: _todoPageKey);
case 2:
return TodoPage(key: _todoPageKey); // 传递 key
case 3:
return const RemindersPage();
return RemindersPage(key: _reminderPageKey);
default:
return const FlashPage();
}
}
String _getAppBarTitle(int index) {
final titles = {0: '闪灵', 1: '笔记', 2: '待办', 3: '提醒'};
final titles = {0: '闪灵', 1: '待办', 2: '提醒'};
return titles[index] ?? '闪灵';
}
}