72 lines
2.4 KiB
Dart
72 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
|
|
|
import 'cross_painter.dart';
|
|
|
|
class AppointmentTile extends StatelessWidget {
|
|
final Appointment appointment;
|
|
final bool crossedOut;
|
|
|
|
const AppointmentTile({super.key, required this.appointment, this.crossedOut = false});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isPast = appointment.endTime.isBefore(DateTime.now());
|
|
final color = appointment.color.withAlpha(isPast ? 160 : 255);
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.all(1),
|
|
child: Stack(
|
|
children: [
|
|
Positioned.fill(
|
|
child: Container(
|
|
padding: const EdgeInsets.all(4),
|
|
alignment: Alignment.topLeft,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.rectangle,
|
|
borderRadius: const BorderRadius.all(Radius.circular(7)),
|
|
color: color,
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
FittedBox(
|
|
fit: BoxFit.fitWidth,
|
|
child: Text(
|
|
appointment.subject,
|
|
style: const TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500),
|
|
maxLines: 1,
|
|
softWrap: false,
|
|
),
|
|
),
|
|
FittedBox(
|
|
fit: BoxFit.fitWidth,
|
|
child: Text(
|
|
appointment.location?.isNotEmpty == true ? appointment.location! : ' ',
|
|
maxLines: 3,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(color: Colors.white, fontSize: 10),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
if (crossedOut)
|
|
Positioned.fill(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(width: 2, color: Colors.red.withAlpha(200)),
|
|
borderRadius: const BorderRadius.all(Radius.circular(7)),
|
|
),
|
|
child: CustomPaint(painter: CrossPainter()),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|