Implemented Reports Screen and some Icon details
This commit is contained in:
@@ -4,10 +4,17 @@ import 'package:ac_web/Api/Dtos/ReportDto.dart';
|
||||
import 'package:ac_web/Pages/ReportDetails.dart';
|
||||
import 'package:ac_web/Widgets/LatestReportEntry.dart';
|
||||
import 'package:ac_web/Widgets/LatestReportHeader.dart';
|
||||
import 'package:ac_web/Widgets/ReportTypeIcons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LatestReportColumn extends StatefulWidget{
|
||||
const LatestReportColumn({super.key});
|
||||
const LatestReportColumn({super.key, this.title = "Latest Reports", this.filterType});
|
||||
|
||||
/// Headline drawn above the first day header.
|
||||
final String title;
|
||||
|
||||
/// When set, only reports of this type are shown.
|
||||
final EReportType? filterType;
|
||||
|
||||
@override
|
||||
State<LatestReportColumn> createState() => _LatestReportColumnState();
|
||||
@@ -38,7 +45,13 @@ class _LatestReportColumnState extends State<LatestReportColumn>{
|
||||
}
|
||||
|
||||
// The list of reports fetched from the ReportsController.
|
||||
final List<ReportDto> reports = snapshot.data ?? <ReportDto>[];
|
||||
List<ReportDto> reports = snapshot.data ?? <ReportDto>[];
|
||||
|
||||
if (widget.filterType != null) {
|
||||
reports = reports
|
||||
.where((report) => report.type == widget.filterType)
|
||||
.toList();
|
||||
}
|
||||
|
||||
return _buildList(reports);
|
||||
},
|
||||
@@ -49,8 +62,19 @@ class _LatestReportColumnState extends State<LatestReportColumn>{
|
||||
|
||||
List<Widget> widgets = <Widget>[];
|
||||
|
||||
if (reports.isEmpty) {
|
||||
return ListView(
|
||||
padding: EdgeInsetsGeometry.all(8),
|
||||
children: <Widget>[
|
||||
LatestReportHeader(text: widget.title, bigHeader: true,),
|
||||
const SizedBox(height: 16),
|
||||
const Text("No reports available."),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Title Entry
|
||||
widgets.add(LatestReportHeader(text: "Latest Reports", bigHeader: true,));
|
||||
widgets.add(LatestReportHeader(text: widget.title, bigHeader: true,));
|
||||
|
||||
DateTime? lastDay;
|
||||
|
||||
@@ -67,23 +91,7 @@ class _LatestReportColumnState extends State<LatestReportColumn>{
|
||||
|
||||
final ReportDto report = reports[i];
|
||||
|
||||
IconData icon;
|
||||
|
||||
switch(reports[i].type){
|
||||
|
||||
case EReportType.log:
|
||||
icon = Icons.receipt_long;
|
||||
case EReportType.codeReview:
|
||||
icon = Icons.code;
|
||||
case EReportType.projectPlan:
|
||||
icon = Icons.assignment;
|
||||
case EReportType.research:
|
||||
icon = Icons.science;
|
||||
case EReportType.newspaper:
|
||||
icon = Icons.newspaper;
|
||||
case EReportType.unknown:
|
||||
icon = Icons.question_mark;
|
||||
}
|
||||
final IconData icon = reports[i].type.icon;
|
||||
|
||||
widgets.add(LatestReportEntry(
|
||||
text: reports[i].title,
|
||||
|
||||
@@ -31,7 +31,10 @@ class LatestReportEntry extends StatelessWidget{
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon),
|
||||
CircleAvatar(
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
child: Icon(icon, color: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -53,8 +56,8 @@ class LatestReportEntry extends StatelessWidget{
|
||||
),
|
||||
),
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 8,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 16,
|
||||
),
|
||||
margin: EdgeInsetsGeometry.all(16),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:ac_web/Api/Dtos/EReportType.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Icons used for the different report types, so that every page draws a
|
||||
/// report type the same way.
|
||||
extension ReportTypeIcons on EReportType {
|
||||
IconData get icon {
|
||||
switch (this) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user