Sito marketing, SEO, legal, live programmata e branding Match Live Tv.
Logo e favicon nel header, partite programmate su web e mobile, reset password, pagine FAQ/sitemap, privacy/termini GDPR e icona Android «Match Live Tv». Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import '../../shared/widgets/primary_cta.dart';
|
||||
import '../../shared/widgets/screen_insets.dart';
|
||||
import 'resume_session_sheet.dart';
|
||||
import 'no_team_onboarding.dart';
|
||||
import 'schedule_match_sheet.dart';
|
||||
import 'team_providers.dart';
|
||||
|
||||
final matchesProvider = FutureProvider<List<MatchModel>>((ref) async {
|
||||
@@ -21,7 +22,16 @@ final matchesProvider = FutureProvider<List<MatchModel>>((ref) async {
|
||||
final teams = await ref.read(teamsProvider.future);
|
||||
if (teams.isEmpty) return [];
|
||||
final client = ref.read(apiClientProvider);
|
||||
return client.fetchMatches(teams.first.id);
|
||||
final list = await client.fetchMatches(teams.first.id);
|
||||
list.sort((a, b) {
|
||||
final sa = a.scheduledAt;
|
||||
final sb = b.scheduledAt;
|
||||
if (sa == null && sb == null) return 0;
|
||||
if (sa == null) return 1;
|
||||
if (sb == null) return -1;
|
||||
return sa.compareTo(sb);
|
||||
});
|
||||
return list;
|
||||
});
|
||||
|
||||
class MatchesScreen extends ConsumerWidget {
|
||||
@@ -195,9 +205,13 @@ class MatchesScreen extends ConsumerWidget {
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Nessuna partita programmata',
|
||||
style: theme.textTheme.bodyMedium,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Text(
|
||||
'Nessuna partita in calendario.\nTocca «Programma partita» per aggiungere data e ora.',
|
||||
style: theme.textTheme.bodyMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -226,11 +240,21 @@ class MatchesScreen extends ConsumerWidget {
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 20, 20, 20 + bottomInset),
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 8),
|
||||
child: PrimaryCta(
|
||||
label: 'NUOVA PARTITA',
|
||||
icon: Icons.add,
|
||||
onPressed: () => _createMatch(context, ref),
|
||||
label: 'PROGRAMMA PARTITA',
|
||||
icon: Icons.event_available,
|
||||
onPressed: () => _scheduleMatch(context, ref),
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 0, 20, 20 + bottomInset),
|
||||
child: TextButton.icon(
|
||||
onPressed: () => _createMatchQuick(context, ref),
|
||||
icon: const Icon(Icons.settings_outlined, size: 18),
|
||||
label: const Text('Crea e configura subito (senza orario)'),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -290,7 +314,70 @@ class MatchesScreen extends ConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _createMatch(BuildContext context, WidgetRef ref) async {
|
||||
Future<void> _scheduleMatch(BuildContext context, WidgetRef ref) async {
|
||||
final teams = await ref.read(teamsProvider.future);
|
||||
if (teams.isEmpty) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Nessuna squadra disponibile')),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final data = await showScheduleMatchSheet(context);
|
||||
if (data == null || !context.mounted) return;
|
||||
|
||||
try {
|
||||
final client = ref.read(apiClientProvider);
|
||||
final match = await client.createMatch(teams.first.id, {
|
||||
'opponent_name': data.opponentName,
|
||||
'scheduled_at': data.scheduledAt.toUtc().toIso8601String(),
|
||||
if (data.location != null) 'location': data.location,
|
||||
'sport': 'volleyball',
|
||||
'sets_to_win': 3,
|
||||
});
|
||||
ref.invalidate(matchesProvider);
|
||||
if (!context.mounted) return;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Partita programmata — visibile sul sito')),
|
||||
);
|
||||
|
||||
final configure = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: AppTheme.surface,
|
||||
title: const Text('Configurare ora?'),
|
||||
content: const Text(
|
||||
'Puoi preparare telefono e regia subito, oppure tornare quando sei in palestra.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Più tardi'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: FilledButton.styleFrom(backgroundColor: AppTheme.primaryRed),
|
||||
child: const Text('Configura'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (configure == true && context.mounted) {
|
||||
context.push('/setup/${match.id}/1');
|
||||
}
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Errore: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _createMatchQuick(BuildContext context, WidgetRef ref) async {
|
||||
final teams = await ref.read(teamsProvider.future);
|
||||
if (teams.isEmpty) {
|
||||
if (context.mounted) {
|
||||
@@ -311,6 +398,18 @@ class MatchesScreen extends ConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
String _matchStatusLabel(
|
||||
MatchModel match, {
|
||||
required bool canResume,
|
||||
required bool hasSession,
|
||||
}) {
|
||||
if (canResume) return 'RIPRENDI';
|
||||
if (hasSession) return 'IN CORSO';
|
||||
final at = match.scheduledAt;
|
||||
if (at != null && at.isAfter(DateTime.now())) return 'PROGRAMMATA';
|
||||
return 'AVVIA';
|
||||
}
|
||||
|
||||
class _MatchCard extends StatelessWidget {
|
||||
const _MatchCard({
|
||||
required this.match,
|
||||
@@ -374,7 +473,7 @@ class _MatchCard extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
canResume ? 'RIPRENDI' : (hasSession ? 'IN CORSO' : 'CONFIGURA'),
|
||||
_matchStatusLabel(match, canResume: canResume, hasSession: hasSession),
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
color: hasSession ? AppTheme.primaryRed : AppTheme.textSecondary,
|
||||
fontSize: 11,
|
||||
|
||||
161
mobile/lib/features/matches/schedule_match_sheet.dart
Normal file
161
mobile/lib/features/matches/schedule_match_sheet.dart
Normal file
@@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../app/theme.dart';
|
||||
import '../../shared/widgets/primary_cta.dart';
|
||||
|
||||
class ScheduleMatchResult {
|
||||
ScheduleMatchResult({
|
||||
required this.opponentName,
|
||||
required this.scheduledAt,
|
||||
this.location,
|
||||
});
|
||||
|
||||
final String opponentName;
|
||||
final DateTime scheduledAt;
|
||||
final String? location;
|
||||
}
|
||||
|
||||
Future<ScheduleMatchResult?> showScheduleMatchSheet(BuildContext context) {
|
||||
return showModalBottomSheet<ScheduleMatchResult>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: AppTheme.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (ctx) => const _ScheduleMatchSheet(),
|
||||
);
|
||||
}
|
||||
|
||||
class _ScheduleMatchSheet extends StatefulWidget {
|
||||
const _ScheduleMatchSheet();
|
||||
|
||||
@override
|
||||
State<_ScheduleMatchSheet> createState() => _ScheduleMatchSheetState();
|
||||
}
|
||||
|
||||
class _ScheduleMatchSheetState extends State<_ScheduleMatchSheet> {
|
||||
final _opponentController = TextEditingController();
|
||||
final _locationController = TextEditingController();
|
||||
late DateTime _scheduledAt;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final now = DateTime.now();
|
||||
_scheduledAt = DateTime(now.year, now.month, now.day, now.hour + 2, 0);
|
||||
if (_scheduledAt.isBefore(now)) {
|
||||
_scheduledAt = now.add(const Duration(hours: 2));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_opponentController.dispose();
|
||||
_locationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _pickDateTime() async {
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _scheduledAt,
|
||||
firstDate: DateTime.now().subtract(const Duration(days: 1)),
|
||||
lastDate: DateTime.now().add(const Duration(days: 365)),
|
||||
);
|
||||
if (date == null || !mounted) return;
|
||||
|
||||
final time = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(_scheduledAt),
|
||||
);
|
||||
if (time == null) return;
|
||||
|
||||
setState(() {
|
||||
_scheduledAt = DateTime(date.year, date.month, date.day, time.hour, time.minute);
|
||||
});
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
final opponent = _opponentController.text.trim();
|
||||
if (opponent.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Inserisci il nome dell’avversario')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.pop(
|
||||
context,
|
||||
ScheduleMatchResult(
|
||||
opponentName: opponent,
|
||||
scheduledAt: _scheduledAt,
|
||||
location: _locationController.text.trim().isEmpty
|
||||
? null
|
||||
: _locationController.text.trim(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final dateLabel = DateFormat('EEE d MMM yyyy · HH:mm', 'it_IT')
|
||||
.format(_scheduledAt.toLocal());
|
||||
final bottom = MediaQuery.paddingOf(context).bottom;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 12, 20, 20 + bottom),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.textSecondary.withValues(alpha: 0.4),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('Programma partita', style: theme.textTheme.titleLarge),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'La diretta non parte ora: comparirà sul sito con data e ora. '
|
||||
'Avvierai lo streaming dall’app quando sei in palestra.',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
TextField(
|
||||
controller: _opponentController,
|
||||
decoration: const InputDecoration(labelText: 'Avversario'),
|
||||
textCapitalization: TextCapitalization.words,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextField(
|
||||
controller: _locationController,
|
||||
decoration: const InputDecoration(labelText: 'Luogo (opzionale)'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text('Data e ora', style: theme.textTheme.bodyMedium),
|
||||
subtitle: Text(dateLabel, style: theme.textTheme.titleMedium),
|
||||
trailing: const Icon(Icons.calendar_today, color: AppTheme.primaryRed),
|
||||
onTap: _pickDateTime,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
PrimaryCta(
|
||||
label: 'SALVA IN PROGRAMMA',
|
||||
icon: Icons.event_available,
|
||||
onPressed: _submit,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user