257 lines
6.9 KiB
Dart
257 lines
6.9 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
import 'package:go_router/go_router.dart';
|
||
import '../../providers/auth_provider.dart';
|
||
import '../../models/user_model.dart';
|
||
|
||
class DashboardScreen extends StatelessWidget {
|
||
const DashboardScreen({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
appBar: AppBar(
|
||
title: const Text('NANAXE CRM'),
|
||
actions: [
|
||
Consumer(
|
||
builder: (context, ref, _) {
|
||
final user = ref.watch(currentUserProvider);
|
||
final isAdmin = user?.role == UserRole.admin;
|
||
|
||
if (isAdmin ?? false) {
|
||
return IconButton(
|
||
icon: const Icon(Icons.admin_panel_settings),
|
||
onPressed: () => context.push('/home/admin'),
|
||
tooltip: 'Админка',
|
||
);
|
||
}
|
||
return const SizedBox.shrink();
|
||
},
|
||
),
|
||
IconButton(
|
||
icon: const Icon(Icons.auto_awesome),
|
||
onPressed: () => context.push('/home/ai-test'),
|
||
tooltip: 'AI Тест',
|
||
),
|
||
IconButton(
|
||
icon: const Icon(Icons.settings),
|
||
onPressed: () {},
|
||
),
|
||
],
|
||
),
|
||
body: SingleChildScrollView(
|
||
padding: const EdgeInsets.all(16),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
_buildWelcomeCard(),
|
||
const SizedBox(height: 24),
|
||
_buildQuickStats(),
|
||
const SizedBox(height: 24),
|
||
_buildQuickActions(context),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildWelcomeCard() {
|
||
return Card(
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(20),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const Text(
|
||
'Добро пожаловать!',
|
||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||
),
|
||
const SizedBox(height: 8),
|
||
const Text(
|
||
'Управляйте задачами команды и планируйте работу с помощью AI',
|
||
style: TextStyle(color: Colors.grey),
|
||
),
|
||
const SizedBox(height: 16),
|
||
Row(
|
||
children: [
|
||
Expanded(
|
||
child: OutlinedButton.icon(
|
||
onPressed: () {},
|
||
icon: const Icon(Icons.add),
|
||
label: const Text('Новая задача'),
|
||
),
|
||
),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: OutlinedButton.icon(
|
||
onPressed: () {},
|
||
icon: const Icon(Icons.auto_awesome),
|
||
label: const Text('AI План'),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildQuickStats() {
|
||
return Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const Text(
|
||
'Быстрая статистика',
|
||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||
),
|
||
const SizedBox(height: 12),
|
||
Row(
|
||
children: [
|
||
Expanded(
|
||
child: _StatCard(
|
||
icon: Icons.task,
|
||
label: 'Задачи',
|
||
value: '12',
|
||
color: Colors.blue,
|
||
),
|
||
),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: _StatCard(
|
||
icon: Icons.pending_actions,
|
||
label: 'В работе',
|
||
value: '5',
|
||
color: Colors.orange,
|
||
),
|
||
),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: _StatCard(
|
||
icon: Icons.check_circle,
|
||
label: 'Готово',
|
||
value: '48',
|
||
color: Colors.green,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
],
|
||
);
|
||
}
|
||
|
||
Widget _buildQuickActions(BuildContext context) {
|
||
return Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const Text(
|
||
'Быстрые действия',
|
||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||
),
|
||
const SizedBox(height: 12),
|
||
Wrap(
|
||
spacing: 12,
|
||
runSpacing: 12,
|
||
children: [
|
||
_ActionChip(
|
||
icon: Icons.calendar_today,
|
||
label: 'Планирование',
|
||
onTap: () => context.go('/home/calendar'),
|
||
),
|
||
_ActionChip(
|
||
icon: Icons.account_tree,
|
||
label: 'Mind-карта',
|
||
onTap: () => context.go('/home/mindmap'),
|
||
),
|
||
_ActionChip(
|
||
icon: Icons.insights,
|
||
label: 'Аналитика',
|
||
onTap: () {},
|
||
),
|
||
_ActionChip(
|
||
icon: Icons.people,
|
||
label: 'Команда',
|
||
onTap: () {},
|
||
),
|
||
],
|
||
),
|
||
],
|
||
);
|
||
}
|
||
}
|
||
|
||
class _StatCard extends StatelessWidget {
|
||
final IconData icon;
|
||
final String label;
|
||
final String value;
|
||
final Color color;
|
||
|
||
const _StatCard({
|
||
required this.icon,
|
||
required this.label,
|
||
required this.value,
|
||
required this.color,
|
||
});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Card(
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(16),
|
||
child: Column(
|
||
children: [
|
||
Icon(icon, color: color, size: 32),
|
||
const SizedBox(height: 8),
|
||
Text(
|
||
value,
|
||
style: const TextStyle(
|
||
fontSize: 24,
|
||
fontWeight: FontWeight.bold,
|
||
),
|
||
),
|
||
Text(
|
||
label,
|
||
style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ActionChip extends StatelessWidget {
|
||
final IconData icon;
|
||
final String label;
|
||
final VoidCallback onTap;
|
||
|
||
const _ActionChip({
|
||
required this.icon,
|
||
required this.label,
|
||
required this.onTap,
|
||
});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return InkWell(
|
||
onTap: onTap,
|
||
borderRadius: BorderRadius.circular(12),
|
||
child: Container(
|
||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||
decoration: BoxDecoration(
|
||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||
borderRadius: BorderRadius.circular(12),
|
||
),
|
||
child: Row(
|
||
mainAxisSize: MainAxisSize.min,
|
||
children: [
|
||
Icon(icon, size: 20),
|
||
const SizedBox(width: 8),
|
||
Text(label),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|