瀏覽代碼

Refactor: Used Location and LocationTag objects in codebase

ashilkn 2 年之前
父節點
當前提交
a1f05e75fc

+ 20 - 18
lib/services/location_service.dart

@@ -25,8 +25,7 @@ class LocationService {
 
   Future<void> addLocation(
     String location,
-    double lat,
-    double long,
+    Location centerPoint,
     int radius,
   ) async {
     final list = getAllLocationTags();
@@ -35,15 +34,17 @@ class LocationService {
     //a & b are the semi-major and semi-minor axes of the ellipse
     //Converting the unit from kilometers to degrees for a and b as that is
     //the unit on the caritesian plane
-    final a = (radius * _scaleFactor(lat)) / kilometersPerDegree;
+
+    //Todo : Check if lat long can be null here
+    final a =
+        (radius * _scaleFactor(centerPoint.latitude!)) / kilometersPerDegree;
     final b = radius / kilometersPerDegree;
-    final center = Location(latitude: lat, longitude: long);
     final locationTag = LocationTag(
       name: location,
       radius: radius,
       aSquare: a * a,
       bSquare: b * b,
-      centerPoint: center,
+      centerPoint: centerPoint,
     );
     list.add(json.encode(locationTag.toJson()));
     await prefs!.setStringList('locations', list);
@@ -57,7 +58,7 @@ class LocationService {
     return 1 / cos(lat * (pi / 180));
   }
 
-  List<LocationTag> enclosingLocationTags(List<double> coordinates) {
+  List<LocationTag> enclosingLocationTags(Location fileCoordinates) {
     final result = List<LocationTag>.of([]);
     final locationTagsData = getAllLocationTags();
     for (String locationTagData in locationTagsData) {
@@ -65,8 +66,8 @@ class LocationService {
       // final locationJson = json.decode(locationTag);
       // final center = locationJson["center"];
       //Todo : Check if lat long can be null here
-      final x = coordinates[0] - locationTag.centerPoint.latitude!;
-      final y = coordinates[1] - locationTag.centerPoint.longitude!;
+      final x = fileCoordinates.latitude! - locationTag.centerPoint.latitude!;
+      final y = fileCoordinates.longitude! - locationTag.centerPoint.longitude!;
       if ((x * x) / (locationTag.aSquare) + (y * y) / (locationTag.bSquare) <=
           1) {
         result.add(
@@ -78,14 +79,15 @@ class LocationService {
   }
 
   bool isFileInsideLocationTag(
-    List<double> center,
-    List<double> fileCoordinates,
+    Location centerPoint,
+    Location fileCoordinates,
     int radius,
   ) {
-    final a = (radius * _scaleFactor(center[0])) / kilometersPerDegree;
+    final a =
+        (radius * _scaleFactor(centerPoint.latitude!)) / kilometersPerDegree;
     final b = radius / kilometersPerDegree;
-    final x = center[0] - fileCoordinates[0];
-    final y = center[1] - fileCoordinates[1];
+    final x = centerPoint.latitude! - fileCoordinates.latitude!;
+    final y = centerPoint.longitude! - fileCoordinates.longitude!;
     if ((x * x) / (a * a) + (y * y) / (b * b) <= 1) {
       return true;
     }
@@ -144,12 +146,12 @@ class GPSData {
 
   GPSData(this.latRef, this.lat, this.longRef, this.long);
 
-  List<double> toSignedDecimalDegreeCoordinates() {
+  Location toLocationFormat() {
     final latSign = latRef == "N" ? 1 : -1;
     final longSign = longRef == "E" ? 1 : -1;
-    return [
-      latSign * lat[0] + lat[1] / 60 + lat[2] / 3600,
-      longSign * long[0] + long[1] / 60 + long[2] / 3600
-    ];
+    return Location(
+      latitude: latSign * lat[0] + lat[1] / 60 + lat[2] / 3600,
+      longitude: longSign * long[0] + long[1] / 60 + long[2] / 3600,
+    );
   }
 }

+ 5 - 4
lib/states/location_state.dart

@@ -1,10 +1,11 @@
 import "package:flutter/material.dart";
 import "package:photos/core/constants.dart";
+import "package:photos/models/location/location.dart";
 import "package:photos/models/typedefs.dart";
 import "package:photos/utils/debouncer.dart";
 
 class LocationTagStateProvider extends StatefulWidget {
-  final List<double> centerPoint;
+  final Location centerPoint;
   final Widget child;
   const LocationTagStateProvider(this.centerPoint, this.child, {super.key});
 
@@ -15,7 +16,7 @@ class LocationTagStateProvider extends StatefulWidget {
 
 class _LocationTagStateProviderState extends State<LocationTagStateProvider> {
   int selectedRaduisIndex = defaultRadiusValueIndex;
-  late List<double> centerPoint;
+  late Location centerPoint;
   final Debouncer _selectedRadiusDebouncer =
       Debouncer(const Duration(milliseconds: 300));
   @override
@@ -48,11 +49,11 @@ class _LocationTagStateProviderState extends State<LocationTagStateProvider> {
 
 class InheritedLocationTagData extends InheritedWidget {
   final int selectedRadiusIndex;
-  final List<double> coordinates;
+  final Location centerPoint;
   final VoidCallbackParamInt updateSelectedIndex;
   const InheritedLocationTagData(
     this.selectedRadiusIndex,
-    this.coordinates,
+    this.centerPoint,
     this.updateSelectedIndex, {
     required super.child,
     super.key,

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

@@ -152,7 +152,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
                           _exifData["lat"],
                           _exifData["longRef"],
                           _exifData["long"],
-                        ).toSignedDecimalDegreeCoordinates(),
+                        ).toLocationFormat(),
                       ),
                       const FileDetailsDivider(),
                     ],

+ 0 - 268
lib/ui/viewer/file/location_detail.dart

@@ -1,268 +0,0 @@
-import "package:flutter/material.dart";
-import "package:photos/ente_theme_data.dart";
-import "package:photos/services/location_service.dart";
-import "package:photos/ui/common/gradient_button.dart";
-import "package:photos/utils/lat_lon_util.dart";
-
-class CreateLocation extends StatefulWidget {
-  const CreateLocation({super.key});
-
-  @override
-  State<StatefulWidget> createState() {
-    return CreateLocationState();
-  }
-}
-
-class CreateLocationState extends State<CreateLocation> {
-  TextEditingController locationController = TextEditingController();
-  List<TextEditingController> centerPointController = List.from(
-    [TextEditingController(text: "0.0"), TextEditingController(text: "0.0")],
-  );
-  List<double> centerPoint = List.of([0, 0]);
-  final List<double> values = [2, 10, 20, 40, 80, 200, 400, 1200];
-  int slider = 0;
-
-  Dialog selectCenterPoint(BuildContext context) => Dialog(
-        shape: RoundedRectangleBorder(
-          borderRadius: BorderRadius.circular(12.0),
-        ), //this right here
-        child: SizedBox(
-          height: 300.0,
-          width: 300.0,
-          child: Column(
-            mainAxisAlignment: MainAxisAlignment.center,
-            children: <Widget>[
-              Padding(
-                padding: const EdgeInsets.all(15),
-                child: TextField(
-                  controller: centerPointController[0],
-                  decoration: const InputDecoration(
-                    border: OutlineInputBorder(),
-                    labelText: 'Longitude',
-                    hintText: 'Enter Longitude',
-                  ),
-                  keyboardType: TextInputType.number,
-                ),
-              ),
-              Padding(
-                padding: const EdgeInsets.all(15),
-                child: TextField(
-                  controller: centerPointController[1],
-                  decoration: const InputDecoration(
-                    border: OutlineInputBorder(),
-                    labelText: 'Latitude',
-                    hintText: 'Enter Latitude',
-                  ),
-                  keyboardType: TextInputType.number,
-                ),
-              ),
-              const Padding(padding: EdgeInsets.only(top: 50.0)),
-              TextButton(
-                onPressed: () {
-                  setState(() {
-                    centerPoint = List.of([
-                      double.parse(centerPointController[0].text),
-                      double.parse(centerPointController[1].text)
-                    ]);
-                  });
-                  Navigator.of(context).pop();
-                },
-                child: Text(
-                  'Select',
-                  style: TextStyle(
-                    color: Theme.of(context).colorScheme.iconColor,
-                    fontSize: 18.0,
-                  ),
-                ),
-              )
-            ],
-          ),
-        ),
-      );
-  @override
-  Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(),
-      body: SingleChildScrollView(
-        child: Column(
-          children: [
-            const SizedBox(height: 12),
-            Container(
-              margin: const EdgeInsets.fromLTRB(16, 12, 0, 0),
-              child: const Align(
-                alignment: Alignment.centerLeft,
-                child: Text.rich(
-                  TextSpan(text: "Add Location"),
-                  textAlign: TextAlign.start,
-                  style: TextStyle(fontSize: 24, fontWeight: FontWeight.w800),
-                ),
-              ),
-            ),
-            const SizedBox(height: 12),
-            Padding(
-              padding: const EdgeInsets.all(15),
-              child: TextField(
-                controller: locationController,
-                decoration: InputDecoration(
-                  filled: true,
-                  fillColor: Theme.of(context).colorScheme.subTextColor,
-                  hintStyle: TextStyle(
-                    color: Theme.of(context).colorScheme.primary,
-                  ),
-                  border: const OutlineInputBorder(),
-                  hintText: 'Enter Your Location',
-                ),
-              ),
-            ),
-            Container(
-              margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
-              padding: const EdgeInsets.all(7),
-              decoration: BoxDecoration(
-                color: Theme.of(context).cardColor,
-                border: Border.all(
-                  color: Theme.of(context).dividerColor,
-                  width: 1,
-                ),
-                borderRadius: const BorderRadius.all(Radius.circular(10)),
-              ),
-              child: ListTile(
-                horizontalTitleGap: 2,
-                leading: const Icon(Icons.location_on_rounded),
-                title: const Text(
-                  "Center Point",
-                ),
-                subtitle: Text(
-                  "${convertLatLng(centerPoint[0], true)}, ${convertLatLng(centerPoint[1], false)}",
-                  style: Theme.of(context).textTheme.bodyMedium!.copyWith(
-                        color: Theme.of(context)
-                            .colorScheme
-                            .defaultTextColor
-                            .withOpacity(0.5),
-                      ),
-                ),
-                trailing: IconButton(
-                  onPressed: () async {
-                    showDialog(
-                      context: context,
-                      builder: (BuildContext context) =>
-                          selectCenterPoint(context),
-                    );
-                  },
-                  icon: const Icon(Icons.edit),
-                ),
-              ),
-            ),
-            Padding(
-              padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
-              child: Row(
-                mainAxisAlignment: MainAxisAlignment.spaceAround,
-                children: [
-                  Container(
-                    height: 65,
-                    width: 70,
-                    padding: const EdgeInsets.all(10),
-                    decoration: BoxDecoration(
-                      color: Theme.of(context).focusColor,
-                      borderRadius: const BorderRadius.all(Radius.circular(5)),
-                    ),
-                    child: Column(
-                      children: [
-                        Text(
-                          values[slider].round().toString(),
-                          style: const TextStyle(
-                            fontSize: 18,
-                            fontWeight: FontWeight.w700,
-                          ),
-                        ),
-                        const Text(
-                          "Km",
-                          style: TextStyle(
-                            fontWeight: FontWeight.w200,
-                          ),
-                        )
-                      ],
-                    ),
-                  ),
-                  Expanded(
-                    child: Container(
-                      padding: const EdgeInsets.symmetric(vertical: 15),
-                      child: Column(
-                        crossAxisAlignment: CrossAxisAlignment.start,
-                        children: [
-                          const Padding(
-                            padding: EdgeInsets.only(left: 20),
-                            child: Text(
-                              "Radius",
-                              style: TextStyle(
-                                fontWeight: FontWeight.w500,
-                              ),
-                            ),
-                          ),
-                          Row(
-                            children: [
-                              Expanded(
-                                child: SliderTheme(
-                                  data: SliderTheme.of(context).copyWith(
-                                    trackHeight: 5,
-                                    activeTrackColor: Theme.of(context)
-                                        .colorScheme
-                                        .inverseBackgroundColor,
-                                    inactiveTrackColor: Theme.of(context)
-                                        .colorScheme
-                                        .subTextColor,
-                                    thumbColor: Theme.of(context)
-                                        .colorScheme
-                                        .inverseBackgroundColor,
-                                  ),
-                                  child: SizedBox(
-                                    width: double.infinity,
-                                    child: Slider(
-                                      value: slider.toDouble(),
-                                      min: 0,
-                                      max: values.length - 1,
-                                      divisions: values.length - 1,
-                                      label: values[slider].toString(),
-                                      onChanged: (double value) {
-                                        setState(() {
-                                          slider = value.toInt();
-                                        });
-                                      },
-                                    ),
-                                  ),
-                                ),
-                              ),
-                            ],
-                          )
-                        ],
-                      ),
-                    ),
-                  ),
-                ],
-              ),
-            ),
-            const SizedBox(height: 200),
-            Align(
-              alignment: Alignment.bottomCenter,
-              child: Padding(
-                padding: const EdgeInsets.fromLTRB(20, 24, 20, 100),
-                child: GradientButton(
-                  onTap: () async {
-                    await LocationService.instance.addLocation(
-                      locationController.text,
-                      centerPoint[0],
-                      centerPoint[1],
-                      values[slider].toInt(),
-                    );
-                    Navigator.pop(context);
-                  },
-                  text: "Add Location",
-                  iconData: Icons.location_on,
-                ),
-              ),
-            )
-          ],
-        ),
-      ),
-    );
-  }
-}

+ 0 - 214
lib/ui/viewer/file/locations_list.dart

@@ -1,214 +0,0 @@
-import "dart:async";
-import "dart:convert";
-
-import "package:flutter/material.dart";
-import "package:photos/db/files_db.dart";
-import "package:photos/ente_theme_data.dart";
-import "package:photos/services/location_service.dart";
-import "package:photos/ui/viewer/file/location_detail.dart";
-
-//state = 0; normal mode
-//state = 1; selection mode
-class LocationsList extends StatelessWidget {
-  final int state;
-  final int? fileId;
-  LocationsList({super.key, this.state = 0, this.fileId});
-
-  final clusteredLocationList =
-      LocationService.instance.clusterFilesByLocation();
-
-  @override
-  Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(),
-      body: SingleChildScrollView(
-        child: Column(
-          children: [
-            const SizedBox(height: 12),
-            Container(
-              margin: const EdgeInsets.fromLTRB(16, 12, 0, 0),
-              child: const Align(
-                alignment: Alignment.centerLeft,
-                child: Text.rich(
-                  TextSpan(text: "Locations"),
-                  textAlign: TextAlign.start,
-                  style: TextStyle(fontSize: 24, fontWeight: FontWeight.w800),
-                ),
-              ),
-            ),
-            Container(
-              margin: const EdgeInsets.fromLTRB(16, 12, 0, 0),
-              child: Align(
-                alignment: Alignment.centerLeft,
-                child: Text.rich(
-                  TextSpan(text: clusteredLocationList.length.toString()),
-                  textAlign: TextAlign.start,
-                  style: const TextStyle(
-                    fontSize: 16,
-                    fontWeight: FontWeight.w100,
-                  ),
-                ),
-              ),
-            ),
-            const SizedBox(height: 12),
-            ...clusteredLocationList.entries.map((entry) {
-              final location = json.decode(entry.key);
-              return InkWell(
-                onTap: () async {
-                  if (state == 1) {
-                    await LocationService.instance
-                        .addFileToLocation(location["id"], fileId!);
-                    Navigator.pop(context);
-                  }
-                },
-                child: Container(
-                  margin: const EdgeInsets.symmetric(
-                    horizontal: 15,
-                    vertical: 10,
-                  ),
-                  padding: const EdgeInsets.all(10),
-                  decoration: BoxDecoration(
-                    color: Theme.of(context).cardColor,
-                    border: Border.all(color: Theme.of(context).dividerColor),
-                    borderRadius: const BorderRadius.all(Radius.circular(10)),
-                  ),
-                  child: ListTile(
-                    horizontalTitleGap: 2,
-                    title: Text(
-                      location["name"],
-                    ),
-                    subtitle: Text(
-                      "${entry.value.length} memories",
-                      style: Theme.of(context).textTheme.bodyMedium!.copyWith(
-                            color: Theme.of(context)
-                                .colorScheme
-                                .defaultTextColor
-                                .withOpacity(0.5),
-                          ),
-                    ),
-                    trailing: state == 0
-                        ? IconButton(
-                            onPressed: () async {},
-                            icon: const Icon(Icons.arrow_forward_ios),
-                          )
-                        : null,
-                  ),
-                ),
-              );
-            }).toList(),
-            InkWell(
-              onTap: () {
-                unawaited(
-                  Navigator.of(context).push(
-                    MaterialPageRoute(
-                      builder: (BuildContext context) {
-                        return const CreateLocation();
-                      },
-                    ),
-                  ),
-                );
-              },
-              child: Container(
-                margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
-                padding: const EdgeInsets.all(10),
-                decoration: BoxDecoration(
-                  color: Theme.of(context).cardColor,
-                  border: Border.all(
-                    color: Theme.of(context).dividerColor,
-                    width: 1,
-                  ),
-                  borderRadius: const BorderRadius.all(Radius.circular(10)),
-                ),
-                child: const ListTile(
-                  horizontalTitleGap: 2,
-                  leading: Icon(Icons.add_location_alt_rounded),
-                  title: Text(
-                    "Add New",
-                  ),
-                ),
-              ),
-            )
-          ],
-        ),
-      ),
-    );
-  }
-}
-
-class LocationFilesList extends StatelessWidget {
-  final List<String> fileIDs;
-  const LocationFilesList({super.key, required this.fileIDs});
-
-  Future<void> generateFiles() async {
-    final files = List.empty(growable: true);
-    for (String fileID in fileIDs) {
-      final file = await (FilesDB.instance.getFile(int.parse(fileID)));
-      files.add(file!);
-    }
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(),
-      body: SingleChildScrollView(
-        child: Column(
-          children: [
-            ...LocationService.instance
-                .clusterFilesByLocation()
-                .entries
-                .map(
-                  (entry) => Container(
-                    decoration: BoxDecoration(
-                      color: Theme.of(context).cardColor,
-                      border: Border.all(color: Theme.of(context).dividerColor),
-                      borderRadius: const BorderRadius.all(Radius.circular(10)),
-                    ),
-                    child: ListTile(
-                      horizontalTitleGap: 2,
-                      title: Text(
-                        entry.key,
-                      ),
-                      subtitle: Text(
-                        "${entry.value.length} memories",
-                        style: Theme.of(context).textTheme.bodyMedium!.copyWith(
-                              color: Theme.of(context)
-                                  .colorScheme
-                                  .defaultTextColor
-                                  .withOpacity(0.5),
-                            ),
-                      ),
-                      trailing: IconButton(
-                        onPressed: () async {},
-                        icon: const Icon(Icons.arrow_forward_ios),
-                      ),
-                    ),
-                  ),
-                )
-                .toList(),
-            Container(
-              decoration: BoxDecoration(
-                color: Theme.of(context).cardColor,
-                border: Border.all(
-                  color: Theme.of(context).dividerColor,
-                  width: 1,
-                ),
-                borderRadius: const BorderRadius.all(Radius.circular(10)),
-              ),
-              child: const ListTile(
-                horizontalTitleGap: 2,
-                leading: Padding(
-                  padding: EdgeInsets.only(top: 8),
-                  child: Icon(Icons.add_location_alt_rounded),
-                ),
-                title: Text(
-                  "Add Location",
-                ),
-              ),
-            )
-          ],
-        ),
-      ),
-    );
-  }
-}

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

@@ -1,6 +1,7 @@
 import "dart:async";
 
 import "package:flutter/material.dart";
+import "package:photos/models/location/location.dart";
 import "package:photos/services/location_service.dart";
 import "package:photos/states/location_screen_state.dart";
 import "package:photos/ui/components/buttons/chip_button_widget.dart";
@@ -11,8 +12,8 @@ import "package:photos/ui/viewer/location/location_screen.dart";
 import "package:photos/utils/navigation_util.dart";
 
 class LocationTagsWidget extends StatefulWidget {
-  final List<double> coordinates;
-  const LocationTagsWidget(this.coordinates, {super.key});
+  final Location centerPoint;
+  const LocationTagsWidget(this.centerPoint, {super.key});
 
   @override
   State<LocationTagsWidget> createState() => _LocationTagsWidgetState();
@@ -47,14 +48,14 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
 
   Future<List<Widget>> _getLocationTags() async {
     final locationTags =
-        LocationService.instance.enclosingLocationTags(widget.coordinates);
+        LocationService.instance.enclosingLocationTags(widget.centerPoint);
     if (locationTags.isEmpty) {
       return [
         InlineButtonWidget(
           "Group nearby photos",
           () => showAddLocationSheet(
             context,
-            widget.coordinates,
+            widget.centerPoint,
             //This callback is for reloading the locationTagsWidget after adding a new location tag
             //so that it updates in file details.
             () {
@@ -91,7 +92,7 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {
         leadingIcon: Icons.add_outlined,
         onTap: () => showAddLocationSheet(
           context,
-          widget.coordinates,
+          widget.centerPoint,
           //This callback is for reloading the locationTagsWidget after adding a new location tag
           //so that it updates in file details.
           () {

+ 2 - 2
lib/ui/viewer/location/add_location_gallery_widget.dart

@@ -58,8 +58,8 @@ class _DynamicLocationGalleryWidgetState
               f.location!.longitude != null,
         );
         return !LocationService.instance.isFileInsideLocationTag(
-          InheritedLocationTagData.of(context).coordinates,
-          [f.location!.latitude!, f.location!.longitude!],
+          InheritedLocationTagData.of(context).centerPoint,
+          f.location!,
           selectedRadius,
         );
       });

+ 4 - 4
lib/ui/viewer/location/add_location_sheet.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
 import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
 import "package:photos/core/constants.dart";
+import "package:photos/models/location/location.dart";
 import "package:photos/services/location_service.dart";
 import 'package:photos/states/location_state.dart';
 import "package:photos/theme/colors.dart";
@@ -17,7 +18,7 @@ import "package:photos/ui/viewer/location/radius_picker_widget.dart";
 
 showAddLocationSheet(
   BuildContext context,
-  List<double> coordinates,
+  Location coordinates,
   VoidCallback onLocationAdded,
 ) {
   showBarModalBottomSheet(
@@ -195,12 +196,11 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
 
   Future<void> _addLocationTag(String locationName) async {
     final locationData = InheritedLocationTagData.of(context);
-    final coordinates = locationData.coordinates;
+    final coordinates = locationData.centerPoint;
     final radius = radiusValues[locationData.selectedRadiusIndex];
     await LocationService.instance.addLocation(
       locationName,
-      coordinates.first,
-      coordinates.last,
+      coordinates,
       radius,
     );
     widget.onLocationAdded.call();

+ 2 - 1
lib/ui/viewer/location/edit_location_sheet.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
 import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
 import "package:photos/core/constants.dart";
+import "package:photos/models/location/location.dart";
 import "package:photos/states/location_state.dart";
 import "package:photos/theme/colors.dart";
 import "package:photos/theme/ente_theme.dart";
@@ -16,7 +17,7 @@ import "package:photos/ui/viewer/location/radius_picker_widget.dart";
 
 showEditLocationSheet(
   BuildContext context,
-  List<double> centerPoint,
+  Location centerPoint,
   VoidCallback onLocationEdited,
 ) {
   showBarModalBottomSheet(

+ 11 - 3
lib/ui/viewer/location/location_screen.dart

@@ -2,6 +2,7 @@ import 'dart:developer' as dev;
 import "package:flutter/material.dart";
 import "package:photos/models/file.dart";
 import "package:photos/models/file_load_result.dart";
+import "package:photos/models/location/location.dart";
 import "package:photos/services/files_service.dart";
 import "package:photos/services/location_service.dart";
 import "package:photos/states/location_screen_state.dart";
@@ -26,7 +27,11 @@ class LocationScreen extends StatelessWidget {
           actionIcons: [
             IconButton(
               onPressed: () {
-                showEditLocationSheet(context, [63.5, -18.5], () {});
+                showEditLocationSheet(
+                  context,
+                  const Location(latitude: 63.5, longitude: -18.5),
+                  () {},
+                );
               },
               icon: const Icon(Icons.edit_rounded),
             )
@@ -90,8 +95,11 @@ class _LocationGalleryWidgetState extends State<LocationGalleryWidget> {
               f.location!.longitude != null,
         );
         return !LocationService.instance.isFileInsideLocationTag(
-          [63.5, -18.5], //pass the coordinates from the location tag here
-          [f.location!.latitude!, f.location!.longitude!],
+          const Location(
+            latitude: 63.5,
+            longitude: -18.5,
+          ), //pass the coordinates from the location tag here
+          f.location!,
           selectedRadius,
         );
       });