feat: Update AttachmentsSection to use RxList for reactive attachment management

This commit is contained in:
Vaibhav Surve 2025-08-02 10:16:01 +05:30
parent d0cbfa987d
commit 5f66c4c647

View File

@ -446,7 +446,7 @@ class _TileContainer extends StatelessWidget {
} }
class _AttachmentsSection extends StatelessWidget { class _AttachmentsSection extends StatelessWidget {
final List<File> attachments; final RxList<File> attachments;
final ValueChanged<File> onRemove; final ValueChanged<File> onRemove;
final VoidCallback onAdd; final VoidCallback onAdd;
@ -458,27 +458,29 @@ class _AttachmentsSection extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Wrap( return Obx(() => Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: [ children: [
...attachments.map((file) => ...attachments.map((file) => _AttachmentTile(
_AttachmentTile(file: file, onRemove: () => onRemove(file))), file: file,
GestureDetector( onRemove: () => onRemove(file),
onTap: onAdd, )),
child: Container( GestureDetector(
width: 80, onTap: onAdd,
height: 80, child: Container(
decoration: BoxDecoration( width: 80,
border: Border.all(color: Colors.grey.shade400), height: 80,
borderRadius: BorderRadius.circular(8), decoration: BoxDecoration(
color: Colors.grey.shade100, border: Border.all(color: Colors.grey.shade400),
borderRadius: BorderRadius.circular(8),
color: Colors.grey.shade100,
),
child: const Icon(Icons.add, size: 30, color: Colors.grey),
),
), ),
child: const Icon(Icons.add, size: 30, color: Colors.grey), ],
), ));
),
],
);
} }
} }