feat: Add maxLines property to LabeledInput and update document tile to conditionally show date header
This commit is contained in:
parent
aa5ae29284
commit
fb26ba0757
@ -393,6 +393,7 @@ class _DocumentUploadBottomSheetState extends State<DocumentUploadBottomSheet> {
|
|||||||
validator: (value) =>
|
validator: (value) =>
|
||||||
value == null || value.trim().isEmpty ? "Required" : null,
|
value == null || value.trim().isEmpty ? "Required" : null,
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
|
maxLines: 3,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -564,6 +565,7 @@ class LabeledInput extends StatelessWidget {
|
|||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final String? Function(String?) validator;
|
final String? Function(String?) validator;
|
||||||
final bool isRequired;
|
final bool isRequired;
|
||||||
|
final int maxLines;
|
||||||
|
|
||||||
const LabeledInput({
|
const LabeledInput({
|
||||||
Key? key,
|
Key? key,
|
||||||
@ -572,6 +574,7 @@ class LabeledInput extends StatelessWidget {
|
|||||||
required this.controller,
|
required this.controller,
|
||||||
required this.validator,
|
required this.validator,
|
||||||
this.isRequired = false,
|
this.isRequired = false,
|
||||||
|
this.maxLines = 1,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -594,6 +597,7 @@ class LabeledInput extends StatelessWidget {
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
validator: validator,
|
validator: validator,
|
||||||
decoration: _inputDecoration(context, hint),
|
decoration: _inputDecoration(context, hint),
|
||||||
|
maxLines: maxLines,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class _UserDocumentsPageState extends State<UserDocumentsPage> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDocumentTile(DocumentItem doc) {
|
Widget _buildDocumentTile(DocumentItem doc, bool showDateHeader) {
|
||||||
final uploadDate =
|
final uploadDate =
|
||||||
DateFormat("dd MMM yyyy").format(doc.uploadedAt.toLocal());
|
DateFormat("dd MMM yyyy").format(doc.uploadedAt.toLocal());
|
||||||
|
|
||||||
@ -79,15 +79,16 @@ class _UserDocumentsPageState extends State<UserDocumentsPage> {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
if (showDateHeader)
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
Padding(
|
||||||
child: MyText.bodySmall(
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||||
uploadDate,
|
child: MyText.bodySmall(
|
||||||
fontSize: 13,
|
uploadDate,
|
||||||
fontWeight: 500,
|
fontSize: 13,
|
||||||
color: Colors.grey,
|
fontWeight: 500,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// 👉 Navigate to details page
|
// 👉 Navigate to details page
|
||||||
@ -345,7 +346,6 @@ class _UserDocumentsPageState extends State<UserDocumentsPage> {
|
|||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
|
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.vertical(top: Radius.circular(5)),
|
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)
|
if (docController.isLoading.value)
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user