417 lines
14 KiB
Dart
417 lines
14 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import '../services/auth_service.dart';
|
|
import '../widgets/profile_avatar.dart';
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
final AuthService _authService = AuthService();
|
|
Map<String, String>? _userInfo;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadUserInfo();
|
|
}
|
|
|
|
Future<void> _loadUserInfo() async {
|
|
final userInfo = await _authService.getUserInfo();
|
|
setState(() {
|
|
_userInfo = userInfo;
|
|
});
|
|
}
|
|
|
|
Future<void> _handleLogout() async {
|
|
await _authService.logout();
|
|
if (mounted) {
|
|
Navigator.of(context).pushReplacementNamed('/auth');
|
|
}
|
|
}
|
|
|
|
void _showProfileMenu() {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
),
|
|
builder: (context) => Container(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// Handle bar
|
|
Container(
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[300],
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
|
|
// Profile info
|
|
ProfileAvatar(
|
|
name: _userInfo?['name'],
|
|
size: 80,
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
Text(
|
|
_userInfo?['name'] ?? 'User',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.grey[800],
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
|
|
Text(
|
|
_userInfo?['email'] ?? 'user@example.com',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 14,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
const SizedBox(height: 32),
|
|
|
|
// Menu items
|
|
ListTile(
|
|
leading: const Icon(Icons.person_outline, color: Color(0xFF6366F1)),
|
|
title: Text(
|
|
'Edit Profile',
|
|
style: GoogleFonts.poppins(fontWeight: FontWeight.w500),
|
|
),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
// TODO: Navigate to edit profile
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Edit Profile coming soon!')),
|
|
);
|
|
},
|
|
),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.settings_outlined, color: Color(0xFF6366F1)),
|
|
title: Text(
|
|
'Settings',
|
|
style: GoogleFonts.poppins(fontWeight: FontWeight.w500),
|
|
),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
// TODO: Navigate to settings
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Settings coming soon!')),
|
|
);
|
|
},
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.logout, color: Colors.red),
|
|
title: Text(
|
|
'Logout',
|
|
style: GoogleFonts.poppins(
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.red,
|
|
),
|
|
),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
_handleLogout();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.grey[50],
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
// Header
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.05),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// Greeting
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Hello,',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
_userInfo?['name'] ?? 'User',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.grey[800],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Profile Avatar
|
|
ProfileAvatar(
|
|
name: _userInfo?['name'],
|
|
size: 48,
|
|
onTap: _showProfileMenu,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Main Content
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
children: [
|
|
// Welcome Card
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
gradient: const LinearGradient(
|
|
colors: [Color(0xFF6366F1), Color(0xFF8B5CF6)],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: const Color(0xFF6366F1).withValues(alpha: 0.3),
|
|
blurRadius: 20,
|
|
offset: const Offset(0, 10),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withValues(alpha: 0.2),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: const Icon(
|
|
Icons.task_alt,
|
|
color: Colors.white,
|
|
size: 24,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Welcome to TaskTracker!',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
'Let\'s get things done',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 14,
|
|
color: Colors.white.withValues(alpha: 0.9),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 32),
|
|
|
|
// Quick Actions
|
|
Text(
|
|
'Quick Actions',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.grey[800],
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// Action Cards
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: _buildActionCard(
|
|
icon: Icons.add_task,
|
|
title: 'Add Task',
|
|
subtitle: 'Create new task',
|
|
color: const Color(0xFF10B981),
|
|
onTap: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Add Task coming soon!')),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: _buildActionCard(
|
|
icon: Icons.list_alt,
|
|
title: 'View Tasks',
|
|
subtitle: 'See all tasks',
|
|
color: const Color(0xFF3B82F6),
|
|
onTap: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('View Tasks coming soon!')),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: _buildActionCard(
|
|
icon: Icons.analytics_outlined,
|
|
title: 'Analytics',
|
|
subtitle: 'View progress',
|
|
color: const Color(0xFF8B5CF6),
|
|
onTap: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Analytics coming soon!')),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: _buildActionCard(
|
|
icon: Icons.settings_outlined,
|
|
title: 'Settings',
|
|
subtitle: 'App settings',
|
|
color: const Color(0xFFF59E0B),
|
|
onTap: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Settings coming soon!')),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildActionCard({
|
|
required IconData icon,
|
|
required String title,
|
|
required String subtitle,
|
|
required Color color,
|
|
required VoidCallback onTap,
|
|
}) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.05),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: color.withValues(alpha: 0.1),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Icon(
|
|
icon,
|
|
color: color,
|
|
size: 24,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
title,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.grey[800],
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
subtitle,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|