feat: implement base architecture and core repositories for weapon tracking and target analysis functionality
This commit is contained in:
@@ -9,6 +9,8 @@ import '../statistics/statistics_screen.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import '../../data/models/session.dart';
|
||||
import '../settings/settings_screen.dart';
|
||||
import '../session/session_setup_screen.dart';
|
||||
import '../session/session_provider.dart';
|
||||
import 'widgets/stats_card.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
@@ -47,7 +49,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// --- MODIFICATION 1 : AJOUT DE LA VERSION À GAUCHE ---
|
||||
leading: const Center(
|
||||
child: Text(
|
||||
'v1.0.2',
|
||||
@@ -56,16 +57,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
title: const Text('Bully'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.analytics),
|
||||
onPressed: () => _navigateToStatistics(context),
|
||||
tooltip: 'Statistiques',
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.history),
|
||||
onPressed: () => _navigateToHistory(context),
|
||||
tooltip: 'Historique',
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () => _navigateToSettings(context),
|
||||
@@ -81,15 +72,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// App logo/header
|
||||
_buildHeader(),
|
||||
const SizedBox(height: AppConstants.largePadding),
|
||||
|
||||
// Main action button
|
||||
_buildMainActionButton(context),
|
||||
const SizedBox(height: AppConstants.largePadding),
|
||||
|
||||
// Statistics section
|
||||
if (_isLoading)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
else if (_stats != null)
|
||||
@@ -107,7 +93,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.primaryColor.withOpacity(0.1),
|
||||
color: AppTheme.primaryColor.withValues(alpha: 0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
@@ -136,20 +122,23 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}
|
||||
|
||||
Widget _buildMainActionButton(BuildContext context) {
|
||||
final sessionProvider = context.watch<SessionProvider>();
|
||||
final isSessionActive = sessionProvider.isSessionActive;
|
||||
|
||||
return ElevatedButton.icon(
|
||||
onPressed: () => _navigateToCapture(context),
|
||||
onPressed: () => _navigateToSessionSetup(context),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryColor,
|
||||
backgroundColor: isSessionActive ? AppTheme.secondaryColor : AppTheme.primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppConstants.borderRadius),
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.add_a_photo, size: 28),
|
||||
label: const Text(
|
||||
'Nouvelle Analyse',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
icon: Icon(isSessionActive ? Icons.play_circle_outline : Icons.add_circle_outline, size: 28),
|
||||
label: Text(
|
||||
isSessionActive ? 'Continuer la session' : 'Démarrer la session',
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -165,8 +154,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Première ligne de vignettes (Sessions et Tirs)
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -192,19 +179,17 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// --- MODIFICATION 2 : GRAPHIQUE RÉEL (Restauré) ---
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Container(
|
||||
height: 150,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(AppConstants.borderRadius),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
@@ -226,8 +211,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
: _buildHomeTrendChart(),
|
||||
),
|
||||
),
|
||||
|
||||
// Deuxième ligne de vignettes (Historique et Meilleur)
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -257,13 +240,19 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
// --- MÉTHODES DE NAVIGATION ---
|
||||
|
||||
void _navigateToCapture(BuildContext context) async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const CaptureScreen()),
|
||||
);
|
||||
void _navigateToSessionSetup(BuildContext context) async {
|
||||
final sessionProvider = context.read<SessionProvider>();
|
||||
if (sessionProvider.isSessionActive) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const CaptureScreen()),
|
||||
);
|
||||
} else {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const SessionSetupScreen()),
|
||||
);
|
||||
}
|
||||
_loadStats();
|
||||
}
|
||||
|
||||
@@ -283,10 +272,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
_loadStats();
|
||||
}
|
||||
|
||||
// --- WIDGET DU GRAPHIQUE D'ACCUEIL ---
|
||||
|
||||
Widget _buildHomeTrendChart() {
|
||||
// Trier par date et prendre les 7 dernières
|
||||
final sorted = List<Session>.from(_recentSessions)
|
||||
..sort((a, b) => a.createdAt.compareTo(b.createdAt));
|
||||
final display =
|
||||
@@ -294,22 +280,84 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
return LineChart(
|
||||
LineChartData(
|
||||
gridData: const FlGridData(show: false),
|
||||
titlesData: const FlTitlesData(show: false),
|
||||
borderData: FlBorderData(show: false),
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
drawVerticalLine: false,
|
||||
getDrawingHorizontalLine: (value) => FlLine(
|
||||
color: Colors.grey.withValues(alpha: 0.1),
|
||||
strokeWidth: 1,
|
||||
),
|
||||
),
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
rightTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
|
||||
topTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 22,
|
||||
interval: 1,
|
||||
getTitlesWidget: (value, meta) {
|
||||
final index = value.toInt();
|
||||
if (index < 0 || index >= display.length) return const SizedBox();
|
||||
final date = display[index].createdAt;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Text(
|
||||
'${date.day}/${date.month}',
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
color: Colors.grey.withValues(alpha: 0.8),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
leftTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 28,
|
||||
getTitlesWidget: (value, meta) {
|
||||
return Text(
|
||||
value.toInt().toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
color: Colors.grey.withValues(alpha: 0.8),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
borderData: FlBorderData(
|
||||
show: true,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.withValues(alpha: 0.2)),
|
||||
left: BorderSide(color: Colors.grey.withValues(alpha: 0.2)),
|
||||
),
|
||||
),
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: display.asMap().entries.map((e) {
|
||||
return FlSpot(e.key.toDouble(), e.value.totalScore.toDouble());
|
||||
return FlSpot(e.key.toDouble(), e.value.averageScore);
|
||||
}).toList(),
|
||||
isCurved: true,
|
||||
color: AppTheme.primaryColor,
|
||||
barWidth: 4,
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: const FlDotData(show: false),
|
||||
dotData: FlDotData(
|
||||
show: true,
|
||||
getDotPainter: (spot, percent, barData, index) => FlDotCirclePainter(
|
||||
radius: 3,
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
strokeColor: AppTheme.primaryColor,
|
||||
),
|
||||
),
|
||||
belowBarData: BarAreaData(
|
||||
show: true,
|
||||
color: AppTheme.primaryColor.withOpacity(0.1),
|
||||
color: AppTheme.primaryColor.withValues(alpha: 0.1),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -317,10 +365,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
void _navigateToSettings(BuildContext context) {
|
||||
Navigator.push(
|
||||
void _navigateToSettings(BuildContext context) async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const SettingsScreen()),
|
||||
);
|
||||
_loadStats();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user