Added Report Details page
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
import 'package:ac_web/Api/Dtos/EReportType.dart';
|
||||
import 'package:ac_web/Api/Dtos/ReportDto.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(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(_iconOf(report.type)),
|
||||
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(),
|
||||
SelectableText(
|
||||
report.text.isEmpty ? "This report has no text." : report.text,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 IconData _iconOf(EReportType type) {
|
||||
switch(type){
|
||||
case EReportType.log:
|
||||
return Icons.receipt_long;
|
||||
case EReportType.codeReview:
|
||||
return Icons.code;
|
||||
case EReportType.projectPlan:
|
||||
return Icons.assignment;
|
||||
case EReportType.research:
|
||||
return Icons.science;
|
||||
case EReportType.newspaper:
|
||||
return Icons.newspaper;
|
||||
case EReportType.unknown:
|
||||
return Icons.question_mark;
|
||||
}
|
||||
}
|
||||
|
||||
static const List<String> _monthNames = <String>[
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user