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<TaskActivityLog> logs,
List<TaskAssignment> assignments, List<TaskAssignment> assignments,
List<Profile> profiles, List<Profile> profiles,
pdf.PdfPageFormat format, pdf.PdfPageFormat? format,
) async { ) async {
final logoData = await rootBundle.load('crmc_logo.png'); final logoData = await rootBundle.load('crmc_logo.png');
final logoImage = pw.MemoryImage(logoData.buffer.asUint8List()); final logoImage = pw.MemoryImage(logoData.buffer.asUint8List());
@ -93,19 +93,24 @@ Future<Uint8List> buildTaskPdfBytes(
doc.addPage( doc.addPage(
pw.Page( pw.Page(
pageFormat: format, pageFormat: format ?? pdf.PdfPageFormat.a4,
margin: pw.EdgeInsets.all(28), margin: pw.EdgeInsets.all(28),
build: (pw.Context ctx) { build: (pw.Context ctx) {
return pw.Column( return pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start, crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [ children: [
pw.Row( pw.Center(
crossAxisAlignment: pw.CrossAxisAlignment.start, child: pw.Row(
children: [ mainAxisAlignment: pw.MainAxisAlignment.center,
pw.Container(width: 64, height: 64, child: pw.Image(logoImage)), crossAxisAlignment: pw.CrossAxisAlignment.center,
pw.SizedBox(width: 12), children: [
pw.Expanded( pw.Container(
child: pw.Column( width: 80,
height: 80,
child: pw.Image(logoImage),
),
pw.SizedBox(width: 16),
pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.center, crossAxisAlignment: pw.CrossAxisAlignment.center,
children: [ children: [
pw.Text( pw.Text(
@ -133,8 +138,8 @@ Future<Uint8List> buildTaskPdfBytes(
pw.Text('(IHOMP)', textAlign: pw.TextAlign.center), pw.Text('(IHOMP)', textAlign: pw.TextAlign.center),
], ],
), ),
), ],
], ),
), ),
pw.SizedBox(height: 12), pw.SizedBox(height: 12),
pw.Center( pw.Center(
@ -275,7 +280,17 @@ Future<Uint8List> buildTaskPdfBytes(
], ],
), ),
pw.SizedBox(height: 12), 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.SizedBox(height: 6),
pw.Text('Description:'), pw.Text('Description:'),
pw.SizedBox(height: 6), pw.SizedBox(height: 6),
@ -332,6 +347,8 @@ Future<Uint8List> buildTaskPdfBytes(
padding: pw.EdgeInsets.all(6), padding: pw.EdgeInsets.all(6),
child: pw.Text(actionTakenText), child: pw.Text(actionTakenText),
), ),
pw.SizedBox(height: 6),
pw.Divider(thickness: 0.8, color: pdf.PdfColors.grey),
pw.SizedBox(height: 12), pw.SizedBox(height: 12),
// Historical timestamps side-by-side: Created / Started / Closed // Historical timestamps side-by-side: Created / Started / Closed
pw.Row( 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),
),
),
], ],
); );
}, },