102 lines
2.9 KiB
Dart
102 lines
2.9 KiB
Dart
import 'package:ac_web/Api/Dtos/ReportDto.dart';
|
|
import 'package:ac_web/Widgets/MarkdownText.dart';
|
|
import 'package:ac_web/Widgets/ReportTypeIcons.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// Page that shows every detail of a single report, including the full text.
|
|
class ReportDetails extends StatelessWidget{
|
|
const ReportDetails({super.key, required this.report});
|
|
|
|
final ReportDto report;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
final DateTime local = report.timestamp.toLocal();
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(report.title.isEmpty ? "Report" : report.title),
|
|
),
|
|
body: SingleChildScrollView(
|
|
padding: EdgeInsetsGeometry.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
spacing: 12,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
spacing: 16,
|
|
children: [
|
|
CircleAvatar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
child: Icon(report.type.icon, color: Theme.of(context).colorScheme.onSurface),
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
report.title.isEmpty ? "Untitled Report" : report.title,
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
_buildInfoRow(context, "Type", report.type.displayName),
|
|
_buildInfoRow(context, "Author", report.author),
|
|
_buildInfoRow(context, "Date", _formatTimestamp(local)),
|
|
_buildInfoRow(context, "Id", report.id),
|
|
const Divider(),
|
|
if (report.text.isEmpty)
|
|
SelectableText(
|
|
"This report has no text.",
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
)
|
|
else
|
|
MarkdownText(data: report.text),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildInfoRow(BuildContext context, String label, String value) {
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
spacing: 8,
|
|
children: [
|
|
SizedBox(
|
|
width: 80,
|
|
child: Text(
|
|
label,
|
|
style: Theme.of(context).textTheme.labelLarge,
|
|
),
|
|
),
|
|
Expanded(child: SelectableText(value)),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// "15. August 2025, 14:32"
|
|
String _formatTimestamp(DateTime timestamp) {
|
|
final String hour = timestamp.hour.toString().padLeft(2, '0');
|
|
final String minute = timestamp.minute.toString().padLeft(2, '0');
|
|
|
|
return "${timestamp.day}. ${_monthNames[timestamp.month - 1]} ${timestamp.year}, $hour:$minute";
|
|
}
|
|
|
|
|
|
static const List<String> _monthNames = <String>[
|
|
"January",
|
|
"February",
|
|
"March",
|
|
"April",
|
|
"May",
|
|
"June",
|
|
"July",
|
|
"August",
|
|
"September",
|
|
"October",
|
|
"November",
|
|
"December",
|
|
];
|
|
}
|