diff --git a/lib/screens/tasks/task_pdf.dart b/lib/screens/tasks/task_pdf.dart index e4074742..60c125ca 100644 --- a/lib/screens/tasks/task_pdf.dart +++ b/lib/screens/tasks/task_pdf.dart @@ -148,26 +148,130 @@ Future buildTaskPdfBytes( ), pw.SizedBox(height: 12), pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, children: [ - pw.Text('Task Number: ${task.taskNumber ?? task.id}'), - pw.Spacer(), - pw.Text('Filed At: $created'), - ], - ), - pw.SizedBox(height: 8), - pw.Row( - children: [ - pw.Text('Service: $serviceName'), + pw.Expanded( + child: pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Row( + children: [ + pw.Text('Task Number: '), + pw.Container( + padding: pw.EdgeInsets.only(bottom: 2), + decoration: pw.BoxDecoration( + border: pw.Border( + bottom: pw.BorderSide( + width: 0.8, + color: pdf.PdfColors.black, + ), + ), + ), + child: pw.Text(task.taskNumber ?? task.id), + ), + ], + ), + pw.SizedBox(height: 8), + pw.Row( + children: [ + pw.Text('Service: '), + pw.Container( + padding: pw.EdgeInsets.only(bottom: 2), + decoration: pw.BoxDecoration( + border: pw.Border( + bottom: pw.BorderSide( + width: 0.8, + color: pdf.PdfColors.black, + ), + ), + ), + child: pw.Text(serviceName), + ), + ], + ), + pw.SizedBox(height: 8), + pw.Row( + children: [ + pw.Text('Type: '), + pw.Container( + padding: pw.EdgeInsets.only(bottom: 2), + decoration: pw.BoxDecoration( + border: pw.Border( + bottom: pw.BorderSide( + width: 0.8, + color: pdf.PdfColors.black, + ), + ), + ), + child: pw.Text(task.requestType ?? ''), + ), + ], + ), + ], + ), + ), pw.SizedBox(width: 12), - pw.Text('Office: $officeName'), - ], - ), - pw.SizedBox(height: 8), - pw.Row( - children: [ - pw.Text('Type: ${task.requestType ?? ''}'), - pw.SizedBox(width: 12), - pw.Text('Category: ${task.requestCategory ?? ''}'), + pw.Container( + width: 180, + child: pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Row( + children: [ + pw.Text('Filed At: '), + pw.Container( + padding: pw.EdgeInsets.only(bottom: 2), + decoration: pw.BoxDecoration( + border: pw.Border( + bottom: pw.BorderSide( + width: 0.8, + color: pdf.PdfColors.black, + ), + ), + ), + child: pw.Text(created), + ), + ], + ), + pw.SizedBox(height: 8), + pw.Row( + children: [ + pw.Text('Office: '), + pw.Container( + padding: pw.EdgeInsets.only(bottom: 2), + decoration: pw.BoxDecoration( + border: pw.Border( + bottom: pw.BorderSide( + width: 0.8, + color: pdf.PdfColors.black, + ), + ), + ), + child: pw.Text(officeName), + ), + ], + ), + pw.SizedBox(height: 8), + pw.Row( + children: [ + pw.Text('Category: '), + pw.Container( + padding: pw.EdgeInsets.only(bottom: 2), + decoration: pw.BoxDecoration( + border: pw.Border( + bottom: pw.BorderSide( + width: 0.8, + color: pdf.PdfColors.black, + ), + ), + ), + child: pw.Text(task.requestCategory ?? ''), + ), + ], + ), + ], + ), + ), ], ), pw.SizedBox(height: 12), @@ -229,41 +333,55 @@ Future buildTaskPdfBytes( child: pw.Text(actionTakenText), ), pw.SizedBox(height: 12), - // Historical timestamps: always show the labels; values may be empty + // Historical timestamps side-by-side: Created / Started / Closed pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, children: [ - pw.Text('Created At:'), - pw.SizedBox(width: 8), - pw.Text( - '${AppTime.formatDate(task.createdAt)} ${AppTime.formatTime(task.createdAt)}', + pw.Expanded( + child: pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Text('Created At:'), + pw.SizedBox(height: 4), + pw.Text( + '${AppTime.formatDate(task.createdAt)} ${AppTime.formatTime(task.createdAt)}', + ), + ], + ), + ), + pw.SizedBox(width: 12), + pw.Expanded( + child: pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Text('Started At:'), + pw.SizedBox(height: 4), + pw.Text( + task.startedAt == null + ? '' + : '${AppTime.formatDate(task.startedAt!)} ${AppTime.formatTime(task.startedAt!)}', + ), + ], + ), + ), + pw.SizedBox(width: 12), + pw.Expanded( + child: pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Text('Closed At:'), + pw.SizedBox(height: 4), + pw.Text( + task.completedAt == null + ? '' + : '${AppTime.formatDate(task.completedAt!)} ${AppTime.formatTime(task.completedAt!)}', + ), + ], + ), ), ], ), - pw.SizedBox(height: 6), - pw.Row( - children: [ - pw.Text('Started At:'), - pw.SizedBox(width: 8), - pw.Text( - task.startedAt == null - ? '' - : '${AppTime.formatDate(task.startedAt!)} ${AppTime.formatTime(task.startedAt!)}', - ), - ], - ), - pw.SizedBox(height: 6), - pw.Row( - children: [ - pw.Text('Closed At:'), - pw.SizedBox(width: 8), - pw.Text( - task.completedAt == null - ? '' - : '${AppTime.formatDate(task.completedAt!)} ${AppTime.formatTime(task.completedAt!)}', - ), - ], - ), - pw.SizedBox(height: 12), + pw.SizedBox(height: 36), // Signature lines row (fixed) — stays aligned regardless of name length pw.Row( children: [