diff --git a/lib/features/home/dashboard_target_progress/ui/dashboard_target_hero_card.dart b/lib/features/home/dashboard_target_progress/ui/dashboard_target_hero_card.dart index 18b97b5..bcc31a1 100644 --- a/lib/features/home/dashboard_target_progress/ui/dashboard_target_hero_card.dart +++ b/lib/features/home/dashboard_target_progress/ui/dashboard_target_hero_card.dart @@ -158,163 +158,184 @@ class DashboardTargetHeroCard extends StatelessWidget { final remainingDays = progress.remainingWorkingDays; - return Container( - decoration: BoxDecoration( - color: theme.colorScheme.surface, - borderRadius: BorderRadius.circular(20), - border: Border.all( - color: theme.colorScheme.primary.withValues(alpha: 0.25), - width: 1.5, - ), - boxShadow: [ - BoxShadow( - color: theme.colorScheme.primary.withValues(alpha: 0.06), - blurRadius: 20, - offset: const Offset(0, 6), + return LayoutBuilder( + builder: (context, constraints) { + final isCompact = constraints.maxWidth < 600; + + return Container( + decoration: BoxDecoration( + color: theme.colorScheme.surface, + borderRadius: BorderRadius.circular(20), + border: Border.all( + color: theme.colorScheme.primary.withValues(alpha: 0.25), + width: 1.5, + ), + boxShadow: [ + BoxShadow( + color: theme.colorScheme.primary.withValues(alpha: 0.06), + blurRadius: 20, + offset: const Offset(0, 6), + ), + ], ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - // ========================================== - // 1. HEADER DELLA CARD (TITOLO & GIORNI) - // ========================================== - Padding( - padding: const EdgeInsets.fromLTRB(20, 18, 20, 14), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - theme.colorScheme.primary, - theme.colorScheme.primary.withValues(alpha: 0.8), - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: theme.colorScheme.primary.withValues(alpha: 0.25), - blurRadius: 8, - offset: const Offset(0, 2), - ), - ], - ), - child: const Icon( - Icons.trending_up_rounded, - color: Colors.white, - size: 22, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // ========================================== + // 1. HEADER DELLA CARD (TITOLO & GIORNI) + // ========================================== + Padding( + padding: EdgeInsets.fromLTRB( + isCompact ? 14 : 20, + isCompact ? 14 : 18, + isCompact ? 14 : 20, + isCompact ? 10 : 14, ), - const SizedBox(width: 14), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Flexible( - child: Text( - hasStaffTargets - ? 'IL TUO RITMO PER OGGI' - : 'RITMO GIORNALIERO NEGOZIO', - style: TextStyle( - fontSize: 11, - fontWeight: FontWeight.w800, - letterSpacing: 0.8, - color: theme.colorScheme.primary, - ), - ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(isCompact ? 8 : 10), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + theme.colorScheme.primary, + theme.colorScheme.primary.withValues(alpha: 0.8), + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: theme.colorScheme.primary + .withValues(alpha: 0.25), + blurRadius: 8, + offset: const Offset(0, 2), ), - const SizedBox(width: 8), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 2, - ), - decoration: BoxDecoration( - color: theme.colorScheme.primaryContainer - .withValues(alpha: 0.35), - borderRadius: BorderRadius.circular(6), - ), - child: Text( - remainingDays > 1 - ? 'Mancano $remainingDays gg' - : (remainingDays == 1 - ? 'Ultimo giorno!' - : 'Mese concluso'), - style: TextStyle( - fontSize: 11, - fontWeight: FontWeight.bold, - color: theme.colorScheme.primary, + ], + ), + child: Icon( + Icons.trending_up_rounded, + color: Colors.white, + size: isCompact ? 20 : 22, + ), + ), + SizedBox(width: isCompact ? 10 : 14), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + spacing: 8, + runSpacing: 4, + children: [ + Text( + hasStaffTargets + ? 'IL TUO RITMO PER OGGI' + : 'RITMO GIORNALIERO NEGOZIO', + style: TextStyle( + fontSize: isCompact ? 10.5 : 11, + fontWeight: FontWeight.w800, + letterSpacing: 0.6, + color: theme.colorScheme.primary, + ), ), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 7, + vertical: 2, + ), + decoration: BoxDecoration( + color: theme.colorScheme.primaryContainer + .withValues(alpha: 0.35), + borderRadius: BorderRadius.circular(6), + ), + child: Text( + remainingDays > 1 + ? 'Mancano $remainingDays gg' + : (remainingDays == 1 + ? 'Ultimo giorno!' + : 'Mese concluso'), + style: TextStyle( + fontSize: isCompact ? 10 : 11, + fontWeight: FontWeight.bold, + color: theme.colorScheme.primary, + ), + ), + ), + ], + ), + const SizedBox(height: 3), + Text( + hasStaffTargets + ? 'Cosa portare a casa oggi, $staffName' + : 'Obiettivi di ${target.store?.name ?? "Negozio"} per oggi', + style: theme.textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.w900, + fontSize: isCompact ? 15 : 17, ), ), ], ), - const SizedBox(height: 3), - Text( - hasStaffTargets - ? 'Cosa portare a casa oggi, $staffName' - : 'Obiettivi di ${target.store?.name ?? "Negozio"} per oggi', - style: theme.textTheme.titleMedium?.copyWith( - fontWeight: FontWeight.w900, - fontSize: 17, + ), + const SizedBox(width: 4), + // Tasto rapido dettaglio + if (isCompact) + IconButton( + onPressed: () => context.pushNamed( + Routes.targetDetail, + extra: target, + ), + icon: const Icon(Icons.analytics_outlined), + tooltip: 'Dettagli target', + color: theme.colorScheme.primary, + visualDensity: VisualDensity.compact, + ) + else + TextButton.icon( + onPressed: () => context.pushNamed( + Routes.targetDetail, + extra: target, + ), + icon: const Icon(Icons.analytics_outlined, size: 18), + label: const Text('Dettagli'), + style: TextButton.styleFrom( + visualDensity: VisualDensity.compact, + foregroundColor: theme.colorScheme.primary, + textStyle: const TextStyle(fontWeight: FontWeight.bold), ), ), - ], - ), - ), - // Tasto rapido dettaglio - TextButton.icon( - onPressed: () => context.pushNamed( - Routes.targetDetail, - extra: target, - ), - icon: const Icon(Icons.analytics_outlined, size: 18), - label: const Text('Dettagli'), - style: TextButton.styleFrom( - visualDensity: VisualDensity.compact, - foregroundColor: theme.colorScheme.primary, - textStyle: const TextStyle(fontWeight: FontWeight.bold), - ), - ), - ], - ), - ), - - // ========================================== - // 2. FOCUS METRICHE: MEDIE RICHIESTE PER OGGI - // ========================================== - if (displayCategories.isEmpty) - Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), - child: Text( - 'Nessun obiettivo attivo configurato per questo mese.', - style: TextStyle( - color: theme.colorScheme.onSurfaceVariant, - fontSize: 13, + ], ), ), - ) - else - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: LayoutBuilder( - builder: (context, constraints) { - final isWide = constraints.maxWidth > 700; - return GridView.builder( + // ========================================== + // 2. FOCUS METRICHE: MEDIE RICHIESTE PER OGGI + // ========================================== + if (displayCategories.isEmpty) + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 20, vertical: 12), + child: Text( + 'Nessun obiettivo attivo configurato per questo mese.', + style: TextStyle( + color: theme.colorScheme.onSurfaceVariant, + fontSize: 13, + ), + ), + ) + else + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: GridView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: displayCategories.length, gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: isWide ? 260 : 200, + maxCrossAxisExtent: + constraints.maxWidth > 700 ? 260 : 200, mainAxisExtent: 154, crossAxisSpacing: 10, mainAxisSpacing: 10, @@ -323,106 +344,116 @@ class DashboardTargetHeroCard extends StatelessWidget { final category = displayCategories[index]; return _buildCategoryDailyPacingCard(theme, category); }, - ); - }, - ), - ), + ), + ), - const SizedBox(height: 14), + const SizedBox(height: 14), - // ========================================== - // 3. SEZIONE INFERIORE: RIEPILOGO NEGOZIO - // ========================================== - Container( - decoration: BoxDecoration( - color: theme.colorScheme.surfaceContainerHighest - .withValues(alpha: 0.35), - borderRadius: const BorderRadius.vertical( - bottom: Radius.circular(19), - ), - border: Border( - top: BorderSide( - color: theme.dividerColor.withValues(alpha: 0.2), - ), - ), - ), - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), - child: Row( - children: [ - Icon( - Icons.storefront_outlined, - size: 18, - color: theme.colorScheme.primary, - ), - const SizedBox(width: 8), - Text( - 'Negozio:', - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w800, - color: theme.colorScheme.primary, - letterSpacing: 0.5, + // ========================================== + // 3. SEZIONE INFERIORE: RIEPILOGO NEGOZIO + // ========================================== + Container( + decoration: BoxDecoration( + color: theme.colorScheme.surfaceContainerHighest + .withValues(alpha: 0.35), + borderRadius: const BorderRadius.vertical( + bottom: Radius.circular(19), ), - ), - const SizedBox(width: 10), - // Badge sintetici del negozio - _buildMiniBadge( - label: '${progress.countAchieved}/${progress.countTotalActive} Presi', - color: const Color(0xFF15803D), - bgColor: const Color(0xFFDCFCE7), - ), - const SizedBox(width: 6), - _buildMiniBadge( - label: '${progress.countInLineOnly} In linea', - color: const Color(0xFF0D9488), - bgColor: const Color(0xFFCCFBF1), - ), - if (progress.countBehind > 0) ...[ - const SizedBox(width: 6), - _buildMiniBadge( - label: '${progress.countBehind} Sotto ritmo', - color: const Color(0xFFDC2626), - bgColor: const Color(0xFFFEE2E2), - ), - ], - const Spacer(), - InkWell( - onTap: () => context.pushNamed( - Routes.targetDetail, - extra: target, - ), - borderRadius: BorderRadius.circular(6), - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, + border: Border( + top: BorderSide( + color: theme.dividerColor.withValues(alpha: 0.2), ), - child: Row( - mainAxisSize: MainAxisSize.min, + ), + ), + padding: EdgeInsets.symmetric( + horizontal: isCompact ? 14 : 20, + vertical: 10, + ), + child: Wrap( + alignment: WrapAlignment.spaceBetween, + crossAxisAlignment: WrapCrossAlignment.center, + spacing: 10, + runSpacing: 8, + children: [ + Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + spacing: 6, + runSpacing: 4, children: [ - Text( - 'Apri analisi completa', - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: theme.colorScheme.primary, - ), - ), - const SizedBox(width: 4), Icon( - Icons.arrow_forward_rounded, - size: 14, + Icons.storefront_outlined, + size: 17, color: theme.colorScheme.primary, ), + Text( + 'Negozio:', + style: TextStyle( + fontSize: 11.5, + fontWeight: FontWeight.w800, + color: theme.colorScheme.primary, + letterSpacing: 0.5, + ), + ), + const SizedBox(width: 2), + // Badge sintetici del negozio + _buildMiniBadge( + label: + '${progress.countAchieved}/${progress.countTotalActive} Presi', + color: const Color(0xFF15803D), + bgColor: const Color(0xFFDCFCE7), + ), + _buildMiniBadge( + label: '${progress.countInLineOnly} In linea', + color: const Color(0xFF0D9488), + bgColor: const Color(0xFFCCFBF1), + ), + if (progress.countBehind > 0) + _buildMiniBadge( + label: '${progress.countBehind} Sotto ritmo', + color: const Color(0xFFDC2626), + bgColor: const Color(0xFFFEE2E2), + ), ], ), - ), + InkWell( + onTap: () => context.pushNamed( + Routes.targetDetail, + extra: target, + ), + borderRadius: BorderRadius.circular(6), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 4, + vertical: 2, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Apri analisi completa', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: theme.colorScheme.primary, + ), + ), + const SizedBox(width: 4), + Icon( + Icons.arrow_forward_rounded, + size: 14, + color: theme.colorScheme.primary, + ), + ], + ), + ), + ), + ], ), - ], - ), + ), + ], ), - ], - ), + ); + }, ); } diff --git a/pubspec.yaml b/pubspec.yaml index 96a0dcf..eb7d62e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flux description: "Gestione attività negozio di telefonia" publish_to: 'none' -version: 2.0.1+57 +version: 2.0.2+58 environment: sdk: ^3.11.3