feat: Add maxLines property to LabeledInput and update document tile to conditionally show date header

This commit is contained in:
Vaibhav Surve 2025-09-24 17:38:24 +05:30
parent aa5ae29284
commit fb26ba0757
2 changed files with 29 additions and 11 deletions

View File

@ -393,6 +393,7 @@ class _DocumentUploadBottomSheetState extends State<DocumentUploadBottomSheet> {
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,
),
],
);

View File

@ -67,7 +67,7 @@ class _UserDocumentsPageState extends State<UserDocumentsPage> {
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<UserDocumentsPage> {
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<UserDocumentsPage> {
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
@ -536,7 +536,21 @@ class _UserDocumentsPageState extends State<UserDocumentsPage> {
),
]
: [
...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),