feat:初始化工程
This commit is contained in:
140
lib/layout/app_drawer.dart
Normal file
140
lib/layout/app_drawer.dart
Normal file
@@ -0,0 +1,140 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../provider/app_provider.dart';
|
||||
|
||||
class AppDrawer extends StatelessWidget {
|
||||
const AppDrawer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 菜单项
|
||||
_buildDrawerItem(
|
||||
icon: Icons.flash_on,
|
||||
title: '闪灵',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
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);
|
||||
},
|
||||
),
|
||||
_buildDrawerItem(
|
||||
icon: Icons.notifications,
|
||||
title: '提醒任务',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Provider.of<AppProvider>(context, listen: false).changeTab(3);
|
||||
},
|
||||
),
|
||||
|
||||
const Divider(),
|
||||
|
||||
_buildDrawerItem(
|
||||
icon: Icons.analytics,
|
||||
title: '统计',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// 这里可以导航到统计页面
|
||||
},
|
||||
),
|
||||
_buildDrawerItem(
|
||||
icon: Icons.archive,
|
||||
title: '归档',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// 这里可以导航到归档页面
|
||||
},
|
||||
),
|
||||
|
||||
const Divider(),
|
||||
|
||||
_buildDrawerItem(
|
||||
icon: Icons.settings,
|
||||
title: '设置',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// 这里可以导航到设置页面
|
||||
},
|
||||
),
|
||||
_buildDrawerItem(
|
||||
icon: Icons.help,
|
||||
title: '帮助与反馈',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// 这里可以导航到帮助页面
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 构建抽屉菜单项
|
||||
Widget _buildDrawerItem({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: Colors.blue.shade600),
|
||||
title: Text(title),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
76
lib/layout/main_screen.dart
Normal file
76
lib/layout/main_screen.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
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';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MainScreen extends StatelessWidget {
|
||||
const MainScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, appState, child) {
|
||||
return Scaffold(
|
||||
// 侧边抽屉菜单
|
||||
drawer: const AppDrawer(),
|
||||
|
||||
// 顶部导航栏
|
||||
appBar: AppBar(
|
||||
title: const Text('闪灵'),
|
||||
backgroundColor: Colors.blue,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
),
|
||||
|
||||
// 主体内容
|
||||
body: _buildPage(appState.currentIndex),
|
||||
|
||||
// 底部导航栏
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: appState.currentIndex,
|
||||
onTap: (index) => appState.changeTab(index),
|
||||
type: BottomNavigationBarType.fixed,
|
||||
items: const [
|
||||
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: '提醒',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 根据索引构建对应页面
|
||||
Widget _buildPage(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const FlashPage();
|
||||
case 1:
|
||||
return const NotesPage();
|
||||
case 2:
|
||||
return const TodoPage();
|
||||
case 3:
|
||||
return const RemindersPage();
|
||||
default:
|
||||
return const FlashPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user