Unifica admin società/squadre e YouTube Full con fallback MLTV.
Premium Full senza canale società usa il canale piattaforma come Light; in app restano solo Match Live TV e YouTube Live. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
import '../../providers/session_provider.dart';
|
||||
import '../../shared/api_client.dart';
|
||||
@@ -75,62 +73,17 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _connectYoutube(Team team) async {
|
||||
try {
|
||||
final url = await ref.read(apiClientProvider).youtubeAuthorizeUrl(team.id);
|
||||
final uri = Uri.parse(url);
|
||||
if (!await canLaunchUrl(uri)) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Impossibile aprire il browser per Google')),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'Completa il consenso Google, poi torna qui e seleziona YouTube Live.',
|
||||
),
|
||||
duration: Duration(seconds: 5),
|
||||
),
|
||||
);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final apiErr = ApiException.fromDio(e);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(apiErr?.message ?? 'Errore collegamento YouTube')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onYoutubeTap(Team? team) {
|
||||
if (team == null) return;
|
||||
if (team.isYoutubeReady) {
|
||||
setState(() => _platform = 'youtube');
|
||||
return;
|
||||
}
|
||||
if (team.canUseYoutube && team.youtubeMode == 'team' && team.canConnectYoutube) {
|
||||
_connectYoutube(team);
|
||||
return;
|
||||
}
|
||||
if (team.canUseYoutube && team.youtubeMode == 'team') {
|
||||
showPremiumRequiredDialog(
|
||||
context,
|
||||
message: 'Collega il canale YouTube (Premium Full) per trasmettere sul tuo canale.',
|
||||
billingUrl: team.staffManageUrl ?? team.billingUrl,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (team.canUseYoutube && team.youtubeMode == 'matchlivetv_light') {
|
||||
if (team.canUseYoutube) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'YouTube sul canale Match Live TV non è ancora attivo. Riprova più tardi o usa Match Live TV.',
|
||||
'YouTube non è ancora disponibile. Riprova più tardi o usa Match Live TV sul sito.',
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -152,23 +105,12 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
if (team.youtubeUsesPlatformChannel) {
|
||||
return label != null ? 'Canale $label' : 'Canale Match Live TV';
|
||||
}
|
||||
return label != null ? 'Canale $label' : 'Canale collegato';
|
||||
return label != null ? 'Canale $label' : 'Canale società collegato';
|
||||
}
|
||||
if (team.youtubeMode == 'matchlivetv_light') {
|
||||
if (team.youtubeMode == 'matchlivetv_light' || team.youtubeMode == 'team') {
|
||||
return 'Canale Match Live TV (in attivazione)';
|
||||
}
|
||||
if (team.canConnectYoutube) {
|
||||
return 'Tocca per collegare il tuo canale YouTube';
|
||||
}
|
||||
return 'Collega canale (Premium Full)';
|
||||
}
|
||||
|
||||
void _onExternalPremiumTap(String platform, Team? team) {
|
||||
showPremiumRequiredDialog(
|
||||
context,
|
||||
message: '$platform è disponibile con Premium (in arrivo).',
|
||||
billingUrl: team?.billingUrl,
|
||||
);
|
||||
return 'In attivazione';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -221,24 +163,6 @@ class _StepTransmissionState extends ConsumerState<StepTransmission> {
|
||||
badge: team?.canUseYoutube == true ? null : 'Premium',
|
||||
onTap: () => _onYoutubeTap(team),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_PlatformCard(
|
||||
title: 'Facebook Live',
|
||||
subtitle: 'Premium — presto disponibile',
|
||||
selected: false,
|
||||
enabled: false,
|
||||
badge: 'Premium',
|
||||
onTap: () => _onExternalPremiumTap('Facebook Live', team),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_PlatformCard(
|
||||
title: 'Twitch',
|
||||
subtitle: 'Premium — presto disponibile',
|
||||
selected: false,
|
||||
enabled: false,
|
||||
badge: 'Premium',
|
||||
onTap: () => _onExternalPremiumTap('Twitch', team),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text('Privacy', style: theme.textTheme.titleLarge),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Reference in New Issue
Block a user