Implemented Reports Screen and some Icon details
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:ac_web/Api/Dtos/EReportType.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.
|
||||
@@ -25,9 +25,13 @@ class ReportDetails extends StatelessWidget{
|
||||
spacing: 12,
|
||||
children: [
|
||||
Row(
|
||||
spacing: 8,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 16,
|
||||
children: [
|
||||
Icon(_iconOf(report.type)),
|
||||
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,
|
||||
@@ -79,22 +83,6 @@ class ReportDetails extends StatelessWidget{
|
||||
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",
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
import 'package:ac_web/Api/Dtos/EReportType.dart';
|
||||
import 'package:ac_web/Pages/ReportsByType.dart';
|
||||
import 'package:ac_web/Widgets/LatestReportHeader.dart';
|
||||
import 'package:ac_web/Widgets/ReportTypeIcons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Overview page that lists every available report type as a button.
|
||||
class Reports extends StatelessWidget {
|
||||
const Reports({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<Widget> widgets = <Widget>[];
|
||||
|
||||
widgets.add(LatestReportHeader(text: "Reports", bigHeader: true,));
|
||||
widgets.add(const SizedBox(height: 8));
|
||||
|
||||
for (final EReportType type in EReportType.values) {
|
||||
widgets.add(_buildButton(context, type));
|
||||
}
|
||||
|
||||
return ListView(
|
||||
padding: EdgeInsetsGeometry.all(8),
|
||||
children: widgets,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildButton(BuildContext context, EReportType type) {
|
||||
|
||||
final ColorScheme colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Material(
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
onTap: () => _openType(context, type),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
CircleAvatar(
|
||||
backgroundColor: colors.inversePrimary,
|
||||
child: Icon(type.icon, color: colors.onSurface),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
type.displayName,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.chevron_right),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Opens a page that only shows the reports of the given type.
|
||||
void _openType(BuildContext context, EReportType type) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (context) => ReportsByType(type: type),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:ac_web/Api/Dtos/EReportType.dart';
|
||||
import 'package:ac_web/Widgets/LatestReportColumn.dart';
|
||||
import 'package:ac_web/Widgets/ReportTypeIcons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Shows all reports of a single [EReportType], grouped by day just like the
|
||||
/// latest reports page.
|
||||
class ReportsByType extends StatelessWidget {
|
||||
const ReportsByType({super.key, required this.type});
|
||||
|
||||
final EReportType type;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
title: Row(
|
||||
children: <Widget>[
|
||||
Icon(type.icon),
|
||||
const SizedBox(width: 8),
|
||||
Text(type.displayName),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: LatestReportColumn(
|
||||
title: type.displayName,
|
||||
filterType: type,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user