added_by_widget.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import "package:flutter/material.dart";
  2. import "package:photos/generated/l10n.dart";
  3. import "package:photos/models/file.dart";
  4. import "package:photos/services/collections_service.dart";
  5. import "package:photos/theme/ente_theme.dart";
  6. class AddedByWidget extends StatelessWidget {
  7. final EnteFile file;
  8. final int currentUserID;
  9. const AddedByWidget(this.file, this.currentUserID, {super.key});
  10. @override
  11. Widget build(BuildContext context) {
  12. if (file.uploadedFileID == null) {
  13. return const SizedBox.shrink();
  14. }
  15. String? addedBy;
  16. if (file.ownerID == currentUserID) {
  17. if (file.pubMagicMetadata!.uploaderName != null) {
  18. addedBy = file.pubMagicMetadata!.uploaderName;
  19. }
  20. } else {
  21. final fileOwner = CollectionsService.instance
  22. .getFileOwner(file.ownerID!, file.collectionID);
  23. addedBy = fileOwner.email;
  24. }
  25. if (addedBy == null || addedBy.isEmpty) {
  26. return const SizedBox.shrink();
  27. }
  28. return Padding(
  29. padding: const EdgeInsets.only(top: 4.0, bottom: 4.0, left: 16),
  30. child: Text(
  31. S.of(context).addedBy(addedBy),
  32. style: getEnteTextTheme(context).miniMuted,
  33. ),
  34. );
  35. }
  36. }