From fb26ba0757a76c05b6a08a17fa7513c87f32bac1 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Wed, 24 Sep 2025 17:38:24 +0530 Subject: [PATCH] feat: Add maxLines property to LabeledInput and update document tile to conditionally show date header --- .../document_upload_bottom_sheet.dart | 4 +++ lib/view/document/user_document_screen.dart | 36 +++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/model/document/document_upload_bottom_sheet.dart b/lib/model/document/document_upload_bottom_sheet.dart index 3f797dc..30170e5 100644 --- a/lib/model/document/document_upload_bottom_sheet.dart +++ b/lib/model/document/document_upload_bottom_sheet.dart @@ -393,6 +393,7 @@ class _DocumentUploadBottomSheetState extends State { validator: (value) => value == null || value.trim().isEmpty ? "Required" : null, isRequired: true, + maxLines: 3, ), ], ), @@ -564,6 +565,7 @@ class LabeledInput extends StatelessWidget { final TextEditingController controller; final String? Function(String?) validator; final bool isRequired; + final int maxLines; const LabeledInput({ Key? key, @@ -572,6 +574,7 @@ class LabeledInput extends StatelessWidget { required this.controller, required this.validator, this.isRequired = false, + this.maxLines = 1, }) : super(key: key); @override @@ -594,6 +597,7 @@ class LabeledInput extends StatelessWidget { controller: controller, validator: validator, decoration: _inputDecoration(context, hint), + maxLines: maxLines, ), ], ); diff --git a/lib/view/document/user_document_screen.dart b/lib/view/document/user_document_screen.dart index b254f45..7eb581a 100644 --- a/lib/view/document/user_document_screen.dart +++ b/lib/view/document/user_document_screen.dart @@ -67,7 +67,7 @@ class _UserDocumentsPageState extends State { super.dispose(); } - Widget _buildDocumentTile(DocumentItem doc) { + Widget _buildDocumentTile(DocumentItem doc, bool showDateHeader) { final uploadDate = DateFormat("dd MMM yyyy").format(doc.uploadedAt.toLocal()); @@ -79,15 +79,16 @@ class _UserDocumentsPageState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), - child: MyText.bodySmall( - uploadDate, - fontSize: 13, - fontWeight: 500, - color: Colors.grey, + if (showDateHeader) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + child: MyText.bodySmall( + uploadDate, + fontSize: 13, + fontWeight: 500, + color: Colors.grey, + ), ), - ), InkWell( onTap: () { // 👉 Navigate to details page @@ -345,7 +346,6 @@ class _UserDocumentsPageState extends State { showModalBottomSheet( context: context, isScrollControlled: true, - shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(5)), @@ -536,7 +536,21 @@ class _UserDocumentsPageState extends State { ), ] : [ - ...docs.map(_buildDocumentTile), + ...docs.asMap().entries.map((entry) { + final index = entry.key; + final doc = entry.value; + + final currentDate = DateFormat("dd MMM yyyy") + .format(doc.uploadedAt.toLocal()); + final prevDate = index > 0 + ? DateFormat("dd MMM yyyy").format( + docs[index - 1].uploadedAt.toLocal()) + : null; + + final showDateHeader = currentDate != prevDate; + + return _buildDocumentTile(doc, showDateHeader); + }), if (docController.isLoading.value) const Padding( padding: EdgeInsets.all(12),