Semplifica condivisione link dopo test rete in app.

Mostra link diretta e regia solo a test completato; rimuove pulsante
duplicato e nasconde «Avvia test rete».

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-02 23:11:40 +02:00
parent 422d8848f6
commit 8882e7854f

View File

@@ -36,6 +36,7 @@ class StepNetworkTest extends ConsumerStatefulWidget {
class _StepNetworkTestState extends ConsumerState<StepNetworkTest> { class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
bool _testing = false; bool _testing = false;
bool _testCompleted = false;
bool _ready = false; bool _ready = false;
double _downloadMbps = 0; double _downloadMbps = 0;
double _uploadMbps = 0; double _uploadMbps = 0;
@@ -79,6 +80,7 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
if (mounted) { if (mounted) {
setState(() { setState(() {
_testing = false; _testing = false;
_testCompleted = true;
_downloadMbps = download; _downloadMbps = download;
_uploadMbps = upload; _uploadMbps = upload;
_latencyMs = latency; _latencyMs = latency;
@@ -139,6 +141,9 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(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( return SingleChildScrollView(
padding: ScreenInsets.contentPadding(context, horizontal: 20, vertical: 12), padding: ScreenInsets.contentPadding(context, horizontal: 20, vertical: 12),
@@ -185,7 +190,7 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
if (_ready) ...[ if (_testCompleted && _ready) ...[
Container( Container(
padding: const EdgeInsets.all(14), padding: const EdgeInsets.all(14),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -201,86 +206,54 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), ),
if (watchShareUrl(ref.read(sessionProvider).session!) != null) ...[ const SizedBox(height: 12),
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: 16), if (_testCompleted && session != null && shareUrl != null) ...[
Container( Container(
padding: const EdgeInsets.all(14), padding: const EdgeInsets.all(14),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppTheme.surfaceElevated, color: AppTheme.surfaceElevated,
borderRadius: BorderRadius.circular(10), 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}',
), ),
icon: const Icon(Icons.live_tv), child: Column(
label: Text( crossAxisAlignment: CrossAxisAlignment.stretch,
ref.read(sessionProvider).session!.platform == 'youtube' children: [
? 'Condividi link YouTube' Text(
: 'Condividi link diretta', 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), const SizedBox(height: 8),
@@ -288,7 +261,7 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
onPressed: () => shareRegiaLink( onPressed: () => shareRegiaLink(
context, context,
ref, ref,
sessionId: ref.read(sessionProvider).session!.id, sessionId: session.id,
shareSubject: shareSubject:
'Regia — ${widget.match.teamName} vs ${widget.match.opponentName}', 'Regia — ${widget.match.teamName} vs ${widget.match.opponentName}',
), ),
@@ -296,11 +269,27 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
label: const Text('Condividi link regia (punteggio)'), label: const Text('Condividi link regia (punteggio)'),
), ),
], ],
const SizedBox(height: 24), if (_testCompleted) ...[
OutlinedButton( const SizedBox(height: 16),
onPressed: _testing ? null : _runTest, Container(
child: Text(_testing ? 'TEST IN CORSO...' : 'AVVIA TEST RETE'), 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), const SizedBox(height: 32),
Row( Row(
children: [ children: [