Browse Source

show option to edit location data for photos that already have location data

ashilkn 1 year ago
parent
commit
1339101d94

+ 1 - 1
lib/ui/viewer/file/file_details_widget.dart

@@ -157,7 +157,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
               ? Column(
               ? Column(
                   children: [
                   children: [
                     LocationTagsWidget(
                     LocationTagsWidget(
-                      widget.file.location!,
+                      widget.file,
                     ),
                     ),
                     const FileDetailsDivider(),
                     const FileDetailsDivider(),
                   ],
                   ],

+ 24 - 6
lib/ui/viewer/file_details/location_tags_widget.dart

@@ -1,22 +1,25 @@
 import "dart:async";
 import "dart:async";
 
 
 import "package:flutter/material.dart";
 import "package:flutter/material.dart";
+import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
 import "package:photos/core/event_bus.dart";
 import "package:photos/core/event_bus.dart";
 import "package:photos/events/location_tag_updated_event.dart";
 import "package:photos/events/location_tag_updated_event.dart";
 import "package:photos/generated/l10n.dart";
 import "package:photos/generated/l10n.dart";
-import "package:photos/models/location/location.dart";
+import "package:photos/models/file/file.dart";
 import "package:photos/services/location_service.dart";
 import "package:photos/services/location_service.dart";
 import "package:photos/states/location_screen_state.dart";
 import "package:photos/states/location_screen_state.dart";
+import "package:photos/theme/colors.dart";
 import "package:photos/theme/ente_theme.dart";
 import "package:photos/theme/ente_theme.dart";
 import "package:photos/ui/components/buttons/chip_button_widget.dart";
 import "package:photos/ui/components/buttons/chip_button_widget.dart";
 import "package:photos/ui/components/info_item_widget.dart";
 import "package:photos/ui/components/info_item_widget.dart";
 import 'package:photos/ui/viewer/location/add_location_sheet.dart';
 import 'package:photos/ui/viewer/location/add_location_sheet.dart';
 import "package:photos/ui/viewer/location/location_screen.dart";
 import "package:photos/ui/viewer/location/location_screen.dart";
+import "package:photos/ui/viewer/location/update_location_data_widget.dart";
 import "package:photos/utils/navigation_util.dart";
 import "package:photos/utils/navigation_util.dart";
 
 
 class LocationTagsWidget extends StatefulWidget {
 class LocationTagsWidget extends StatefulWidget {
-  final Location centerPoint;
-  const LocationTagsWidget(this.centerPoint, {super.key});
+  final EnteFile file;
+  const LocationTagsWidget(this.file, {super.key});
 
 
   @override
   @override
   State<LocationTagsWidget> createState() => _LocationTagsWidgetState();
   State<LocationTagsWidget> createState() => _LocationTagsWidgetState();
@@ -58,13 +61,28 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
         subtitleSection: locationTagChips,
         subtitleSection: locationTagChips,
         hasChipButtons: hasChipButtons ?? true,
         hasChipButtons: hasChipButtons ?? true,
         onTap: onTap,
         onTap: onTap,
+        editOnTap: () {
+          showBarModalBottomSheet(
+            shape: const RoundedRectangleBorder(
+              borderRadius: BorderRadius.vertical(
+                top: Radius.circular(5),
+              ),
+            ),
+            backgroundColor: getEnteColorScheme(context).backgroundElevated,
+            barrierColor: backdropFaintDark,
+            context: context,
+            builder: (context) {
+              return UpdateLocationDataWidget([widget.file]);
+            },
+          );
+        },
       ),
       ),
     );
     );
   }
   }
 
 
   Future<List<Widget>> _getLocationTags() async {
   Future<List<Widget>> _getLocationTags() async {
     final locationTags = await LocationService.instance
     final locationTags = await LocationService.instance
-        .enclosingLocationTags(widget.centerPoint);
+        .enclosingLocationTags(widget.file.location!);
     if (locationTags.isEmpty) {
     if (locationTags.isEmpty) {
       if (mounted) {
       if (mounted) {
         setState(() {
         setState(() {
@@ -73,7 +91,7 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
           hasChipButtons = false;
           hasChipButtons = false;
           onTap = () => showAddLocationSheet(
           onTap = () => showAddLocationSheet(
                 context,
                 context,
-                widget.centerPoint,
+                widget.file.location!,
               );
               );
         });
         });
       }
       }
@@ -112,7 +130,7 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
         ChipButtonWidget(
         ChipButtonWidget(
           null,
           null,
           leadingIcon: Icons.add_outlined,
           leadingIcon: Icons.add_outlined,
-          onTap: () => showAddLocationSheet(context, widget.centerPoint),
+          onTap: () => showAddLocationSheet(context, widget.file.location!),
         ),
         ),
       );
       );
       return result;
       return result;