From 90d3e6bf7befe964df423a333ea2b5e3b0f5e714 Mon Sep 17 00:00:00 2001 From: Marc Rejohn Castillano Date: Sun, 22 Feb 2026 00:30:12 +0800 Subject: [PATCH] Proper task pdf layout --- lib/screens/tasks/task_pdf.dart | 50 +++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/screens/tasks/task_pdf.dart b/lib/screens/tasks/task_pdf.dart index 60c125ca..fa867b03 100644 --- a/lib/screens/tasks/task_pdf.dart +++ b/lib/screens/tasks/task_pdf.dart @@ -23,7 +23,7 @@ Future buildTaskPdfBytes( List logs, List assignments, List 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 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, - children: [ - pw.Container(width: 64, height: 64, child: pw.Image(logoImage)), - pw.SizedBox(width: 12), - pw.Expanded( - child: pw.Column( + pw.Center( + child: pw.Row( + mainAxisAlignment: pw.MainAxisAlignment.center, + crossAxisAlignment: pw.CrossAxisAlignment.center, + children: [ + pw.Container( + width: 80, + height: 80, + child: pw.Image(logoImage), + ), + pw.SizedBox(width: 16), + pw.Column( crossAxisAlignment: pw.CrossAxisAlignment.center, children: [ pw.Text( @@ -133,8 +138,8 @@ Future buildTaskPdfBytes( pw.Text('(IHOMP)', textAlign: pw.TextAlign.center), ], ), - ), - ], + ], + ), ), pw.SizedBox(height: 12), pw.Center( @@ -275,7 +280,17 @@ Future 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 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 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), + ), + ), ], ); },