Initial commit: monorepo Match Live TV.
Rails API, app Flutter, infrastruttura Docker/MediaMTX, sito marketing e documentazione di deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
39
mobile/lib/shared/widgets/camera_compact_metrics.dart
Normal file
39
mobile/lib/shared/widgets/camera_compact_metrics.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Riga compatta metriche stream (sostituisce le MetricCard ingombranti in camera).
|
||||
class CameraCompactMetrics extends StatelessWidget {
|
||||
const CameraCompactMetrics({
|
||||
super.key,
|
||||
required this.networkType,
|
||||
required this.bitrateMbps,
|
||||
required this.fps,
|
||||
this.batteryLevel,
|
||||
this.viewerCount,
|
||||
this.light = false,
|
||||
});
|
||||
|
||||
final String networkType;
|
||||
final double bitrateMbps;
|
||||
final int fps;
|
||||
final int? batteryLevel;
|
||||
final int? viewerCount;
|
||||
final bool light;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = light ? Colors.white70 : Theme.of(context).textTheme.bodySmall?.color;
|
||||
final parts = <String>[
|
||||
networkType,
|
||||
'${bitrateMbps.toStringAsFixed(1)} Mbps',
|
||||
'$fps fps',
|
||||
if (batteryLevel != null) '$batteryLevel%',
|
||||
if (viewerCount != null && viewerCount! > 0) '$viewerCount spett.',
|
||||
];
|
||||
return Text(
|
||||
parts.join(' · '),
|
||||
style: TextStyle(fontSize: 11, color: color, fontWeight: FontWeight.w500),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
}
|
||||
303
mobile/lib/shared/widgets/camera_score_controls.dart
Normal file
303
mobile/lib/shared/widgets/camera_score_controls.dart
Normal file
@@ -0,0 +1,303 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
import '../../features/controller_mode/controller_screen.dart';
|
||||
import 'score_overlay_bar.dart';
|
||||
|
||||
/// Controlli punteggio per overlay camera (portrait e landscape).
|
||||
class CameraScoreControls extends StatelessWidget {
|
||||
const CameraScoreControls({
|
||||
super.key,
|
||||
required this.homeName,
|
||||
required this.awayName,
|
||||
required this.homePoints,
|
||||
required this.awayPoints,
|
||||
required this.currentSet,
|
||||
required this.homeSets,
|
||||
required this.awaySets,
|
||||
required this.onHomePoint,
|
||||
required this.onAwayPoint,
|
||||
required this.onHomeMinus,
|
||||
required this.onAwayMinus,
|
||||
required this.onCloseSet,
|
||||
this.lastDelta,
|
||||
this.compact = false,
|
||||
this.pointsTarget,
|
||||
});
|
||||
|
||||
final String homeName;
|
||||
final String awayName;
|
||||
final int homePoints;
|
||||
final int awayPoints;
|
||||
final int currentSet;
|
||||
final int homeSets;
|
||||
final int awaySets;
|
||||
final VoidCallback onHomePoint;
|
||||
final VoidCallback onAwayPoint;
|
||||
final VoidCallback onHomeMinus;
|
||||
final VoidCallback onAwayMinus;
|
||||
final VoidCallback onCloseSet;
|
||||
final int? lastDelta;
|
||||
final bool compact;
|
||||
final int? pointsTarget;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (compact) {
|
||||
return _LandscapeControls(
|
||||
homeName: homeName,
|
||||
awayName: awayName,
|
||||
homePoints: homePoints,
|
||||
awayPoints: awayPoints,
|
||||
currentSet: currentSet,
|
||||
homeSets: homeSets,
|
||||
awaySets: awaySets,
|
||||
lastDelta: lastDelta,
|
||||
pointsTarget: pointsTarget,
|
||||
onHomePoint: onHomePoint,
|
||||
onAwayPoint: onAwayPoint,
|
||||
onHomeMinus: onHomeMinus,
|
||||
onAwayMinus: onAwayMinus,
|
||||
onCloseSet: onCloseSet,
|
||||
);
|
||||
}
|
||||
|
||||
return _PortraitControls(
|
||||
homeName: homeName,
|
||||
awayName: awayName,
|
||||
homePoints: homePoints,
|
||||
awayPoints: awayPoints,
|
||||
currentSet: currentSet,
|
||||
homeSets: homeSets,
|
||||
awaySets: awaySets,
|
||||
pointsTarget: pointsTarget,
|
||||
onHomePoint: onHomePoint,
|
||||
onAwayPoint: onAwayPoint,
|
||||
onHomeMinus: onHomeMinus,
|
||||
onAwayMinus: onAwayMinus,
|
||||
onCloseSet: onCloseSet,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PortraitControls extends StatelessWidget {
|
||||
const _PortraitControls({
|
||||
required this.homeName,
|
||||
required this.awayName,
|
||||
required this.homePoints,
|
||||
required this.awayPoints,
|
||||
required this.currentSet,
|
||||
required this.homeSets,
|
||||
required this.awaySets,
|
||||
required this.onHomePoint,
|
||||
required this.onAwayPoint,
|
||||
required this.onHomeMinus,
|
||||
required this.onAwayMinus,
|
||||
required this.onCloseSet,
|
||||
this.pointsTarget,
|
||||
});
|
||||
|
||||
final String homeName;
|
||||
final String awayName;
|
||||
final int homePoints;
|
||||
final int awayPoints;
|
||||
final int currentSet;
|
||||
final int homeSets;
|
||||
final int awaySets;
|
||||
final VoidCallback onHomePoint;
|
||||
final VoidCallback onAwayPoint;
|
||||
final VoidCallback onHomeMinus;
|
||||
final VoidCallback onAwayMinus;
|
||||
final VoidCallback onCloseSet;
|
||||
final int? pointsTarget;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ScoreOverlayBar(
|
||||
homeName: homeName,
|
||||
awayName: awayName,
|
||||
homePoints: homePoints,
|
||||
awayPoints: awayPoints,
|
||||
currentSet: currentSet,
|
||||
homeSets: homeSets,
|
||||
awaySets: awaySets,
|
||||
pointsTarget: pointsTarget,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ScoreTapButton(label: '+1 $homeName', onTap: onHomePoint, large: true),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: ScoreTapButton(label: '+1 $awayName', onTap: onAwayPoint, large: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: homePoints > 0 ? onHomeMinus : null,
|
||||
child: Text('-1 $homeName', style: const TextStyle(fontSize: 12)),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: awayPoints > 0 ? onAwayMinus : null,
|
||||
child: Text('-1 $awayName', style: const TextStyle(fontSize: 12)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
YellowActionButton(label: 'Chiudi set', onPressed: onCloseSet),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LandscapeControls extends StatelessWidget {
|
||||
const _LandscapeControls({
|
||||
required this.homeName,
|
||||
required this.awayName,
|
||||
required this.homePoints,
|
||||
required this.awayPoints,
|
||||
required this.currentSet,
|
||||
required this.homeSets,
|
||||
required this.awaySets,
|
||||
required this.onHomePoint,
|
||||
required this.onAwayPoint,
|
||||
required this.onHomeMinus,
|
||||
required this.onAwayMinus,
|
||||
required this.onCloseSet,
|
||||
this.lastDelta,
|
||||
this.pointsTarget,
|
||||
});
|
||||
|
||||
final String homeName;
|
||||
final String awayName;
|
||||
final int homePoints;
|
||||
final int awayPoints;
|
||||
final int currentSet;
|
||||
final int homeSets;
|
||||
final int awaySets;
|
||||
final VoidCallback onHomePoint;
|
||||
final VoidCallback onAwayPoint;
|
||||
final VoidCallback onHomeMinus;
|
||||
final VoidCallback onAwayMinus;
|
||||
final VoidCallback onCloseSet;
|
||||
final int? lastDelta;
|
||||
final int? pointsTarget;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ScoreOverlayBar(
|
||||
homeName: homeName,
|
||||
awayName: awayName,
|
||||
homePoints: homePoints,
|
||||
awayPoints: awayPoints,
|
||||
currentSet: currentSet,
|
||||
homeSets: homeSets,
|
||||
awaySets: awaySets,
|
||||
compact: true,
|
||||
lastDelta: lastDelta,
|
||||
pointsTarget: pointsTarget,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _CompactScoreBtn(label: '+1', sub: homeName, onTap: onHomePoint)),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(child: _CompactScoreBtn(label: '+1', sub: awayName, onTap: onAwayPoint)),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: _CompactScoreBtn(
|
||||
label: '-1',
|
||||
sub: homeName,
|
||||
onTap: homePoints > 0 ? onHomeMinus : null,
|
||||
muted: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: _CompactScoreBtn(
|
||||
label: '-1',
|
||||
sub: awayName,
|
||||
onTap: awayPoints > 0 ? onAwayMinus : null,
|
||||
muted: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
YellowActionButton(label: 'Chiudi set', onPressed: onCloseSet),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CompactScoreBtn extends StatelessWidget {
|
||||
const _CompactScoreBtn({
|
||||
required this.label,
|
||||
required this.sub,
|
||||
required this.onTap,
|
||||
this.muted = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String sub;
|
||||
final VoidCallback? onTap;
|
||||
final bool muted;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final enabled = onTap != null;
|
||||
return Material(
|
||||
color: muted
|
||||
? Colors.black.withValues(alpha: enabled ? 0.65 : 0.35)
|
||||
: AppTheme.primaryRed.withValues(alpha: enabled ? 0.92 : 0.45),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: enabled ? Colors.white : Colors.white38,
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
sub,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: enabled ? Colors.white70 : Colors.white30,
|
||||
fontSize: 9,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
42
mobile/lib/shared/widgets/connected_badge.dart
Normal file
42
mobile/lib/shared/widgets/connected_badge.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// Dot verde + etichetta COLLEGATO.
|
||||
class ConnectedBadge extends StatelessWidget {
|
||||
const ConnectedBadge({
|
||||
super.key,
|
||||
this.connected = true,
|
||||
this.label,
|
||||
});
|
||||
|
||||
final bool connected;
|
||||
final String? label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final color = connected ? AppTheme.successGreen : AppTheme.textSecondary;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label ?? (connected ? 'COLLEGATO' : 'DISCONNESSO'),
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: color,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
65
mobile/lib/shared/widgets/destructive_cta.dart
Normal file
65
mobile/lib/shared/widgets/destructive_cta.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// CTA distruttiva nera con icona rossa (INTERROMPI, FERMA TRASMISSIONE).
|
||||
class DestructiveCta extends StatelessWidget {
|
||||
const DestructiveCta({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.onPressed,
|
||||
this.loading = false,
|
||||
this.compact = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
final bool loading;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return SizedBox(
|
||||
width: compact ? null : double.infinity,
|
||||
height: compact ? 44 : 52,
|
||||
child: OutlinedButton(
|
||||
onPressed: loading ? null : onPressed,
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.black,
|
||||
foregroundColor: AppTheme.primaryRed,
|
||||
side: BorderSide(
|
||||
color: AppTheme.primaryRed.withValues(alpha: 0.6),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(compact ? 10 : 12),
|
||||
),
|
||||
),
|
||||
child: loading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: AppTheme.primaryRed,
|
||||
),
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: compact ? MainAxisSize.min : MainAxisSize.max,
|
||||
children: [
|
||||
const Icon(Icons.stop_circle_outlined, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
label,
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: AppTheme.primaryRed,
|
||||
fontSize: compact ? 12 : 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
31
mobile/lib/shared/widgets/end_stream_dialog.dart
Normal file
31
mobile/lib/shared/widgets/end_stream_dialog.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// Conferma chiusura definitiva della diretta (non riprendibile).
|
||||
Future<bool> confirmEndStream(BuildContext context) async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: AppTheme.surface,
|
||||
title: const Text('Chiudi diretta'),
|
||||
content: const Text(
|
||||
'La diretta verrà chiusa definitivamente. '
|
||||
'Gli spettatori vedranno che lo stream è terminato e non potrai riprendere questa sessione.\n\n'
|
||||
'Per una pausa temporanea usa «Interrompi».',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Annulla'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: FilledButton.styleFrom(backgroundColor: AppTheme.primaryRed),
|
||||
child: const Text('Chiudi definitivamente'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return result == true;
|
||||
}
|
||||
59
mobile/lib/shared/widgets/live_badge.dart
Normal file
59
mobile/lib/shared/widgets/live_badge.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// Pill rossa con dot pulsante e timer diretta.
|
||||
class LiveBadge extends StatelessWidget {
|
||||
const LiveBadge({
|
||||
super.key,
|
||||
required this.elapsed,
|
||||
this.compact = false,
|
||||
});
|
||||
|
||||
final Duration elapsed;
|
||||
final bool compact;
|
||||
|
||||
String _format(Duration d) {
|
||||
final h = d.inHours;
|
||||
final m = d.inMinutes.remainder(60).toString().padLeft(2, '0');
|
||||
final s = d.inSeconds.remainder(60).toString().padLeft(2, '0');
|
||||
if (h > 0) return '$h:$m:$s';
|
||||
return '$m:$s';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: compact ? 10 : 14,
|
||||
vertical: compact ? 4 : 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.primaryRed,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: compact ? 6 : 8,
|
||||
height: compact ? 6 : 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
SizedBox(width: compact ? 6 : 8),
|
||||
Text(
|
||||
compact ? 'LIVE ${_format(elapsed)}' : 'IN DIRETTA ${_format(elapsed)}',
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: compact ? 11 : 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
74
mobile/lib/shared/widgets/match_live_wordmark.dart
Normal file
74
mobile/lib/shared/widgets/match_live_wordmark.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// Wordmark orizzontale: MATCH + pill LIVE + TV.
|
||||
class MatchLiveWordmark extends StatelessWidget {
|
||||
const MatchLiveWordmark({
|
||||
super.key,
|
||||
this.compact = false,
|
||||
this.showSlogan = false,
|
||||
});
|
||||
|
||||
final bool compact;
|
||||
final bool showSlogan;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final matchStyle = theme.textTheme.displaySmall?.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w900,
|
||||
letterSpacing: 1,
|
||||
);
|
||||
final tvStyle = theme.textTheme.displaySmall?.copyWith(
|
||||
color: AppTheme.textSecondary,
|
||||
fontWeight: FontWeight.w900,
|
||||
letterSpacing: 1,
|
||||
);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text('MATCH', style: matchStyle),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: compact ? 8 : 12,
|
||||
vertical: compact ? 2 : 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.primaryRed,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
'LIVE',
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: compact ? 14 : 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text('TV', style: tvStyle),
|
||||
],
|
||||
),
|
||||
if (showSlogan) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'LO STREAMING CHE NON MUORE',
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: AppTheme.textSecondary,
|
||||
fontSize: 12,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
65
mobile/lib/shared/widgets/metric_card.dart
Normal file
65
mobile/lib/shared/widgets/metric_card.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// Card metrica singola (segnale, Mbps, fps).
|
||||
class MetricCard extends StatelessWidget {
|
||||
const MetricCard({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.value,
|
||||
this.icon,
|
||||
this.highlight = false,
|
||||
this.expand = true,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
final IconData? icon;
|
||||
final bool highlight;
|
||||
final bool expand;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final card = Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.surfaceElevated,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: highlight
|
||||
? Border.all(color: AppTheme.successGreen.withValues(alpha: 0.5))
|
||||
: null,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: 18, color: AppTheme.textSecondary),
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
Text(
|
||||
value,
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
color: highlight ? AppTheme.successGreen : Colors.white,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(fontSize: 11),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (!expand) {
|
||||
return SizedBox(width: 72, child: card);
|
||||
}
|
||||
|
||||
return Expanded(child: card);
|
||||
}
|
||||
}
|
||||
66
mobile/lib/shared/widgets/primary_cta.dart
Normal file
66
mobile/lib/shared/widgets/primary_cta.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// CTA primaria rossa full-width (AVANTI, INIZIA).
|
||||
class PrimaryCta extends StatelessWidget {
|
||||
const PrimaryCta({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.onPressed,
|
||||
this.loading = false,
|
||||
this.icon,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
final bool loading;
|
||||
final IconData? icon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 52,
|
||||
child: ElevatedButton(
|
||||
onPressed: loading ? null : onPressed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryRed,
|
||||
foregroundColor: Colors.white,
|
||||
disabledBackgroundColor: AppTheme.primaryRed.withValues(alpha: 0.5),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
elevation: 0,
|
||||
),
|
||||
child: loading
|
||||
? const SizedBox(
|
||||
width: 22,
|
||||
height: 22,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w800,
|
||||
letterSpacing: 1,
|
||||
),
|
||||
),
|
||||
if (icon != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
Icon(icon, size: 20),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
96
mobile/lib/shared/widgets/score_outcome_dialogs.dart
Normal file
96
mobile/lib/shared/widgets/score_outcome_dialogs.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
import '../scoring/match_scoring_rules.dart';
|
||||
|
||||
Future<bool> showSetWonDialog(
|
||||
BuildContext context, {
|
||||
required ScoringSide winner,
|
||||
required String homeName,
|
||||
required String awayName,
|
||||
required int homePoints,
|
||||
required int awayPoints,
|
||||
}) async {
|
||||
final winnerName = winner == ScoringSide.home ? homeName : awayName;
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: AppTheme.surface,
|
||||
title: const Text('Set concluso'),
|
||||
content: Text(
|
||||
'$winnerName vince il set $homePoints-$awayPoints.\n\nChiudere il set e passare al successivo?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Continua a segnare'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: FilledButton.styleFrom(backgroundColor: AppTheme.accentYellow),
|
||||
child: const Text('Chiudi set', style: TextStyle(color: Colors.black)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return result == true;
|
||||
}
|
||||
|
||||
Future<bool> showCloseSetAnywayDialog(BuildContext context) async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: AppTheme.surface,
|
||||
title: const Text('Chiudi set'),
|
||||
content: const Text(
|
||||
'Il punteggio non soddisfa ancora le regole del torneo. Chiudere il set comunque?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Annulla'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
child: const Text('Chiudi comunque'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return result == true;
|
||||
}
|
||||
|
||||
Future<bool> showMatchWonDialog(
|
||||
BuildContext context, {
|
||||
required ScoringSide winner,
|
||||
required String homeName,
|
||||
required String awayName,
|
||||
required int homeSets,
|
||||
required int awaySets,
|
||||
}) async {
|
||||
final winnerName = winner == ScoringSide.home ? homeName : awayName;
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: AppTheme.surface,
|
||||
title: const Text('Partita terminata'),
|
||||
content: Text(
|
||||
'$winnerName vince la partita ($homeSets-$awaySets set).\n\nChiudere definitivamente la diretta?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Continua in onda'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: FilledButton.styleFrom(backgroundColor: AppTheme.primaryRed),
|
||||
child: const Text('Chiudi diretta'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return result == true;
|
||||
}
|
||||
133
mobile/lib/shared/widgets/score_overlay_bar.dart
Normal file
133
mobile/lib/shared/widgets/score_overlay_bar.dart
Normal file
@@ -0,0 +1,133 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
|
||||
/// Barra overlay punteggio: SET n | HOME x - AWAY y.
|
||||
class ScoreOverlayBar extends StatelessWidget {
|
||||
const ScoreOverlayBar({
|
||||
super.key,
|
||||
required this.homeName,
|
||||
required this.awayName,
|
||||
required this.homePoints,
|
||||
required this.awayPoints,
|
||||
required this.currentSet,
|
||||
this.homeSets,
|
||||
this.awaySets,
|
||||
this.compact = false,
|
||||
this.lastDelta,
|
||||
this.pointsTarget,
|
||||
});
|
||||
|
||||
final String homeName;
|
||||
final String awayName;
|
||||
final int homePoints;
|
||||
final int awayPoints;
|
||||
final int currentSet;
|
||||
final int? homeSets;
|
||||
final int? awaySets;
|
||||
final bool compact;
|
||||
final int? lastDelta;
|
||||
final int? pointsTarget;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final bg = Colors.black.withValues(alpha: 0.72);
|
||||
|
||||
final bar = Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: compact ? 10 : 14,
|
||||
vertical: compact ? 6 : 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: bg,
|
||||
borderRadius: BorderRadius.circular(compact ? 8 : 10),
|
||||
border: Border.all(color: Colors.white12),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
pointsTarget != null ? 'SET $currentSet → $pointsTarget' : 'SET $currentSet',
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: AppTheme.accentYellow,
|
||||
fontSize: compact ? 11 : 13,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
height: compact ? 14 : 18,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||
color: Colors.white24,
|
||||
),
|
||||
Text(
|
||||
homeName.toUpperCase(),
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontSize: compact ? 11 : 13,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'$homePoints',
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: compact ? 16 : 20,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
'-',
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
color: AppTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$awayPoints',
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: compact ? 16 : 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
awayName.toUpperCase(),
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontSize: compact ? 11 : 13,
|
||||
),
|
||||
),
|
||||
if (homeSets != null && awaySets != null) ...[
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
'($homeSets-$awaySets)',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(fontSize: 11),
|
||||
),
|
||||
],
|
||||
if (lastDelta != null && lastDelta != 0) ...[
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
lastDelta! > 0 ? '+$lastDelta' : '$lastDelta',
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: lastDelta! > 0 ? AppTheme.successGreen : AppTheme.primaryRed,
|
||||
fontSize: compact ? 11 : 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
if (!constraints.hasBoundedWidth) {
|
||||
return bar;
|
||||
}
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: bar,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
84
mobile/lib/shared/widgets/screen_insets.dart
Normal file
84
mobile/lib/shared/widgets/screen_insets.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Padding di sistema (status bar, notch, barra navigazione) con minimo configurabile.
|
||||
class ScreenInsets {
|
||||
ScreenInsets._();
|
||||
|
||||
static EdgeInsets of(BuildContext context, {double minimum = 8}) {
|
||||
final mq = MediaQuery.of(context);
|
||||
final padding = mq.padding;
|
||||
final view = mq.viewPadding;
|
||||
return EdgeInsets.only(
|
||||
left: math.max(math.max(padding.left, view.left), minimum),
|
||||
top: math.max(math.max(padding.top, view.top), minimum),
|
||||
right: math.max(math.max(padding.right, view.right), minimum),
|
||||
bottom: math.max(math.max(padding.bottom, view.bottom), minimum),
|
||||
);
|
||||
}
|
||||
|
||||
/// Padding per contenuti scrollabili (login, wizard, elenco partite).
|
||||
/// Overlay camera: in landscape su Android la barra nav può stare a sinistra.
|
||||
static EdgeInsets cameraOverlay(BuildContext context, {double minimum = 12}) {
|
||||
final base = of(context, minimum: minimum);
|
||||
final landscape =
|
||||
MediaQuery.orientationOf(context) == Orientation.landscape;
|
||||
if (landscape && base.left < 48) {
|
||||
return base.copyWith(left: 48);
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
static EdgeInsets contentPadding(
|
||||
BuildContext context, {
|
||||
double horizontal = 20,
|
||||
double vertical = 16,
|
||||
double minimum = 8,
|
||||
}) {
|
||||
final inset = of(context, minimum: minimum);
|
||||
return EdgeInsets.fromLTRB(
|
||||
math.max(inset.left, horizontal),
|
||||
math.max(inset.top, vertical),
|
||||
math.max(inset.right, horizontal),
|
||||
math.max(inset.bottom, vertical),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// SafeArea con padding minimo su tutti i lati (gestisce edge-to-edge Android).
|
||||
class AppSafeArea extends StatelessWidget {
|
||||
const AppSafeArea({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.minimum = 8,
|
||||
this.top = true,
|
||||
this.bottom = true,
|
||||
this.left = true,
|
||||
this.right = true,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final double minimum;
|
||||
final bool top;
|
||||
final bool bottom;
|
||||
final bool left;
|
||||
final bool right;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
minimum: EdgeInsets.only(
|
||||
left: left ? minimum : 0,
|
||||
top: top ? minimum : 0,
|
||||
right: right ? minimum : 0,
|
||||
bottom: bottom ? minimum : 0,
|
||||
),
|
||||
top: top,
|
||||
bottom: bottom,
|
||||
left: left,
|
||||
right: right,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user