178 lines
4.8 KiB
Dart
178 lines
4.8 KiB
Dart
import 'package:aves/model/activity/activity_entry.dart';
|
|
import 'package:aves/model/activity/activity_preview_point.dart';
|
|
import 'package:aves/model/activity/activity_track.dart';
|
|
import 'package:aves/widgets/activity/preview/activity_entry_preview.dart';
|
|
import 'package:aves/widgets/activity/preview/activity_track_preview.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ActivityEntryListTile extends StatelessWidget {
|
|
final ActivityEntry entry;
|
|
final List<ActivityPreviewPoint> points;
|
|
|
|
final String dateLabel;
|
|
final String distanceLabel;
|
|
final String elevationLabel;
|
|
final String durationLabel;
|
|
|
|
final VoidCallback onTap;
|
|
final VoidCallback onToggleFavorite;
|
|
final VoidCallback onRename;
|
|
final VoidCallback onRecalculate;
|
|
final VoidCallback onInfo;
|
|
|
|
const ActivityEntryListTile({
|
|
super.key,
|
|
required this.entry,
|
|
required this.points,
|
|
required this.dateLabel,
|
|
required this.distanceLabel,
|
|
required this.elevationLabel,
|
|
required this.durationLabel,
|
|
required this.onTap,
|
|
required this.onToggleFavorite,
|
|
required this.onRename,
|
|
required this.onRecalculate,
|
|
required this.onInfo,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListTile(
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 12,
|
|
vertical: 8,
|
|
),
|
|
leading: ActivityEntryPreview(
|
|
points: points,
|
|
size: 64,
|
|
),
|
|
title: Text(
|
|
entry.bestName,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(dateLabel),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
[
|
|
entry.sport ?? 'Attività',
|
|
distanceLabel,
|
|
elevationLabel,
|
|
durationLabel,
|
|
if (entry.pointCount != null) '${entry.pointCount} punti',
|
|
].join(' · '),
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
trailing: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
IconButton(
|
|
icon: Icon(
|
|
entry.isFavorite ? Icons.favorite : Icons.favorite_border,
|
|
),
|
|
color: entry.isFavorite ? Theme.of(context).colorScheme.primary : null,
|
|
tooltip: entry.isFavorite ? 'Rimuovi dai preferiti' : 'Aggiungi ai preferiti',
|
|
onPressed: onToggleFavorite,
|
|
),
|
|
PopupMenuButton<String>(
|
|
tooltip: 'Azioni attività',
|
|
onSelected: (value) {
|
|
switch (value) {
|
|
case 'rename':
|
|
onRename();
|
|
break;
|
|
|
|
case 'recalculate':
|
|
onRecalculate();
|
|
break;
|
|
|
|
case 'info':
|
|
onInfo();
|
|
break;
|
|
}
|
|
},
|
|
itemBuilder: (context) => const [
|
|
PopupMenuItem(
|
|
value: 'rename',
|
|
child: Text('Modifica nome'),
|
|
),
|
|
PopupMenuItem(
|
|
value: 'recalculate',
|
|
child: Text('Ricalcola e confronta'),
|
|
),
|
|
PopupMenuItem(
|
|
value: 'info',
|
|
child: Text('Dettagli DB'),
|
|
),
|
|
],
|
|
),
|
|
const Icon(Icons.chevron_right),
|
|
],
|
|
),
|
|
onTap: onTap,
|
|
);
|
|
}
|
|
}
|
|
|
|
class ActivityTrackListTile extends StatelessWidget {
|
|
final ActivityTrack activity;
|
|
|
|
final VoidCallback onTap;
|
|
final VoidCallback onRecalculate;
|
|
|
|
const ActivityTrackListTile({
|
|
super.key,
|
|
required this.activity,
|
|
required this.onTap,
|
|
required this.onRecalculate,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListTile(
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 12,
|
|
vertical: 8,
|
|
),
|
|
leading: ActivityTrackPreview(
|
|
activity: activity,
|
|
size: 64,
|
|
),
|
|
title: Text(
|
|
activity.displayName,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(activity.dateLabel),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
[
|
|
activity.sportLabel,
|
|
activity.distanceLabel,
|
|
activity.elevationGainLabel,
|
|
activity.durationLabel,
|
|
'${activity.pointCount} punti',
|
|
].join(' · '),
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
trailing: IconButton(
|
|
icon: const Icon(Icons.calculate_outlined),
|
|
tooltip: 'Ricalcola e confronta',
|
|
onPressed: onRecalculate,
|
|
),
|
|
onTap: onTap,
|
|
);
|
|
}
|
|
}
|