App: scelta canale YouTube MLTV/società, privacy e condivisione link.
Premium Full può forzare il canale piattaforma; visibilità non in elenco o privato; share_url unificato per Match Live TV e YouTube. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import '../../providers/match_rules_provider.dart';
|
||||
import '../../providers/score_provider.dart';
|
||||
import '../../shared/api_client.dart';
|
||||
import '../../shared/regia_share.dart';
|
||||
import '../../shared/watch_share.dart';
|
||||
import '../../shared/models/score_state.dart';
|
||||
import '../../providers/session_provider.dart';
|
||||
import '../../shared/websocket_service.dart';
|
||||
@@ -232,6 +233,50 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _shareWatch() async {
|
||||
final session = ref.read(sessionProvider).session;
|
||||
final match = ref.read(sessionProvider).match;
|
||||
if (session == null) return;
|
||||
await shareWatchLink(
|
||||
context,
|
||||
session: session,
|
||||
title:
|
||||
'Diretta — ${match?.teamName ?? 'Casa'} vs ${match?.opponentName ?? 'Ospiti'}',
|
||||
);
|
||||
}
|
||||
|
||||
void _showShareMenu() {
|
||||
final session = ref.read(sessionProvider).session;
|
||||
if (session == null) return;
|
||||
final isYoutube = session.platform == 'youtube';
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.live_tv),
|
||||
title: Text(isYoutube ? 'Condividi link YouTube' : 'Condividi link diretta'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_shareWatch();
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.scoreboard),
|
||||
title: const Text('Condividi link regia (punteggio)'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_shareRegia();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _leaveSession() async {
|
||||
try {
|
||||
await StreamingChannel.stopStream();
|
||||
@@ -342,7 +387,7 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
||||
bitrateMbps: _bitrateMbps,
|
||||
fps: _fps,
|
||||
viewerCount: _viewerCount,
|
||||
onShareRegia: _shareRegia,
|
||||
onShare: _showShareMenu,
|
||||
onInterrupt: _interruptStream,
|
||||
onCloseStream: _closeStreamPermanently,
|
||||
pointsTarget: pointsTarget,
|
||||
@@ -358,7 +403,7 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
||||
bitrateMbps: _bitrateMbps,
|
||||
fps: _fps,
|
||||
viewerCount: _viewerCount,
|
||||
onShareRegia: _shareRegia,
|
||||
onShare: _showShareMenu,
|
||||
onInterrupt: _interruptStream,
|
||||
onCloseStream: _closeStreamPermanently,
|
||||
pointsTarget: pointsTarget,
|
||||
@@ -380,7 +425,7 @@ class _PortraitOverlay extends StatelessWidget {
|
||||
required this.bitrateMbps,
|
||||
required this.fps,
|
||||
required this.viewerCount,
|
||||
required this.onShareRegia,
|
||||
required this.onShare,
|
||||
required this.onInterrupt,
|
||||
required this.onCloseStream,
|
||||
required this.pointsTarget,
|
||||
@@ -395,7 +440,7 @@ class _PortraitOverlay extends StatelessWidget {
|
||||
final double bitrateMbps;
|
||||
final int fps;
|
||||
final int viewerCount;
|
||||
final VoidCallback onShareRegia;
|
||||
final VoidCallback onShare;
|
||||
final VoidCallback onInterrupt;
|
||||
final Future<void> Function() onCloseStream;
|
||||
final int pointsTarget;
|
||||
@@ -413,9 +458,9 @@ class _PortraitOverlay extends StatelessWidget {
|
||||
LiveBadge(elapsed: elapsed),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
onPressed: onShareRegia,
|
||||
onPressed: onShare,
|
||||
icon: const Icon(Icons.share),
|
||||
tooltip: 'Condividi link regia',
|
||||
tooltip: 'Condividi link',
|
||||
),
|
||||
CameraCompactMetrics(
|
||||
networkType: networkType,
|
||||
@@ -451,9 +496,9 @@ class _PortraitOverlay extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
OutlinedButton.icon(
|
||||
onPressed: onShareRegia,
|
||||
onPressed: onShare,
|
||||
icon: const Icon(Icons.share, size: 18),
|
||||
label: const Text('Condividi link regia'),
|
||||
label: const Text('Condividi link'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
OutlinedButton(
|
||||
@@ -485,7 +530,7 @@ class _LandscapeOverlay extends StatelessWidget {
|
||||
required this.bitrateMbps,
|
||||
required this.fps,
|
||||
required this.viewerCount,
|
||||
required this.onShareRegia,
|
||||
required this.onShare,
|
||||
required this.onInterrupt,
|
||||
required this.onCloseStream,
|
||||
required this.pointsTarget,
|
||||
@@ -501,7 +546,7 @@ class _LandscapeOverlay extends StatelessWidget {
|
||||
final double bitrateMbps;
|
||||
final int fps;
|
||||
final int viewerCount;
|
||||
final VoidCallback onShareRegia;
|
||||
final VoidCallback onShare;
|
||||
final VoidCallback onInterrupt;
|
||||
final Future<void> Function() onCloseStream;
|
||||
final int pointsTarget;
|
||||
@@ -557,9 +602,9 @@ class _LandscapeOverlay extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: onShareRegia,
|
||||
onPressed: onShare,
|
||||
icon: const Icon(Icons.share, color: Colors.white),
|
||||
tooltip: 'Condividi link regia',
|
||||
tooltip: 'Condividi link',
|
||||
),
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:math';
|
||||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
@@ -16,6 +15,7 @@ import '../../shared/models/score_state.dart';
|
||||
import '../../shared/models/stream_session.dart';
|
||||
import '../../shared/websocket_service.dart';
|
||||
import '../../shared/regia_share.dart';
|
||||
import '../../shared/watch_share.dart';
|
||||
import '../../shared/widgets/metric_card.dart';
|
||||
import '../../shared/widgets/primary_cta.dart';
|
||||
import '../../shared/widgets/screen_insets.dart';
|
||||
@@ -201,7 +201,7 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
if (ref.read(sessionProvider).session?.watchPageUrl != null) ...[
|
||||
if (watchShareUrl(ref.read(sessionProvider).session!) != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
@@ -213,25 +213,43 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'Link per gli spettatori',
|
||||
ref.read(sessionProvider).session!.platform == 'youtube'
|
||||
? 'Link video YouTube'
|
||||
: 'Link diretta Match Live TV',
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SelectableText(
|
||||
ref.read(sessionProvider).session!.watchPageUrl!,
|
||||
watchShareUrl(ref.read(sessionProvider).session!)!,
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
final url = ref.read(sessionProvider).session!.watchPageUrl!;
|
||||
Clipboard.setData(ClipboardData(text: url));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Link copiato')),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.link, size: 18),
|
||||
label: const Text('COPIA LINK DIRETTA'),
|
||||
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'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -251,19 +269,33 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
OutlinedButton.icon(
|
||||
onPressed: ref.read(sessionProvider).session == null
|
||||
? null
|
||||
: () => shareRegiaLink(
|
||||
context,
|
||||
ref,
|
||||
sessionId: ref.read(sessionProvider).session!.id,
|
||||
shareSubject:
|
||||
'Regia — ${widget.match.teamName} vs ${widget.match.opponentName}',
|
||||
),
|
||||
icon: const Icon(Icons.share),
|
||||
label: const Text('Condividi link regia (punteggio)'),
|
||||
),
|
||||
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),
|
||||
label: Text(
|
||||
ref.read(sessionProvider).session!.platform == 'youtube'
|
||||
? 'Condividi link YouTube'
|
||||
: 'Condividi link diretta',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => shareRegiaLink(
|
||||
context,
|
||||
ref,
|
||||
sessionId: ref.read(sessionProvider).session!.id,
|
||||
shareSubject:
|
||||
'Regia — ${widget.match.teamName} vs ${widget.match.opponentName}',
|
||||
),
|
||||
icon: const Icon(Icons.scoreboard),
|
||||
label: const Text('Condividi link regia (punteggio)'),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
OutlinedButton(
|
||||
onPressed: _testing ? null : _runTest,
|
||||
|
||||
@@ -31,8 +31,27 @@ class StepTransmission extends ConsumerStatefulWidget {
|
||||
class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
String _platform = 'matchlivetv';
|
||||
String _privacy = 'unlisted';
|
||||
String? _youtubeChannel;
|
||||
bool _creating = false;
|
||||
|
||||
void _syncYoutubeChannel(Team? team) {
|
||||
if (team == null) {
|
||||
_youtubeChannel = null;
|
||||
return;
|
||||
}
|
||||
if (!team.canChooseYoutubeChannel) {
|
||||
if (team.youtubeTeamChannelAvailable) {
|
||||
_youtubeChannel = 'team';
|
||||
} else if (team.youtubePlatformAvailable) {
|
||||
_youtubeChannel = 'platform';
|
||||
} else {
|
||||
_youtubeChannel = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
_youtubeChannel ??= 'platform';
|
||||
}
|
||||
|
||||
Future<void> _createSession() async {
|
||||
setState(() => _creating = true);
|
||||
try {
|
||||
@@ -40,6 +59,7 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
final session = await client.createSession(
|
||||
widget.match.id,
|
||||
platform: _platform,
|
||||
youtubeChannel: _platform == 'youtube' ? _youtubeChannel : null,
|
||||
privacyStatus: _privacy,
|
||||
qualityPreset: '720p_30_2.5mbps',
|
||||
targetBitrate: 2500000,
|
||||
@@ -76,7 +96,10 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
void _onYoutubeTap(Team? team) {
|
||||
if (team == null) return;
|
||||
if (team.isYoutubeReady) {
|
||||
setState(() => _platform = 'youtube');
|
||||
setState(() {
|
||||
_platform = 'youtube';
|
||||
_syncYoutubeChannel(team);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (team.canUseYoutube) {
|
||||
@@ -100,17 +123,20 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
if (team == null || !team.canUseYoutube) {
|
||||
return 'Premium Light o Full';
|
||||
}
|
||||
if (team.isYoutubeReady) {
|
||||
final label = team.youtubeChannelTitle;
|
||||
if (team.youtubeUsesPlatformChannel) {
|
||||
return label != null ? 'Canale $label' : 'Canale Match Live TV';
|
||||
}
|
||||
return label != null ? 'Canale $label' : 'Canale società collegato';
|
||||
}
|
||||
if (team.youtubeMode == 'matchlivetv_light' || team.youtubeMode == 'team') {
|
||||
if (!team.isYoutubeReady) {
|
||||
return 'Canale Match Live TV (in attivazione)';
|
||||
}
|
||||
return 'In attivazione';
|
||||
if (_platform == 'youtube' && team.canChooseYoutubeChannel) {
|
||||
return _youtubeChannel == 'team'
|
||||
? 'Canale ${team.youtubeTeamChannelTitle ?? "società"}'
|
||||
: 'Canale Match Live TV';
|
||||
}
|
||||
if (team.youtubeUsesPlatformChannel || team.youtubePlatformAvailable) {
|
||||
final label = team.youtubeChannelTitle;
|
||||
return label != null ? 'Canale $label' : 'Canale Match Live TV';
|
||||
}
|
||||
final label = team.youtubeTeamChannelTitle ?? team.youtubeChannelTitle;
|
||||
return label != null ? 'Canale $label' : 'Canale società collegato';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -122,7 +148,10 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
loading: () => const Center(child: CircularProgressIndicator(color: AppTheme.primaryRed)),
|
||||
error: (_, __) => const Center(child: Text('Errore caricamento squadra')),
|
||||
data: (team) {
|
||||
_syncYoutubeChannel(team);
|
||||
final youtubeSelectable = team != null && team.isYoutubeReady;
|
||||
final showYoutubeChannels =
|
||||
_platform == 'youtube' && team != null && team.canChooseYoutubeChannel;
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: ScreenInsets.contentPadding(context, horizontal: 20, vertical: 12),
|
||||
@@ -163,17 +192,60 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
badge: team?.canUseYoutube == true ? null : 'Premium',
|
||||
onTap: () => _onYoutubeTap(team),
|
||||
),
|
||||
if (showYoutubeChannels) ...[
|
||||
const SizedBox(height: 16),
|
||||
Text('Canale YouTube', style: theme.textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
_PlatformCard(
|
||||
title: 'Match Live TV',
|
||||
subtitle: 'Canale ufficiale della piattaforma',
|
||||
selected: _youtubeChannel == 'platform',
|
||||
enabled: true,
|
||||
onTap: () => setState(() => _youtubeChannel = 'platform'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_PlatformCard(
|
||||
title: team!.youtubeTeamChannelTitle ?? 'Canale società',
|
||||
subtitle: 'Il tuo canale collegato',
|
||||
selected: _youtubeChannel == 'team',
|
||||
enabled: true,
|
||||
onTap: () => setState(() => _youtubeChannel = 'team'),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
Text('Privacy', style: theme.textTheme.titleLarge),
|
||||
Text('Visibilità video', style: theme.textTheme.titleLarge),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Solo per YouTube. Su Match Live TV la pagina diretta segue le impostazioni del sito.',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SegmentedButton<String>(
|
||||
segments: const [
|
||||
ButtonSegment(value: 'public', label: Text('Pubblico')),
|
||||
ButtonSegment(value: 'unlisted', label: Text('Non in elenco')),
|
||||
ButtonSegment(
|
||||
value: 'unlisted',
|
||||
label: Text('Non in elenco'),
|
||||
icon: Icon(Icons.link),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: 'private',
|
||||
label: Text('Privato'),
|
||||
icon: Icon(Icons.lock_outline),
|
||||
),
|
||||
],
|
||||
selected: {_privacy},
|
||||
onSelectionChanged: (s) => setState(() => _privacy = s.first),
|
||||
onSelectionChanged: _platform == 'youtube'
|
||||
? (s) => setState(() => _privacy = s.first)
|
||||
: null,
|
||||
),
|
||||
if (_platform != 'youtube')
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
'Seleziona YouTube Live per impostare la visibilità del video.',
|
||||
style: theme.textTheme.bodySmall?.copyWith(color: AppTheme.textSecondary),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text('Qualità', style: theme.textTheme.titleLarge),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Reference in New Issue
Block a user