瀏覽代碼

Location fixes (#1721)

Neeraj Gupta 1 年之前
父節點
當前提交
ea723f1183
共有 2 個文件被更改,包括 10 次插入8 次删除
  1. 2 2
      lib/services/search_service.dart
  2. 8 6
      lib/ui/viewer/location/add_location_sheet.dart

+ 2 - 2
lib/services/search_service.dart

@@ -731,6 +731,8 @@ class SearchService {
               tagToItemsMap[tag]!.add(file);
             }
           }
+          // If the location tag already exists for a city, do not consider
+          // it for the city suggestions
           if (!hasLocationTag) {
             filesWithNoLocTag.add(file);
           }
@@ -769,14 +771,12 @@ class SearchService {
           ..sort((a, b) => results[b]!.length.compareTo(results[a]!.length));
         for (final city in sortedByResultCount) {
           if (results[city]!.length <= 1) continue;
-          // If the location tag already exists for a city, don't add it again
           tagSearchResults.add(
             GenericSearchResult(
               ResultType.locationSuggestion,
               city.city,
               results[city]!,
               onResultTap: (ctx) {
-                Navigator.of(ctx).pop();
                 showAddLocationSheet(
                   ctx,
                   Location(latitude: city.lat, longitude: city.lng),

+ 8 - 6
lib/ui/viewer/location/add_location_sheet.dart

@@ -76,12 +76,13 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
   late ValueNotifier<double> _selectedRadiusNotifier;
   final _focusNode = FocusNode();
   final _textEditingController = TextEditingController();
-  final _isEmptyNotifier = ValueNotifier(true);
+  late final ValueNotifier<bool> _isEmptyNotifier;
   Widget? _keyboardTopButtons;
 
   @override
   void initState() {
     _textEditingController.text = widget.name;
+    _isEmptyNotifier = ValueNotifier(widget.name.isEmpty);
     _focusNode.addListener(_focusNodeListener);
     _selectedRadiusNotifier = ValueNotifier(widget.radius);
     _selectedRadiusNotifier.addListener(_selectedRadiusListener);
@@ -169,11 +170,12 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
                         RadiusPickerWidget(
                           _selectedRadiusNotifier,
                         ),
-                        const SizedBox(height: 16),
-                        Text(
-                          S.of(context).locationTagFeatureDescription,
-                          style: textTheme.smallMuted,
-                        ),
+                        if (widget.name.isEmpty) const SizedBox(height: 16),
+                        if (widget.name.isEmpty)
+                          Text(
+                            S.of(context).locationTagFeatureDescription,
+                            style: textTheme.smallMuted,
+                          ),
                       ],
                     ),
                   ),