cambiate metriche, tolti totali aggregati e messo a posto lista obiettivi
This commit is contained in:
1 parent
d5591b2c91
commit
3949d6d13c
4 files changed
+293
-312
No files matched your search
@@ -263,4 +263,23 @@ class TargetMetrics extends Equatable {
|
||||
telepass2 +
|
||||
energiaTim2 +
|
||||
energiaAltri2;
|
||||
|
||||
/// Numero di categorie con almeno una soglia impostata (> 0)
|
||||
int get activeMetricsCount {
|
||||
int count = 0;
|
||||
if (mnp1 > 0 || mnp2 > 0) count++;
|
||||
if (unica1 > 0 || unica2 > 0) count++;
|
||||
if (nip1 > 0 || nip2 > 0) count++;
|
||||
if (business1 > 0 || business2 > 0) count++;
|
||||
if (contenuti1 > 0 || contenuti2 > 0) count++;
|
||||
if (calcio1 > 0 || calcio2 > 0) count++;
|
||||
if (fin1 > 0 || fin2 > 0) count++;
|
||||
if (upselling1 > 0 || upselling2 > 0) count++;
|
||||
if (cb1 > 0 || cb2 > 0) count++;
|
||||
if (al1 > 0 || al2 > 0) count++;
|
||||
if (telepass1 > 0 || telepass2 > 0) count++;
|
||||
if (energiaTim1 > 0 || energiaTim2 > 0) count++;
|
||||
if (energiaAltri1 > 0 || energiaAltri2 > 0) count++;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -113,6 +113,33 @@ class CategoryProgress extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
/// Ha un target attivo (> 0) impostato
|
||||
bool get hasTarget => targetS1 > 0 || targetS2 > 0;
|
||||
|
||||
/// Obiettivo Soglia 2 già raggiunto/preso nei pezzi
|
||||
bool get isAchievedS2 => targetS2 > 0 && actualPieces >= targetS2;
|
||||
|
||||
/// Obiettivo Soglia 1 già raggiunto/preso nei pezzi
|
||||
bool get isAchievedS1 => targetS1 > 0 && actualPieces >= targetS1;
|
||||
|
||||
/// Obiettivo già raggiunto/preso (almeno Soglia 1)
|
||||
bool get isAchieved => isAchievedS1 || isAchievedS2;
|
||||
|
||||
/// In linea con il ritmo di marcia ma non ancora formalmente raggiunto
|
||||
bool get isInLineOnly =>
|
||||
!isAchieved &&
|
||||
(status == TargetPacingStatus.inLineS1 ||
|
||||
status == TargetPacingStatus.inLineS2);
|
||||
|
||||
/// Sotto ritmo ma recuperabile (ROSA)
|
||||
bool get isRecoverable => status == TargetPacingStatus.recoverable;
|
||||
|
||||
/// In forte ritardo critico o fermo (ROSSO)
|
||||
bool get isCritical => status == TargetPacingStatus.critical;
|
||||
|
||||
/// Sotto ritmo complessivo (Rosa o Rosso)
|
||||
bool get isBehind => isRecoverable || isCritical;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
key,
|
||||
@@ -164,12 +191,28 @@ class TargetProgressModel extends Equatable {
|
||||
int get totalTargetS2 =>
|
||||
categories.values.fold(0, (sum, c) => sum + c.targetS2);
|
||||
|
||||
/// Numero di obiettivi in linea o raggiunti in Soglia 2
|
||||
/// Numero di obiettivi già raggiunti/presi (almeno Soglia 1)
|
||||
int get countAchieved =>
|
||||
categories.values.where((c) => c.isAchieved).length;
|
||||
|
||||
/// Numero di obiettivi già raggiunti in Soglia 2 (Sfidante)
|
||||
int get countAchievedS2 =>
|
||||
categories.values.where((c) => c.isAchievedS2).length;
|
||||
|
||||
/// Numero di obiettivi già raggiunti in Soglia 1 ma non ancora in Soglia 2
|
||||
int get countAchievedS1 =>
|
||||
categories.values.where((c) => c.isAchievedS1 && !c.isAchievedS2).length;
|
||||
|
||||
/// Numero di obiettivi non ancora raggiunti ma attualmente in linea con il ritmo
|
||||
int get countInLineOnly =>
|
||||
categories.values.where((c) => c.isInLineOnly).length;
|
||||
|
||||
/// Numero di obiettivi in linea o già raggiunti in Soglia 2
|
||||
int get countInLineS2 => categories.values
|
||||
.where((c) => c.status == TargetPacingStatus.inLineS2)
|
||||
.length;
|
||||
|
||||
/// Numero di obiettivi in linea o raggiunti in Soglia 1
|
||||
/// Numero di obiettivi in linea o già raggiunti in Soglia 1
|
||||
int get countInLineS1 => categories.values
|
||||
.where((c) => c.status == TargetPacingStatus.inLineS1)
|
||||
.length;
|
||||
@@ -189,7 +232,7 @@ class TargetProgressModel extends Equatable {
|
||||
|
||||
/// Numero di categorie con obiettivo attivo (> 0)
|
||||
int get countTotalActive => categories.values
|
||||
.where((c) => c.status != TargetPacingStatus.notSet)
|
||||
.where((c) => c.hasTarget)
|
||||
.length;
|
||||
|
||||
/// Media giornaliera complessiva tenuta finora
|
||||
|
||||
@@ -228,11 +228,6 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
TargetProgressModel progress,
|
||||
bool isDesktop,
|
||||
) {
|
||||
final s1Target = progress.totalTargetS1;
|
||||
final s2Target = progress.totalTargetS2;
|
||||
final actual = progress.totalActualPieces;
|
||||
final s1Ratio = s1Target > 0 ? (actual / s1Target).clamp(0.0, 1.0) : 0.0;
|
||||
|
||||
final greenTheme = PacingTheme.of(TargetPacingStatus.inLineS2);
|
||||
final verdinoTheme = PacingTheme.of(TargetPacingStatus.inLineS1);
|
||||
final pinkTheme = PacingTheme.of(TargetPacingStatus.recoverable);
|
||||
@@ -320,13 +315,13 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
),
|
||||
|
||||
// KPI 2: Totale Realizzato vs Minimo
|
||||
// KPI 2: Obiettivi Presi vs Totali
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'VOLUME TOTALE',
|
||||
'OBIETTIVI PRESI',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -340,24 +335,24 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Text(
|
||||
'$actual',
|
||||
'${progress.countAchieved}',
|
||||
style: const TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
' / $s1Target (Minimo)',
|
||||
' / ${progress.countTotalActive} totali',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
if (s2Target > 0) ...[
|
||||
if (progress.countAchievedS2 > 0) ...[
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'• Sfida: $s2Target',
|
||||
'• ${progress.countAchievedS2} in Sfida (S2)',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.purple.shade700,
|
||||
@@ -371,10 +366,14 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: LinearProgressIndicator(
|
||||
value: s1Ratio,
|
||||
value: progress.countTotalActive > 0
|
||||
? (progress.countAchieved / progress.countTotalActive)
|
||||
: 0.0,
|
||||
minHeight: 8,
|
||||
backgroundColor: theme.dividerColor.withValues(alpha: 0.3),
|
||||
color: s1Ratio >= 1.0 ? const Color(0xFF15803D) : theme.colorScheme.primary,
|
||||
color: progress.countAchieved == progress.countTotalActive
|
||||
? const Color(0xFF15803D)
|
||||
: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -386,7 +385,7 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
const Divider(height: 1),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
// Riga Inferiore: Ritmo e Medie Lavorative (Grandi e Immediate)
|
||||
// Riga Inferiore: Giorni lavorativi e Sintesi Gare
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -409,66 +408,41 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
spacing: 12,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
// Media Attuale
|
||||
// Già Presi
|
||||
_buildRateBadge(
|
||||
label: 'MEDIA ATTUALE NEGOZIO',
|
||||
value: '${progress.overallActualDailyRate.toStringAsFixed(1)} / gg',
|
||||
color: theme.colorScheme.primary,
|
||||
bgColor: theme.colorScheme.primaryContainer.withValues(alpha: 0.25),
|
||||
borderColor: theme.colorScheme.primary.withValues(alpha: 0.35),
|
||||
label: 'GIÀ PRESI 🏆',
|
||||
value: '${progress.countAchieved} / ${progress.countTotalActive}',
|
||||
color: greenTheme.text,
|
||||
bgColor: greenTheme.background,
|
||||
borderColor: greenTheme.border,
|
||||
),
|
||||
|
||||
// Richiesta S1
|
||||
() {
|
||||
final isS1Done = actual >= s1Target;
|
||||
Color c;
|
||||
Color bg;
|
||||
Color border;
|
||||
String val;
|
||||
if (isS1Done) {
|
||||
c = greenTheme.text;
|
||||
bg = greenTheme.background;
|
||||
border = greenTheme.border;
|
||||
val = 'RAGGIUNTA! 🎉';
|
||||
} else if (progress.overallRequiredDailyRateS1 <= progress.overallActualDailyRate) {
|
||||
c = verdinoTheme.text;
|
||||
bg = verdinoTheme.background;
|
||||
border = verdinoTheme.border;
|
||||
val = '${progress.overallRequiredDailyRateS1.toStringAsFixed(1)} / gg';
|
||||
} else if (progress.overallRequiredDailyRateS1 <= progress.overallActualDailyRate * 1.35) {
|
||||
c = pinkTheme.text;
|
||||
bg = pinkTheme.background;
|
||||
border = pinkTheme.border;
|
||||
val = '${progress.overallRequiredDailyRateS1.toStringAsFixed(1)} / gg';
|
||||
} else {
|
||||
c = redTheme.text;
|
||||
bg = redTheme.background;
|
||||
border = redTheme.border;
|
||||
val = '${progress.overallRequiredDailyRateS1.toStringAsFixed(1)} / gg';
|
||||
}
|
||||
return _buildRateBadge(
|
||||
label: 'SERVE PER S1 (MINIMO)',
|
||||
value: val,
|
||||
color: c,
|
||||
bgColor: bg,
|
||||
borderColor: border,
|
||||
);
|
||||
}(),
|
||||
// In linea
|
||||
_buildRateBadge(
|
||||
label: 'IN LINEA ✅',
|
||||
value: '${progress.countInLineOnly} obiettivi',
|
||||
color: verdinoTheme.text,
|
||||
bgColor: verdinoTheme.background,
|
||||
borderColor: verdinoTheme.border,
|
||||
),
|
||||
|
||||
// Richiesta S2 (se presente)
|
||||
if (s2Target > 0)
|
||||
() {
|
||||
final isS2Done = actual >= s2Target;
|
||||
return _buildRateBadge(
|
||||
label: 'SERVE PER S2 (SFIDANTE)',
|
||||
value: isS2Done
|
||||
? 'RAGGIUNTA! 🚀'
|
||||
: '${progress.overallRequiredDailyRateS2.toStringAsFixed(1)} / gg',
|
||||
color: isS2Done ? greenTheme.text : Colors.purple.shade900,
|
||||
bgColor: isS2Done ? greenTheme.background : Colors.purple.shade50,
|
||||
borderColor: isS2Done ? greenTheme.border : Colors.purple.shade200,
|
||||
);
|
||||
}(),
|
||||
// Da spingere
|
||||
_buildRateBadge(
|
||||
label: 'DA SPINGERE ⚡',
|
||||
value: '${progress.countRecoverable} obiettivi',
|
||||
color: pinkTheme.text,
|
||||
bgColor: pinkTheme.background,
|
||||
borderColor: pinkTheme.border,
|
||||
),
|
||||
|
||||
// In ritardo
|
||||
_buildRateBadge(
|
||||
label: 'IN RITARDO 🔴',
|
||||
value: '${progress.countCritical} obiettivi',
|
||||
color: redTheme.text,
|
||||
bgColor: redTheme.background,
|
||||
borderColor: redTheme.border,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -784,12 +758,13 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
final staffId = it.staffId;
|
||||
final staffName = it.staff?.name ?? 'Addetto';
|
||||
final sp = progress.staffProgress[staffId];
|
||||
final greenTheme = PacingTheme.of(TargetPacingStatus.inLineS2);
|
||||
final verdinoTheme = PacingTheme.of(TargetPacingStatus.inLineS1);
|
||||
|
||||
final totalS1 = it.metrics.totalLevel1;
|
||||
final totalS2 = it.metrics.totalLevel2;
|
||||
final hasTargets = totalS1 > 0 || totalS2 > 0;
|
||||
final actualTotal = sp?.totalActualPieces ?? 0;
|
||||
final s1Ratio = totalS1 > 0 ? (actualTotal / totalS1).clamp(0.0, 1.0) : 0.0;
|
||||
|
||||
final staffPacingStatus = sp == null || !hasTargets
|
||||
? TargetPacingStatus.notSet
|
||||
@@ -872,33 +847,31 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Text(
|
||||
'$actualTotal',
|
||||
'${sp?.countAchieved ?? 0}',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: actualTotal >= totalS1
|
||||
color: (sp?.countAchieved ?? 0) > 0
|
||||
? const Color(0xFF15803D)
|
||||
: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
' / $totalS1',
|
||||
' / ${sp?.countTotalActive ?? 0} presi',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
if (totalS2 > 0) ...[
|
||||
if ((sp?.countAchievedS2 ?? 0) > 0) ...[
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'(S2: $totalS2)',
|
||||
style: TextStyle(
|
||||
'(${sp?.countAchievedS2} in S2)',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: actualTotal >= totalS2
|
||||
? const Color(0xFF15803D)
|
||||
: Colors.purple.shade700,
|
||||
color: Color(0xFF15803D),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -918,38 +891,37 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Media: ${sp.overallActualDailyRate.toStringAsFixed(1)} / gg',
|
||||
'${sp.countInLineOnly} in linea ✅',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
color: verdinoTheme.text,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: staffTheme.background,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(color: staffTheme.border),
|
||||
),
|
||||
child: Text(
|
||||
actualTotal >= totalS1
|
||||
? 'S1 RAGGIUNTO! 🎉'
|
||||
: 'Req S1: ${sp.overallRequiredDailyRateS1.toStringAsFixed(1)} / gg',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: staffTheme.text,
|
||||
if (sp.countBehind > 0)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: staffTheme.background,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(color: staffTheme.border),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (totalS2 > 0)
|
||||
child: Text(
|
||||
'${sp.countBehind} sotto ritmo',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: staffTheme.text,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
'Req S2: ${sp.overallRequiredDailyRateS2.toStringAsFixed(1)} / gg',
|
||||
'Tutti a ritmo! 🚀',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.purple.shade700,
|
||||
color: greenTheme.text,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -958,10 +930,12 @@ class _TargetDetailScreenState extends State<TargetDetailScreen>
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
child: LinearProgressIndicator(
|
||||
value: s1Ratio,
|
||||
value: sp.countTotalActive > 0
|
||||
? (sp.countAchieved / sp.countTotalActive)
|
||||
: 0.0,
|
||||
minHeight: 5,
|
||||
backgroundColor: theme.dividerColor.withValues(alpha: 0.15),
|
||||
color: actualTotal >= totalS1
|
||||
color: sp.countAchieved == sp.countTotalActive
|
||||
? const Color(0xFF15803D)
|
||||
: staffTheme.primary,
|
||||
),
|
||||
|
||||
@@ -335,8 +335,7 @@ class _TargetListScreenState extends State<TargetListScreen> {
|
||||
final range = _formatDateRange(target.startDay, target.endDay);
|
||||
final storeName = target.store?.name ?? 'Negozio';
|
||||
|
||||
final totalL1 = target.metrics.totalLevel1;
|
||||
final totalL2 = target.metrics.totalLevel2;
|
||||
final activeMetricsCount = target.metrics.activeMetricsCount;
|
||||
final staffCount = target.individualTargets.length;
|
||||
|
||||
return Card(
|
||||
@@ -433,7 +432,7 @@ class _TargetListScreenState extends State<TargetListScreen> {
|
||||
const Divider(height: 1),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Riga 2: Chip Strategici di Pacing & Avanzamento (4 Colori: Verde, Verdino, Rosa, Rosso)
|
||||
// Riga 2: Stato Avanzamento Obiettivi (Presi, In Linea, Sotto)
|
||||
if (progress != null) ...[
|
||||
() {
|
||||
final greenTheme = PacingTheme.of(TargetPacingStatus.inLineS2);
|
||||
@@ -444,219 +443,155 @@ class _TargetListScreenState extends State<TargetListScreen> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
// Sottotitolo informativo: Giorni Lavorativi ed Addetti
|
||||
Row(
|
||||
children: [
|
||||
// 1. Verde pieno: In linea con Soglia 2 (Sfidante)
|
||||
if (progress.countInLineS2 > 0)
|
||||
_buildSmartChip(
|
||||
icon: greenTheme.icon,
|
||||
label: '${progress.countInLineS2} Sfidante (Verde)',
|
||||
color: greenTheme.text,
|
||||
backgroundColor: greenTheme.background,
|
||||
borderColor: greenTheme.border,
|
||||
Icon(
|
||||
Icons.schedule_outlined,
|
||||
size: 15,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${progress.elapsedWorkingDays} gg trascorsi • ${progress.remainingWorkingDays} gg rimasti (escl. dom. e festivi) • $staffCount addetti',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// 2. Verdino: In linea con Soglia 1 (Minimo)
|
||||
if (progress.countInLineS1 > 0)
|
||||
_buildSmartChip(
|
||||
icon: verdinoTheme.icon,
|
||||
label: '${progress.countInLineS1} Minimo (Verdino)',
|
||||
color: verdinoTheme.text,
|
||||
backgroundColor: verdinoTheme.background,
|
||||
borderColor: verdinoTheme.border,
|
||||
),
|
||||
// I 3 INDICATORI CHIAVE: GIÀ PRESI, IN LINEA, SOTTO RITMO
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
// 1. GIÀ PRESI (Verde)
|
||||
_buildPacingMetricCard(
|
||||
title: 'GIÀ PRESI',
|
||||
value: '${progress.countAchieved}',
|
||||
suffix: '/ ${progress.countTotalActive}',
|
||||
note: progress.countAchievedS2 > 0
|
||||
? '${progress.countAchievedS2} centrati in S2'
|
||||
: (progress.countAchieved > 0
|
||||
? 'Obiettivi raggiunti'
|
||||
: 'Nessuno ancora'),
|
||||
color: greenTheme.text,
|
||||
backgroundColor: greenTheme.background,
|
||||
borderColor: greenTheme.border,
|
||||
icon: Icons.emoji_events_rounded,
|
||||
),
|
||||
|
||||
// 3. Rosa: Sotto ritmo ma recuperabile (Da spingere)
|
||||
if (progress.countRecoverable > 0)
|
||||
_buildSmartChip(
|
||||
icon: pinkTheme.icon,
|
||||
label: '${progress.countRecoverable} Da spingere (Rosa)',
|
||||
color: pinkTheme.text,
|
||||
backgroundColor: pinkTheme.background,
|
||||
borderColor: pinkTheme.border,
|
||||
),
|
||||
// 2. IN LINEA (Verdino)
|
||||
_buildPacingMetricCard(
|
||||
title: 'IN LINEA',
|
||||
value: '${progress.countInLineOnly}',
|
||||
suffix: 'obiettivi',
|
||||
note: 'A ritmo per chiudere',
|
||||
color: verdinoTheme.text,
|
||||
backgroundColor: verdinoTheme.background,
|
||||
borderColor: verdinoTheme.border,
|
||||
icon: Icons.trending_up_rounded,
|
||||
),
|
||||
|
||||
// 4. Rosso: In ritardo critico
|
||||
if (progress.countCritical > 0)
|
||||
_buildSmartChip(
|
||||
icon: redTheme.icon,
|
||||
label: '${progress.countCritical} In ritardo (Rosso)',
|
||||
color: redTheme.text,
|
||||
backgroundColor: redTheme.background,
|
||||
borderColor: redTheme.border,
|
||||
),
|
||||
|
||||
// Se tutti sono a target
|
||||
if (progress.countBehind == 0 && progress.countTotalActive > 0)
|
||||
_buildSmartChip(
|
||||
icon: Icons.star_rounded,
|
||||
label: 'Tutti gli obiettivi a ritmo! 🚀',
|
||||
color: greenTheme.text,
|
||||
backgroundColor: greenTheme.background,
|
||||
borderColor: greenTheme.border,
|
||||
),
|
||||
|
||||
// Addetti
|
||||
_buildSmartChip(
|
||||
icon: Icons.people_outline,
|
||||
label: '$staffCount addetti',
|
||||
color: Colors.blue.shade900,
|
||||
backgroundColor: Colors.blue.shade50,
|
||||
borderColor: Colors.blue.shade200,
|
||||
// 3. SOTTO RITMO (Rosa o Rosso)
|
||||
_buildPacingMetricCard(
|
||||
title: 'SOTTO RITMO',
|
||||
value: '${progress.countBehind}',
|
||||
suffix: 'da spingere',
|
||||
note: progress.countBehind == 0
|
||||
? 'Tutto a ritmo!'
|
||||
: '${progress.countRecoverable} recuperabili • ${progress.countCritical} critici',
|
||||
color: progress.countBehind == 0
|
||||
? greenTheme.text
|
||||
: (progress.countCritical > 0
|
||||
? redTheme.text
|
||||
: pinkTheme.text),
|
||||
backgroundColor: progress.countBehind == 0
|
||||
? greenTheme.background
|
||||
: (progress.countCritical > 0
|
||||
? redTheme.background
|
||||
: pinkTheme.background),
|
||||
borderColor: progress.countBehind == 0
|
||||
? greenTheme.border
|
||||
: (progress.countCritical > 0
|
||||
? redTheme.border
|
||||
: pinkTheme.border),
|
||||
icon: progress.countBehind == 0
|
||||
? Icons.check_circle_rounded
|
||||
: (progress.countCritical > 0
|
||||
? Icons.warning_amber_rounded
|
||||
: Icons.bolt_rounded),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
// Box Grande & Immediato: Quantità, Media Attuale, Media Richiesta
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.35),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.outlineVariant.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.calendar_month_outlined,
|
||||
size: 15,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'${progress.elapsedWorkingDays} gg trascorsi • ${progress.remainingWorkingDays} gg rimasti (escluse dom. e festivi)',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
// 1. QUANTITÀ / VOLUME
|
||||
_buildPacingMetricCard(
|
||||
title: 'QUANTITÀ FATTA',
|
||||
value: '${progress.totalActualPieces}',
|
||||
suffix: '/ ${progress.totalTargetS1}',
|
||||
note: progress.totalTargetS2 > 0
|
||||
? 'Sfida: ${progress.totalTargetS2}'
|
||||
: 'Target Minimo',
|
||||
color: theme.colorScheme.onSurface,
|
||||
backgroundColor: theme.colorScheme.surface,
|
||||
borderColor: theme.colorScheme.outlineVariant.withValues(alpha: 0.6),
|
||||
),
|
||||
|
||||
// 2. MEDIA ATTUALE
|
||||
_buildPacingMetricCard(
|
||||
title: 'MEDIA ATTUALE',
|
||||
value: progress.overallActualDailyRate.toStringAsFixed(1),
|
||||
suffix: '/ gg',
|
||||
note: 'Ritmo tenuto finora',
|
||||
color: theme.colorScheme.primary,
|
||||
backgroundColor: theme.colorScheme.primaryContainer.withValues(alpha: 0.2),
|
||||
borderColor: theme.colorScheme.primary.withValues(alpha: 0.35),
|
||||
),
|
||||
|
||||
// 3. MEDIA RICHIESTA S1 (Colorata in base al semaforo)
|
||||
() {
|
||||
final isS1Done = progress.totalActualPieces >= progress.totalTargetS1;
|
||||
Color cardColor;
|
||||
Color cardBg;
|
||||
Color cardBorder;
|
||||
String note;
|
||||
|
||||
if (isS1Done) {
|
||||
cardColor = greenTheme.primary;
|
||||
cardBg = greenTheme.background;
|
||||
cardBorder = greenTheme.border;
|
||||
note = 'Obiettivo centrato!';
|
||||
} else if (progress.overallRequiredDailyRateS1 <= progress.overallActualDailyRate) {
|
||||
cardColor = verdinoTheme.primary;
|
||||
cardBg = verdinoTheme.background;
|
||||
cardBorder = verdinoTheme.border;
|
||||
note = 'In linea col ritmo';
|
||||
} else if (progress.overallRequiredDailyRateS1 <= progress.overallActualDailyRate * 1.35) {
|
||||
cardColor = pinkTheme.primary;
|
||||
cardBg = pinkTheme.background;
|
||||
cardBorder = pinkTheme.border;
|
||||
note = 'Serve spingere';
|
||||
} else {
|
||||
cardColor = redTheme.primary;
|
||||
cardBg = redTheme.background;
|
||||
cardBorder = redTheme.border;
|
||||
note = 'Serve forte spinta';
|
||||
}
|
||||
|
||||
return _buildPacingMetricCard(
|
||||
title: 'MEDIA RICHIESTA S1',
|
||||
value: isS1Done
|
||||
? 'CENTRATO!'
|
||||
: progress.overallRequiredDailyRateS1.toStringAsFixed(1),
|
||||
suffix: isS1Done ? '🎉' : '/ gg',
|
||||
note: note,
|
||||
color: cardColor,
|
||||
backgroundColor: cardBg,
|
||||
borderColor: cardBorder,
|
||||
);
|
||||
}(),
|
||||
|
||||
// 4. MEDIA RICHIESTA S2 (se presente)
|
||||
if (progress.totalTargetS2 > 0) ...[
|
||||
() {
|
||||
final isS2Done = progress.totalActualPieces >= progress.totalTargetS2;
|
||||
return _buildPacingMetricCard(
|
||||
title: 'MEDIA RICHIESTA S2',
|
||||
value: isS2Done
|
||||
? 'CENTRATO!'
|
||||
: progress.overallRequiredDailyRateS2.toStringAsFixed(1),
|
||||
suffix: isS2Done ? '🚀' : '/ gg',
|
||||
note: isS2Done ? 'Sfidante raggiunto!' : 'Per lo sfidante',
|
||||
color: isS2Done ? greenTheme.primary : Colors.purple.shade700,
|
||||
backgroundColor: isS2Done ? greenTheme.background : Colors.purple.shade50,
|
||||
borderColor: isS2Done ? greenTheme.border : Colors.purple.shade200,
|
||||
);
|
||||
}(),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// Panoramica Categorie Attive con il loro rispettivo stato
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
...progress.categories.values
|
||||
.where((c) => c.hasTarget)
|
||||
.map((c) {
|
||||
if (c.isAchieved) {
|
||||
return _buildSmartChip(
|
||||
icon: Icons.emoji_events_rounded,
|
||||
label: '${c.label}: Preso! 🎉',
|
||||
color: greenTheme.text,
|
||||
backgroundColor: greenTheme.background,
|
||||
borderColor: greenTheme.border,
|
||||
);
|
||||
} else if (c.isInLineOnly) {
|
||||
return _buildSmartChip(
|
||||
icon: Icons.check_circle_outline_rounded,
|
||||
label: '${c.label}: In linea ✅',
|
||||
color: verdinoTheme.text,
|
||||
backgroundColor: verdinoTheme.background,
|
||||
borderColor: verdinoTheme.border,
|
||||
);
|
||||
} else if (c.isRecoverable) {
|
||||
return _buildSmartChip(
|
||||
icon: Icons.bolt_rounded,
|
||||
label: '${c.label}: Da spingere ⚡',
|
||||
color: pinkTheme.text,
|
||||
backgroundColor: pinkTheme.background,
|
||||
borderColor: pinkTheme.border,
|
||||
);
|
||||
} else {
|
||||
return _buildSmartChip(
|
||||
icon: Icons.warning_amber_rounded,
|
||||
label: '${c.label}: In ritardo 🔴',
|
||||
color: redTheme.text,
|
||||
backgroundColor: redTheme.background,
|
||||
borderColor: redTheme.border,
|
||||
);
|
||||
}
|
||||
}),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}(),
|
||||
] else ...[
|
||||
// Fallback indicatori totali di base se il progresso è ancora in calcolo
|
||||
// Fallback indicatori di base se il progresso è ancora in caricamento
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
_buildMetricBadge(
|
||||
label: 'Soglia 1 (Totale)',
|
||||
value: '$totalL1',
|
||||
label: 'Obiettivi Attivi',
|
||||
value: '$activeMetricsCount categorie',
|
||||
color: Colors.blue,
|
||||
icon: Icons.flag_outlined,
|
||||
),
|
||||
if (totalL2 > 0)
|
||||
_buildMetricBadge(
|
||||
label: 'Soglia 2 (Sfidante)',
|
||||
value: '$totalL2',
|
||||
color: Colors.deepPurple,
|
||||
icon: Icons.stars_outlined,
|
||||
),
|
||||
_buildMetricBadge(
|
||||
label: 'Addetti Coinvolti',
|
||||
value: '$staffCount assegnati',
|
||||
@@ -727,6 +662,7 @@ class _TargetListScreenState extends State<TargetListScreen> {
|
||||
required Color color,
|
||||
required Color backgroundColor,
|
||||
required Color borderColor,
|
||||
IconData? icon,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
@@ -739,14 +675,23 @@ class _TargetListScreenState extends State<TargetListScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color.withValues(alpha: 0.85),
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: 14, color: color.withValues(alpha: 0.9)),
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color.withValues(alpha: 0.9),
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
@@ -757,18 +702,18 @@ class _TargetListScreenState extends State<TargetListScreen> {
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
suffix,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color.withValues(alpha: 0.8),
|
||||
color: color.withValues(alpha: 0.85),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -778,7 +723,7 @@ class _TargetListScreenState extends State<TargetListScreen> {
|
||||
note,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: color.withValues(alpha: 0.75),
|
||||
color: color.withValues(alpha: 0.8),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user