Proper signatory layout on Task Printout
This commit is contained in:
parent
74f9511ee3
commit
302d52fe4f
|
|
@ -85,13 +85,11 @@ Future<Uint8List> buildTaskPdfBytes(
|
|||
final profileById = {for (final p in profiles) p.id: p};
|
||||
final assignedForTask = assignments.where((a) => a.taskId == task.id).toList()
|
||||
..sort((a, b) => a.createdAt.compareTo(b.createdAt));
|
||||
final latestAssignment = assignedForTask.isEmpty
|
||||
? null
|
||||
: assignedForTask.last;
|
||||
final performedBy = latestAssignment == null
|
||||
// Collect all unique assigned user IDs for this task and map to profile names
|
||||
final assignedUserIds = {for (final a in assignedForTask) a.userId};
|
||||
final performedBy = assignedUserIds.isEmpty
|
||||
? ''
|
||||
: (profileById[latestAssignment.userId]?.fullName ??
|
||||
latestAssignment.userId);
|
||||
: assignedUserIds.map((id) => profileById[id]?.fullName ?? id).join(', ');
|
||||
|
||||
doc.addPage(
|
||||
pw.Page(
|
||||
|
|
@ -182,30 +180,43 @@ Future<Uint8List> buildTaskPdfBytes(
|
|||
child: pw.Text(descriptionText),
|
||||
),
|
||||
pw.SizedBox(height: 12),
|
||||
// Requested/Noted signature lines
|
||||
// Requested/Noted signature lines (bottom-aligned to match Performed/Received)
|
||||
pw.Row(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.end,
|
||||
children: [
|
||||
pw.Expanded(
|
||||
child: pw.Column(
|
||||
children: [
|
||||
pw.Container(height: 28),
|
||||
pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.Text(requestedBy),
|
||||
pw.Text('Requested By'),
|
||||
],
|
||||
child: pw.Container(
|
||||
height: 56,
|
||||
child: pw.Column(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.end,
|
||||
children: [
|
||||
pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.Text(
|
||||
requestedBy,
|
||||
style: pw.TextStyle(fontWeight: pw.FontWeight.bold),
|
||||
),
|
||||
pw.Text('Requested By'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.SizedBox(width: 12),
|
||||
pw.Expanded(
|
||||
child: pw.Column(
|
||||
children: [
|
||||
pw.Container(height: 28),
|
||||
pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.Text(notedBy),
|
||||
pw.Text('Noted by Supervisor/Senior'),
|
||||
],
|
||||
child: pw.Container(
|
||||
height: 56,
|
||||
child: pw.Column(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.end,
|
||||
children: [
|
||||
pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.Text(
|
||||
notedBy,
|
||||
style: pw.TextStyle(fontWeight: pw.FontWeight.bold),
|
||||
),
|
||||
pw.Text('Noted by Supervisor/Senior'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -236,34 +247,71 @@ Future<Uint8List> buildTaskPdfBytes(
|
|||
],
|
||||
),
|
||||
pw.SizedBox(height: 12),
|
||||
// Performed/Received signature lines
|
||||
// Signature lines row (fixed) — stays aligned regardless of name length
|
||||
pw.Row(
|
||||
children: [
|
||||
pw.Expanded(
|
||||
child: pw.Column(
|
||||
children: [
|
||||
pw.Container(height: 28),
|
||||
pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.Text(performedBy),
|
||||
pw.Text('Performed By'),
|
||||
],
|
||||
child: pw.Container(
|
||||
height: 24,
|
||||
alignment: pw.Alignment.center,
|
||||
child: pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
),
|
||||
),
|
||||
pw.SizedBox(width: 12),
|
||||
pw.Expanded(
|
||||
child: pw.Column(
|
||||
children: [
|
||||
pw.Container(height: 28),
|
||||
pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.Text(receivedBy),
|
||||
pw.Text('Received By'),
|
||||
],
|
||||
child: pw.Container(
|
||||
height: 24,
|
||||
alignment: pw.Alignment.center,
|
||||
child: pw.Container(height: 1, color: pdf.PdfColors.black),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.SizedBox(height: 6),
|
||||
// Names row: performedBy can be long but won't move the signature line; center names under lines
|
||||
pw.Row(
|
||||
children: [
|
||||
pw.Expanded(
|
||||
child: pw.Container(
|
||||
padding: pw.EdgeInsets.only(right: 6),
|
||||
alignment: pw.Alignment.center,
|
||||
child: pw.Text(
|
||||
performedBy,
|
||||
textAlign: pw.TextAlign.center,
|
||||
style: pw.TextStyle(fontWeight: pw.FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.SizedBox(width: 12),
|
||||
pw.Expanded(
|
||||
child: pw.Container(
|
||||
padding: pw.EdgeInsets.only(left: 6),
|
||||
alignment: pw.Alignment.center,
|
||||
child: pw.Text(
|
||||
receivedBy,
|
||||
textAlign: pw.TextAlign.center,
|
||||
style: pw.TextStyle(fontWeight: pw.FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.SizedBox(height: 6),
|
||||
// Labels row (centered)
|
||||
pw.Row(
|
||||
children: [
|
||||
pw.Expanded(
|
||||
child: pw.Text(
|
||||
'Performed By',
|
||||
textAlign: pw.TextAlign.center,
|
||||
),
|
||||
),
|
||||
pw.SizedBox(width: 12),
|
||||
pw.Expanded(
|
||||
child: pw.Text('Received By', textAlign: pw.TextAlign.center),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user