소스 검색

Fixed a state refresh issue on Location tile in file details

ashilkn 2 년 전
부모
커밋
d3a858f653
1개의 변경된 파일21개의 추가작업 그리고 12개의 파일을 삭제
  1. 21 12
      lib/ui/viewer/file_details/location_tags_widget.dart

+ 21 - 12
lib/ui/viewer/file_details/location_tags_widget.dart

@@ -22,9 +22,9 @@ class LocationTagsWidget extends StatefulWidget {
 }
 }
 
 
 class _LocationTagsWidgetState extends State<LocationTagsWidget> {
 class _LocationTagsWidgetState extends State<LocationTagsWidget> {
-  String title = "Add location";
-  IconData leadingIcon = Icons.add_location_alt_outlined;
-  bool hasChipButtons = false;
+  String? title;
+  IconData? leadingIcon;
+  bool? hasChipButtons;
   late Future<List<Widget>> locationTagChips;
   late Future<List<Widget>> locationTagChips;
   late StreamSubscription<LocationTagUpdatedEvent> _locTagUpdateListener;
   late StreamSubscription<LocationTagUpdatedEvent> _locTagUpdateListener;
   @override
   @override
@@ -51,10 +51,10 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
       switchOutCurve: Curves.easeInOutExpo,
       switchOutCurve: Curves.easeInOutExpo,
       child: InfoItemWidget(
       child: InfoItemWidget(
         key: ValueKey(title),
         key: ValueKey(title),
-        leadingIcon: Icons.add_location_alt_outlined,
+        leadingIcon: leadingIcon ?? Icons.pin_drop_outlined,
         title: title,
         title: title,
         subtitleSection: locationTagChips,
         subtitleSection: locationTagChips,
-        hasChipButtons: hasChipButtons,
+        hasChipButtons: hasChipButtons ?? true,
       ),
       ),
     );
     );
   }
   }
@@ -63,6 +63,14 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
     final locationTags = await LocationService.instance
     final locationTags = await LocationService.instance
         .enclosingLocationTags(widget.centerPoint);
         .enclosingLocationTags(widget.centerPoint);
     if (locationTags.isEmpty) {
     if (locationTags.isEmpty) {
+      if (mounted) {
+        setState(() {
+          title = "Add location";
+          leadingIcon = Icons.add_location_alt_outlined;
+          hasChipButtons = false;
+        });
+      }
+
       return [
       return [
         InlineButtonWidget(
         InlineButtonWidget(
           "Group nearby photos",
           "Group nearby photos",
@@ -72,13 +80,14 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
           ),
           ),
         ),
         ),
       ];
       ];
-    }
-    if (mounted) {
-      setState(() {
-        title = "Location";
-        leadingIcon = Icons.pin_drop_outlined;
-        hasChipButtons = true;
-      });
+    } else {
+      if (mounted) {
+        setState(() {
+          title = "Location";
+          leadingIcon = Icons.pin_drop_outlined;
+          hasChipButtons = true;
+        });
+      }
     }
     }
 
 
     final result = locationTags
     final result = locationTags