import 'dart:ui'; import 'package:fluent_ui/fluent_ui.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:task_hub/models/task.dart'; import 'package:task_hub/pages/home_page.dart'; import 'package:task_hub/pages/schedule_page.dart'; import 'package:task_hub/pages/settings_page.dart'; import 'package:task_hub/pages/task_page.dart'; import 'package:task_hub/utils/notice.dart'; import 'package:timezone/data/latest.dart' as tz; import 'package:window_size/window_size.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); setWindowMinSize(const Size(800, 600)); tz.initializeTimeZones(); await Hive.initFlutter(); Hive.registerAdapter(TaskAdapter()); await Hive.openBox('taskBox'); await initNotify(); checkScheduleTime(); runApp(const TaskHubApp()); } class TaskHubApp extends StatelessWidget { const TaskHubApp({super.key}); @override Widget build(BuildContext context) { return FluentApp( title: '拾光记', themeMode: ThemeMode.system, theme: FluentThemeData( fontFamily: 'CustomFont', accentColor: Colors.purple, ), debugShowCheckedModeBanner: false, home: const MainLayout(), ); } } class MainLayout extends StatefulWidget { const MainLayout({super.key}); @override State createState() => _MainLayoutState(); } class _MainLayoutState extends State { int _currentIndex = 0; @override Widget build(BuildContext context) { final iconColor = FluentTheme.of(context).accentColor; final paneColor = FluentTheme.of(context).accentColor.lightest; return NavigationView( titleBar: TitleBar( title: const Text('拾光记', style: TextStyle(fontSize: 18)), ), pane: NavigationPane( selected: _currentIndex, onChanged: (index) => setState(() => _currentIndex = index), size: NavigationPaneSize(openWidth: 150), items: [ PaneItem( icon: Icon(FluentIcons.home, color: iconColor), title: const Text('首页', style: TextStyle(fontSize: 16)), body: Container(color: paneColor, child: const HomePage()), ), PaneItem( icon: Icon(FluentIcons.check_list, color: iconColor), title: const Text('待办', style: TextStyle(fontSize: 16)), body: Container(color: paneColor, child: const TaskPage()), ), PaneItem( icon: Icon(FluentIcons.calendar, color: iconColor), title: const Text('日程', style: TextStyle(fontSize: 16)), body: Container(color: paneColor, child: const SchedulePage()), ), PaneItemSeparator(), PaneItem( icon: Icon(FluentIcons.settings, color: iconColor), title: const Text('设置', style: TextStyle(fontSize: 16)), body: Container(color: Colors.white, child: const SettingsPage()), ), ], footerItems: [ PaneItemSeparator(), PaneItemAction( icon: const Icon(FluentIcons.add), title: const Text('添加任务'), onTap: () { // 添加任务的逻辑 }, ), ], ), ); } }