import 'package:flutter/material.dart';
import '../../core/localization/app_localizations.dart';
import '../../core/theme/app_colors.dart';
import '../../data/app_data_scope.dart';
import '../../models/tour.dart';
import '../tours/tour_detail_page.dart';
class TourCompletionPage extends StatelessWidget {
const TourCompletionPage({super.key, required this.tour});
final Tour tour;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context);
final lang = Localizations.localeOf(context).languageCode;
final store = AppDataScope.of(context);
final alternatives = store.tours
.where((t) =>
t.id != tour.id &&
(t.topicSlugs
.toSet()
.intersection(tour.topicSlugs.toSet())
.isNotEmpty ||
t.category == tour.category))
.take(3)
.toList();
return Scaffold(
appBar: AppBar(),
body: ListView(
padding: const EdgeInsets.fromLTRB(24, 30, 24, 36),
children: [
const Icon(Icons.celebration_rounded,
size: 72, color: AppColors.heartRed),
const SizedBox(height: 18),
Text(l10n.t('tourCompleteTitle'),
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.headlineMedium
?.copyWith(fontWeight: FontWeight.w900)),
const SizedBox(height: 8),
Text(
l10n.tf('tourCompleteSummary', {
'stops': tour.stops.length,
'distance': tour.distanceKm.toStringAsFixed(1),
'minutes': tour.durationMinutes
}),
textAlign: TextAlign.center,
style: const TextStyle(
color: AppColors.mutedInk, fontWeight: FontWeight.w700)),
const SizedBox(height: 28),
Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: AppColors.softPink,
borderRadius: BorderRadius.circular(22)),
child: Column(children: [
const Icon(Icons.favorite_rounded, color: AppColors.heartRed),
const SizedBox(height: 8),
Text(tour.title.get(lang),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w900)),
const SizedBox(height: 5),
Text(l10n.t('tourCompleteThanks'), textAlign: TextAlign.center),
]),
),
if (alternatives.isNotEmpty) ...[
const SizedBox(height: 30),
Text(l10n.t('nextUp'),
style: Theme.of(context)
.textTheme
.titleLarge
?.copyWith(fontWeight: FontWeight.w900)),
const SizedBox(height: 8),
for (final item in alternatives)
ListTile(
contentPadding: EdgeInsets.zero,
leading: const CircleAvatar(child: Icon(Icons.route_outlined)),
title: Text(item.title.get(lang)),
subtitle: Text(
'${item.durationMinutes} ${l10n.t('minutesShort')} · ${l10n.tf('tourStopsCount', {
'n': item.stops.length
})}'),
trailing: const Icon(Icons.arrow_forward_rounded),
onTap: () => Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => TourDetailPage(tour: item))),
),
],
const SizedBox(height: 24),
FilledButton.icon(
onPressed: () =>
Navigator.of(context).popUntil((route) => route.isFirst),
icon: const Icon(Icons.home_rounded),
label: Text(l10n.t('backToHome')),
),
],
),
);
}
}

