referenceAttachmentsUI method

dynamic referenceAttachmentsUI(
  1. dynamic context,
  2. dynamic ref
)

Implementation

Widget referenceAttachmentsUI(BuildContext context, WidgetRef ref) {
  final lang = L10n.of(context);
  final referenceAttachmentsLoader = ref.watch(
    referenceAttachmentsProvider(attachmentManager),
  );
  bool canEdit = attachmentManager.canEditAttachments();

  return referenceAttachmentsLoader.when(
    data: (refAttachmentList) {
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          attachmentHeader(
            context: context,
            title: lang.references,
            canEdit: canEdit,
            onTapAdd:
                () => addSpaceObjectRefDialog(
                  context: context,
                  attachmentManager: attachmentManager,
                ),
          ),
          ListView.builder(
            shrinkWrap: true,
            itemCount: refAttachmentList.length,
            padding: EdgeInsets.zero,
            physics: NeverScrollableScrollPhysics(),
            itemBuilder: (context, index) {
              return ReferenceAttachmentItem(
                attachment: refAttachmentList[index],
                canEdit: canEdit,
              );
            },
          ),
          if (refAttachmentList.isEmpty)
            Text(L10n.of(context).referencesEmptyStateTitle),
          const SizedBox(height: 20),
        ],
      );
    },
    error: (e, s) {
      _log.severe('Failed to load attachments', e, s);
      return Text(L10n.of(context).errorLoadingAttachments(e));
    },
    loading:
        () => const Skeletonizer(
          child: Wrap(spacing: 5.0, runSpacing: 10.0, children: []),
        ),
  );
}