- 在首页添加 Wakatime 卡片和相关功能 - 在设置页面添加 Wakatime API Token 配置 - 更新 auth_service 以支持 Wakatime 认证 - 添加 fl_chart 依赖用于 Wakatime 数据图表展示 - 更新 flutter_lints 版本到 2.0.0
116 lines
2.9 KiB
Dart
116 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../services/auth_service.dart';
|
|
import '../widgets/leetcode_card.dart';
|
|
import '../widgets/gitea_card.dart';
|
|
import '../widgets/kodbox_card.dart';
|
|
import '../widgets/github_card.dart';
|
|
import 'settings_screen.dart';
|
|
import 'wakatime_screen.dart';
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
int _selectedIndex = 0;
|
|
final List<String> _platforms = [
|
|
'LeetCode',
|
|
'Gitea',
|
|
'KodBox',
|
|
'GitHub',
|
|
'Wakatime'
|
|
];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
Provider.of<AuthService>(context, listen: false).loadConfigs();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('个人面板'),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.settings),
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => const SettingsScreen()),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
drawer: Drawer(
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: [
|
|
const DrawerHeader(
|
|
decoration: BoxDecoration(color: Colors.blue),
|
|
child: Text(
|
|
'数据平台',
|
|
style: TextStyle(color: Colors.white, fontSize: 24),
|
|
),
|
|
),
|
|
...List.generate(_platforms.length, (index) {
|
|
return ListTile(
|
|
selected: _selectedIndex == index,
|
|
leading: Icon(_getPlatformIcon(_platforms[index])),
|
|
title: Text(_platforms[index]),
|
|
onTap: () {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
Navigator.pop(context);
|
|
},
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
body: _buildPlatformContent(),
|
|
);
|
|
}
|
|
|
|
IconData _getPlatformIcon(String platform) {
|
|
switch (platform) {
|
|
case 'LeetCode':
|
|
return Icons.code;
|
|
case 'Gitea':
|
|
return Icons.storage;
|
|
case 'KodBox':
|
|
return Icons.folder;
|
|
case 'GitHub':
|
|
return Icons.code;
|
|
case 'Wakatime':
|
|
return Icons.timer;
|
|
default:
|
|
return Icons.help_outline;
|
|
}
|
|
}
|
|
|
|
Widget _buildPlatformContent() {
|
|
switch (_platforms[_selectedIndex]) {
|
|
case 'LeetCode':
|
|
return const LeetCodeCard();
|
|
case 'Gitea':
|
|
return const GiteaCard();
|
|
case 'KodBox':
|
|
return const KodBoxCard();
|
|
case 'GitHub':
|
|
return const GithubCard();
|
|
case 'Wakatime':
|
|
return const WakatimeScreen();
|
|
default:
|
|
return const Center(child: Text('未知平台'));
|
|
}
|
|
}
|
|
}
|