2024-03-06 22:27:33 -05:00
|
|
|
import 'package:flutter/material.dart';
|
2024-04-30 21:36:40 -05:00
|
|
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
2024-03-06 22:27:33 -05:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
|
|
|
import 'package:immich_mobile/utils/bytes_units.dart';
|
|
|
|
|
|
2024-08-09 08:43:47 -05:00
|
|
|
class FileInfo extends StatelessWidget {
|
2024-03-06 22:27:33 -05:00
|
|
|
final Asset asset;
|
|
|
|
|
|
2025-07-29 00:34:03 +05:30
|
|
|
const FileInfo({super.key, required this.asset});
|
2024-03-06 22:27:33 -05:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final textColor = context.isDarkTheme ? Colors.white : Colors.black;
|
|
|
|
|
|
2024-12-05 02:33:46 +05:30
|
|
|
final height = asset.orientatedHeight ?? asset.height;
|
|
|
|
|
final width = asset.orientatedWidth ?? asset.width;
|
2025-07-25 08:07:22 +05:30
|
|
|
String resolution = height != null && width != null ? "$width x $height " : "";
|
|
|
|
|
String fileSize = asset.exifInfo?.fileSize != null ? formatBytes(asset.exifInfo!.fileSize!) : "";
|
2024-03-06 22:27:33 -05:00
|
|
|
String text = resolution + fileSize;
|
|
|
|
|
final imgSizeString = text.isNotEmpty ? text : null;
|
|
|
|
|
|
|
|
|
|
String? title;
|
|
|
|
|
String? subtitle;
|
|
|
|
|
|
|
|
|
|
if (imgSizeString == null && asset.fileName.isNotEmpty) {
|
|
|
|
|
// There is only filename
|
|
|
|
|
title = asset.fileName;
|
|
|
|
|
} else if (imgSizeString != null && asset.fileName.isNotEmpty) {
|
|
|
|
|
// There is both filename and size information
|
|
|
|
|
title = asset.fileName;
|
|
|
|
|
subtitle = imgSizeString;
|
|
|
|
|
} else if (imgSizeString != null && asset.fileName.isEmpty) {
|
|
|
|
|
title = imgSizeString;
|
|
|
|
|
} else {
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ListTile(
|
|
|
|
|
contentPadding: const EdgeInsets.all(0),
|
|
|
|
|
dense: true,
|
2025-07-29 00:34:03 +05:30
|
|
|
leading: Icon(Icons.image, color: textColor.withAlpha(200)),
|
2024-03-06 22:27:33 -05:00
|
|
|
titleAlignment: ListTileTitleAlignment.center,
|
2025-07-29 00:34:03 +05:30
|
|
|
title: Text(title, style: context.textTheme.labelLarge),
|
2024-03-06 22:27:33 -05:00
|
|
|
subtitle: subtitle == null ? null : Text(subtitle),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|