From 8882e7854f020bf03a6a9e883b323ddc02045b32 Mon Sep 17 00:00:00 2001 From: Emiliano Frascaro Date: Tue, 2 Jun 2026 23:11:40 +0200 Subject: [PATCH] Semplifica condivisione link dopo test rete in app. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mostra link diretta e regia solo a test completato; rimuove pulsante duplicato e nasconde «Avvia test rete». Co-authored-by: Cursor --- .../setup_wizard/step_network_test.dart | 159 ++++++++---------- 1 file changed, 74 insertions(+), 85 deletions(-) diff --git a/mobile/lib/features/setup_wizard/step_network_test.dart b/mobile/lib/features/setup_wizard/step_network_test.dart index ca1c639..cccf7f3 100644 --- a/mobile/lib/features/setup_wizard/step_network_test.dart +++ b/mobile/lib/features/setup_wizard/step_network_test.dart @@ -36,6 +36,7 @@ class StepNetworkTest extends ConsumerStatefulWidget { class _StepNetworkTestState extends ConsumerState { bool _testing = false; + bool _testCompleted = false; bool _ready = false; double _downloadMbps = 0; double _uploadMbps = 0; @@ -79,6 +80,7 @@ class _StepNetworkTestState extends ConsumerState { if (mounted) { setState(() { _testing = false; + _testCompleted = true; _downloadMbps = download; _uploadMbps = upload; _latencyMs = latency; @@ -139,6 +141,9 @@ class _StepNetworkTestState extends ConsumerState { @override Widget build(BuildContext context) { final theme = Theme.of(context); + final session = ref.watch(sessionProvider).session; + final shareUrl = session != null ? watchShareUrl(session) : null; + final shareTitle = 'Diretta — ${widget.match.teamName} vs ${widget.match.opponentName}'; return SingleChildScrollView( padding: ScreenInsets.contentPadding(context, horizontal: 20, vertical: 12), @@ -185,7 +190,7 @@ class _StepNetworkTestState extends ConsumerState { ), ), const SizedBox(height: 20), - if (_ready) ...[ + if (_testCompleted && _ready) ...[ Container( padding: const EdgeInsets.all(14), decoration: BoxDecoration( @@ -201,86 +206,54 @@ class _StepNetworkTestState extends ConsumerState { textAlign: TextAlign.center, ), ), - if (watchShareUrl(ref.read(sessionProvider).session!) != null) ...[ - const SizedBox(height: 12), - Container( - padding: const EdgeInsets.all(14), - decoration: BoxDecoration( - color: AppTheme.surfaceElevated, - borderRadius: BorderRadius.circular(10), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - ref.read(sessionProvider).session!.platform == 'youtube' - ? 'Link video YouTube' - : 'Link diretta Match Live TV', - style: theme.textTheme.titleSmall, - ), - const SizedBox(height: 8), - SelectableText( - watchShareUrl(ref.read(sessionProvider).session!)!, - style: theme.textTheme.bodySmall, - ), - const SizedBox(height: 8), - Row( - children: [ - Expanded( - child: OutlinedButton.icon( - onPressed: () => copyWatchLink( - context, - ref.read(sessionProvider).session!, - ), - icon: const Icon(Icons.link, size: 18), - label: const Text('COPIA'), - ), - ), - const SizedBox(width: 8), - Expanded( - child: OutlinedButton.icon( - onPressed: () => shareWatchLink( - context, - session: ref.read(sessionProvider).session!, - title: - 'Diretta — ${widget.match.teamName} vs ${widget.match.opponentName}', - ), - icon: const Icon(Icons.share, size: 18), - label: const Text('CONDIVIDI'), - ), - ), - ], - ), - ], - ), - ), - ], + const SizedBox(height: 12), ], - const SizedBox(height: 16), - Container( - padding: const EdgeInsets.all(14), - decoration: BoxDecoration( - color: AppTheme.surfaceElevated, - borderRadius: BorderRadius.circular(10), - ), - child: Text( - 'In caso di disconnessione, lo stream resta attivo con slate per massimo 5 minuti mentre il telefono riconnette.', - style: theme.textTheme.bodyMedium, - ), - ), - const SizedBox(height: 16), - if (ref.read(sessionProvider).session != null) ...[ - OutlinedButton.icon( - onPressed: () => shareWatchLink( - context, - session: ref.read(sessionProvider).session!, - title: 'Diretta — ${widget.match.teamName} vs ${widget.match.opponentName}', + if (_testCompleted && session != null && shareUrl != null) ...[ + Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: AppTheme.surfaceElevated, + borderRadius: BorderRadius.circular(10), ), - icon: const Icon(Icons.live_tv), - label: Text( - ref.read(sessionProvider).session!.platform == 'youtube' - ? 'Condividi link YouTube' - : 'Condividi link diretta', + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + session.platform == 'youtube' + ? 'Link video YouTube' + : 'Link diretta Match Live TV', + style: theme.textTheme.titleSmall, + ), + const SizedBox(height: 8), + SelectableText( + shareUrl, + style: theme.textTheme.bodySmall, + ), + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: OutlinedButton.icon( + onPressed: () => copyWatchLink(context, session), + icon: const Icon(Icons.link, size: 18), + label: const Text('COPIA'), + ), + ), + const SizedBox(width: 8), + Expanded( + child: OutlinedButton.icon( + onPressed: () => shareWatchLink( + context, + session: session, + title: shareTitle, + ), + icon: const Icon(Icons.share, size: 18), + label: const Text('CONDIVIDI'), + ), + ), + ], + ), + ], ), ), const SizedBox(height: 8), @@ -288,7 +261,7 @@ class _StepNetworkTestState extends ConsumerState { onPressed: () => shareRegiaLink( context, ref, - sessionId: ref.read(sessionProvider).session!.id, + sessionId: session.id, shareSubject: 'Regia — ${widget.match.teamName} vs ${widget.match.opponentName}', ), @@ -296,11 +269,27 @@ class _StepNetworkTestState extends ConsumerState { label: const Text('Condividi link regia (punteggio)'), ), ], - const SizedBox(height: 24), - OutlinedButton( - onPressed: _testing ? null : _runTest, - child: Text(_testing ? 'TEST IN CORSO...' : 'AVVIA TEST RETE'), - ), + if (_testCompleted) ...[ + const SizedBox(height: 16), + Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: AppTheme.surfaceElevated, + borderRadius: BorderRadius.circular(10), + ), + child: Text( + 'In caso di disconnessione, lo stream resta attivo con slate per massimo 5 minuti mentre il telefono riconnette.', + style: theme.textTheme.bodyMedium, + ), + ), + ], + if (!_testCompleted) ...[ + const SizedBox(height: 24), + OutlinedButton( + onPressed: _testing ? null : _runTest, + child: Text(_testing ? 'TEST IN CORSO...' : 'AVVIA TEST RETE'), + ), + ], const SizedBox(height: 32), Row( children: [