Files
AcWeb/ac_web/lib/Widgets/LatestReportEntry.dart
T
2026-08-31 15:39:01 +02:00

77 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
class LatestReportEntry extends StatelessWidget{
const LatestReportEntry({
super.key,
required this.text,
required this.icon,
required this.author,
required this.timestamp,
this.onTap,
});
final String text;
final IconData icon;
final String author;
final DateTime timestamp;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
return Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadiusGeometry.circular(12)),
shadowColor: Colors.white,
color: Colors.black38,
margin: EdgeInsetsGeometry.fromLTRB(0, 8, 0, 8),
child:
InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Container(
child: Row(
children: [
Icon(icon),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
spacing: 4,
children: [
// Long titles are wrapped over multiple lines instead of overflowing.
Text(
text,
softWrap: true,
style: Theme.of(context).textTheme.titleMedium,
),
Text(
"$author • ${_timestampLabel()}",
softWrap: true,
style: Theme.of(context).textTheme.bodySmall,
),
],
),
),
],
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
),
margin: EdgeInsetsGeometry.all(16),
),
)
);
}
/// e.g. "15.08.2025 09:05"
String _timestampLabel() {
final DateTime local = timestamp.toLocal();
final String day = local.day.toString().padLeft(2, '0');
final String month = local.month.toString().padLeft(2, '0');
final String hour = local.hour.toString().padLeft(2, '0');
final String minute = local.minute.toString().padLeft(2, '0');
return "$day.$month.${local.year} $hour:$minute";
}
}