Crossed out cancelled hours, implemented file uploading

This commit is contained in:
2023-05-23 21:12:56 +02:00
parent 047282c5aa
commit 06b7c18158
6 changed files with 208 additions and 104 deletions

View File

@ -0,0 +1,17 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class CrossPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.red.withAlpha(200)
..strokeWidth = 2.0;
canvas.drawLine(Offset(0, 0), Offset(size.width, size.height), paint);
canvas.drawLine(Offset(size.width, 0), Offset(0, size.height), paint);
}
@override
bool shouldRepaint(CrossPainter oldDelegate) => false;
}

View File

@ -1,18 +1,20 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:marianum_mobile/api/webuntis/queries/getTimetable/getTimetableResponse.dart';
import 'package:marianum_mobile/screen/pages/timetable/CrossPainter.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
class AppointmentComponent extends StatefulWidget {
final CalendarAppointmentDetails details;
const AppointmentComponent({Key? key, required this.details}) : super(key: key);
final bool crossedOut;
const AppointmentComponent({Key? key, required this.details, this.crossedOut = false}) : super(key: key);
@override
State<AppointmentComponent> createState() => _AppointmentComponentState();
}
class _AppointmentComponentState extends State<AppointmentComponent> {
@override
Widget build(BuildContext context) {
final Appointment meeting = widget.details.appointments.first;
@ -20,90 +22,106 @@ class _AppointmentComponentState extends State<AppointmentComponent> {
double headerHeight = 50;
const double footerHeight = 5;
final double infoHeight = appointmentHeight - (headerHeight + footerHeight);
if(infoHeight < 0) headerHeight += infoHeight;
if (infoHeight < 0) headerHeight += infoHeight;
return Column(
return Stack(
children: [
Container(
padding: const EdgeInsets.all(3),
height: headerHeight,
alignment: Alignment.topLeft,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(5),
topRight: Radius.circular(5)),
color: meeting.color,
),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FittedBox(
fit: BoxFit.fitWidth,
child: Text(
meeting.subject,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w500,
),
maxLines: 1,
softWrap: false,
),
),
FittedBox(
fit: BoxFit.fitWidth,
child: Text(
meeting.location ?? "?",
maxLines: 3,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: const TextStyle(
color: Colors.white,
fontSize: 10,
),
),
)
],
)),
),
Visibility(
visible: meeting.notes != null && infoHeight > 10,
replacement: Container(
color: meeting.color,
height: infoHeight,
),
child: Container(
height: infoHeight,
padding: const EdgeInsets.fromLTRB(3, 5, 3, 2),
color: meeting.color.withOpacity(0.8),
alignment: Alignment.topLeft,
child: SingleChildScrollView(
Column(
children: [
Container(
padding: const EdgeInsets.all(3),
height: headerHeight,
alignment: Alignment.topLeft,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(5),
topRight: Radius.circular(5),
),
color: meeting.color,
),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
meeting.notes ?? "",
style: const TextStyle(
color: Colors.white,
fontSize: 10,
FittedBox(
fit: BoxFit.fitWidth,
child: Text(
meeting.subject,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w500,
),
maxLines: 1,
softWrap: false,
),
),
FittedBox(
fit: BoxFit.fitWidth,
child: Text(
meeting.location ?? "?",
maxLines: 3,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: const TextStyle(
color: Colors.white,
fontSize: 10,
),
),
)
],
)),
),
),
),
),
Visibility(
visible: meeting.notes != null && infoHeight > 10,
replacement: Container(
color: meeting.color,
height: infoHeight,
),
child: Container(
height: infoHeight,
padding: const EdgeInsets.fromLTRB(3, 5, 3, 2),
color: meeting.color.withOpacity(0.8),
alignment: Alignment.topLeft,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
meeting.notes ?? "",
style: const TextStyle(
color: Colors.white,
fontSize: 10,
),
)
],
),
),
),
),
Container(
height: footerHeight,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(5),
bottomRight: Radius.circular(5),
),
color: meeting.color,
),
),
],
),
Container(
height: footerHeight,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(5),
bottomRight: Radius.circular(5)),
color: meeting.color,
Visibility(
visible: (meeting.id as GetTimetableResponseObject).code == "cancelled",
child: Positioned.fill(
child: CustomPaint(
painter: CrossPainter(),
),
),
),
],

View File

@ -115,7 +115,10 @@ class _TimetableState extends State<Timetable> {
),
timeRegionBuilder: (BuildContext context, TimeRegionDetails timeRegionDetails) => TimeRegionComponent(details: timeRegionDetails),
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) => AppointmentComponent(details: details),
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) => AppointmentComponent(
details: details,
crossedOut: value.getTimetableResponse.result.where((element) => element.id == details.appointments.first.id).firstOrNull?.code == "cancelled"
),
headerHeight: 0,
selectionDecoration: const BoxDecoration(),