Proper task pdf layout

This commit is contained in:
Marc Rejohn Castillano 2026-02-22 00:30:12 +08:00
parent 2d527b86aa
commit 90d3e6bf7b

View File

@ -23,7 +23,7 @@ Future<Uint8List> buildTaskPdfBytes(
List<TaskActivityLog> logs,
List<TaskAssignment> assignments,
List<Profile> profiles,
pdf.PdfPageFormat format,
pdf.PdfPageFormat? format,
) async {
final logoData = await rootBundle.load('crmc_logo.png');
final logoImage = pw.MemoryImage(logoData.buffer.asUint8List());
@ -93,19 +93,24 @@ Future<Uint8List> buildTaskPdfBytes(
doc.addPage(
pw.Page(
pageFormat: format,
pageFormat: format ?? pdf.PdfPageFormat.a4,
margin: pw.EdgeInsets.all(28),
build: (pw.Context ctx) {
return pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
pw.Row(
crossAxisAlignment: pw.CrossAxisAlignment.start,
pw.Center(
child: pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.center,
crossAxisAlignment: pw.CrossAxisAlignment.center,
children: [
pw.Container(width: 64, height: 64, child: pw.Image(logoImage)),
pw.SizedBox(width: 12),
pw.Expanded(
child: pw.Column(
pw.Container(
width: 80,
height: 80,
child: pw.Image(logoImage),
),
pw.SizedBox(width: 16),
pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.center,
children: [
pw.Text(
@ -133,9 +138,9 @@ Future<Uint8List> buildTaskPdfBytes(
pw.Text('(IHOMP)', textAlign: pw.TextAlign.center),
],
),
),
],
),
),
pw.SizedBox(height: 12),
pw.Center(
child: pw.Text(
@ -275,7 +280,17 @@ Future<Uint8List> buildTaskPdfBytes(
],
),
pw.SizedBox(height: 12),
pw.Text('Task Title: ${task.title}'),
pw.Divider(thickness: 0.8, color: pdf.PdfColors.grey),
pw.SizedBox(height: 6),
pw.Center(
child: pw.Text(
task.title,
textAlign: pw.TextAlign.center,
style: pw.TextStyle(fontWeight: pw.FontWeight.bold),
),
),
pw.SizedBox(height: 6),
pw.Divider(thickness: 0.8, color: pdf.PdfColors.grey),
pw.SizedBox(height: 6),
pw.Text('Description:'),
pw.SizedBox(height: 6),
@ -332,6 +347,8 @@ Future<Uint8List> buildTaskPdfBytes(
padding: pw.EdgeInsets.all(6),
child: pw.Text(actionTakenText),
),
pw.SizedBox(height: 6),
pw.Divider(thickness: 0.8, color: pdf.PdfColors.grey),
pw.SizedBox(height: 12),
// Historical timestamps side-by-side: Created / Started / Closed
pw.Row(
@ -447,6 +464,15 @@ Future<Uint8List> buildTaskPdfBytes(
),
],
),
pw.SizedBox(height: 12),
pw.Spacer(),
pw.Align(
alignment: pw.Alignment.centerRight,
child: pw.Text(
'MC-IHO-F-05 Rev. 2',
style: pw.TextStyle(fontSize: 9, color: pdf.PdfColors.grey),
),
),
],
);
},