Revert "Rebuild only tiles that depend on state of exif using ValueNotifier"

This reverts commit 26e83d93b1.
This commit is contained in:
ashilkn 2023-03-14 15:45:16 +05:30
parent 26e83d93b1
commit 1ddefe916c
2 changed files with 14 additions and 35 deletions

View file

@ -21,7 +21,7 @@ class InfoItemWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
debugPrint("$title InfoItemWidget.build -------");
debugPrint("InfoItemWidget.build -------");
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,

View file

@ -32,7 +32,7 @@ class FileDetailsWidget extends StatefulWidget {
}
class _FileDetailsWidgetState extends State<FileDetailsWidget> {
final ValueNotifier<Map<String, IfdTag>?> _exifNotifier = ValueNotifier(null);
Map<String, IfdTag>? _exif;
final Map<String, dynamic> _exifData = {
"focalLength": null,
"fNumber": null,
@ -53,29 +53,26 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
_isImage = widget.file.fileType == FileType.image ||
widget.file.fileType == FileType.livePhoto;
if (_isImage) {
_exifNotifier.addListener(() {
if (_exifNotifier.value != null) {
_generateExifForDetails(_exifNotifier.value!);
}
});
getExif(widget.file).then((exif) {
_exifNotifier.value = exif;
if (mounted) {
setState(() {
_exif = exif;
});
}
});
}
super.initState();
}
@override
void dispose() {
_exifNotifier.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final file = widget.file;
final bool isFileOwner =
file.ownerID == null || file.ownerID == _currentUserID;
if (_isImage && _exif != null) {
_generateExifForDetails(_exif!);
}
final bool showExifListTile = _exifData["focalLength"] != null ||
_exifData["fNumber"] != null ||
_exifData["takenOnDevice"] != null ||
@ -92,27 +89,9 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
: FileCaptionReadyOnly(caption: widget.file.caption!),
),
CreationTimeItem(file, _currentUserID),
ValueListenableBuilder(
valueListenable: _exifNotifier,
builder: (context, _, __) =>
FilePropertiesItemWidget(file, _isImage, _exifData, _currentUserID),
),
showExifListTile
? ValueListenableBuilder(
valueListenable: _exifNotifier,
builder: (context, _, __) {
return BasicExifItemWidget(_exifData);
},
)
: null,
_isImage
? ValueListenableBuilder(
valueListenable: _exifNotifier,
builder: (context, value, _) {
return AllExifItemWidget(file, value as Map<String, IfdTag>?);
},
)
: null,
FilePropertiesItemWidget(file, _isImage, _exifData, _currentUserID),
showExifListTile ? BasicExifItemWidget(_exifData) : null,
_isImage ? AllExifItemWidget(file, _exif) : null,
FeatureFlagService.instance.isInternalUserOrDebugBuild()
? ObjectsItemWidget(file)
: null,