Start Add location flow when clicked on locationSuggestion
This commit is contained in:
parent
3080dcf9f1
commit
4cf56a2fa2
3 changed files with 40 additions and 8 deletions
|
@ -3,6 +3,7 @@ import "dart:math";
|
|||
import "package:flutter/cupertino.dart";
|
||||
import "package:intl/intl.dart";
|
||||
import 'package:logging/logging.dart';
|
||||
import "package:photos/core/constants.dart";
|
||||
import 'package:photos/core/event_bus.dart';
|
||||
import 'package:photos/data/holidays.dart';
|
||||
import 'package:photos/data/months.dart';
|
||||
|
@ -17,6 +18,7 @@ import "package:photos/models/file/extensions/file_props.dart";
|
|||
import 'package:photos/models/file/file.dart';
|
||||
import 'package:photos/models/file/file_type.dart';
|
||||
import "package:photos/models/local_entity_data.dart";
|
||||
import "package:photos/models/location/location.dart";
|
||||
import "package:photos/models/location_tag/location_tag.dart";
|
||||
import 'package:photos/models/search/album_search_result.dart';
|
||||
import 'package:photos/models/search/generic_search_result.dart';
|
||||
|
@ -25,6 +27,7 @@ import 'package:photos/services/collections_service.dart';
|
|||
import "package:photos/services/location_service.dart";
|
||||
import 'package:photos/services/semantic_search/semantic_search_service.dart';
|
||||
import "package:photos/states/location_screen_state.dart";
|
||||
import "package:photos/ui/viewer/location/add_location_sheet.dart";
|
||||
import "package:photos/ui/viewer/location/location_screen.dart";
|
||||
import 'package:photos/utils/date_time_util.dart';
|
||||
import "package:photos/utils/navigation_util.dart";
|
||||
|
@ -772,6 +775,15 @@ class SearchService {
|
|||
ResultType.locationSuggestion,
|
||||
city.city,
|
||||
results[city]!,
|
||||
onResultTap: (ctx) {
|
||||
Navigator.of(ctx).pop();
|
||||
showAddLocationSheet(
|
||||
ctx,
|
||||
Location(latitude: city.lat, longitude: city.lng),
|
||||
name: city.city,
|
||||
radius: defaultCityRadius,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,14 @@ import "package:photos/utils/debouncer.dart";
|
|||
class LocationTagStateProvider extends StatefulWidget {
|
||||
final LocalEntity<LocationTag>? locationTagEntity;
|
||||
final Location? centerPoint;
|
||||
final double? radius;
|
||||
final Widget child;
|
||||
const LocationTagStateProvider(
|
||||
this.child, {
|
||||
this.centerPoint,
|
||||
this.locationTagEntity,
|
||||
// if the locationTagEntity is null, we use the centerPoint and radius
|
||||
this.radius,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
@ -47,9 +50,12 @@ class _LocationTagStateProviderState extends State<LocationTagStateProvider> {
|
|||
///If the location tag has a custom radius value, we add the custom radius
|
||||
///value to the list of default radius values only for this location tag and
|
||||
///keep it in the state of this widget.
|
||||
_radiusValues = _getRadiusValuesOfLocTag(_locationTagEntity?.item.radius);
|
||||
_radiusValues = _getRadiusValuesOfLocTag(
|
||||
_locationTagEntity?.item.radius ?? widget.radius,
|
||||
);
|
||||
|
||||
_selectedRadius = _locationTagEntity?.item.radius ?? defaultRadiusValue;
|
||||
_selectedRadius =
|
||||
_locationTagEntity?.item.radius ?? widget.radius ?? defaultRadiusValue;
|
||||
|
||||
_locTagEntityListener =
|
||||
Bus.instance.on<LocationTagUpdatedEvent>().listen((event) {
|
||||
|
|
|
@ -22,14 +22,20 @@ import "package:photos/ui/viewer/location/radius_picker_widget.dart";
|
|||
|
||||
showAddLocationSheet(
|
||||
BuildContext context,
|
||||
Location coordinates,
|
||||
) {
|
||||
Location coordinates, {
|
||||
String name = '',
|
||||
double radius = defaultRadiusValue,
|
||||
}) {
|
||||
showBarModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return LocationTagStateProvider(
|
||||
centerPoint: coordinates,
|
||||
const AddLocationSheet(),
|
||||
AddLocationSheet(
|
||||
radius: radius,
|
||||
name: name,
|
||||
),
|
||||
radius: radius,
|
||||
);
|
||||
},
|
||||
shape: const RoundedRectangleBorder(
|
||||
|
@ -45,7 +51,13 @@ showAddLocationSheet(
|
|||
}
|
||||
|
||||
class AddLocationSheet extends StatefulWidget {
|
||||
const AddLocationSheet({super.key});
|
||||
final double radius;
|
||||
final String name;
|
||||
const AddLocationSheet({
|
||||
super.key,
|
||||
this.radius = defaultRadiusValue,
|
||||
this.name = '',
|
||||
});
|
||||
|
||||
@override
|
||||
State<AddLocationSheet> createState() => _AddLocationSheetState();
|
||||
|
@ -61,8 +73,7 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
|
|||
final ValueNotifier<bool> _submitNotifer = ValueNotifier(false);
|
||||
|
||||
final ValueNotifier<bool> _cancelNotifier = ValueNotifier(false);
|
||||
final ValueNotifier<double> _selectedRadiusNotifier =
|
||||
ValueNotifier(defaultRadiusValue);
|
||||
late ValueNotifier<double> _selectedRadiusNotifier;
|
||||
final _focusNode = FocusNode();
|
||||
final _textEditingController = TextEditingController();
|
||||
final _isEmptyNotifier = ValueNotifier(true);
|
||||
|
@ -70,8 +81,11 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
_textEditingController.text = widget.name;
|
||||
_focusNode.addListener(_focusNodeListener);
|
||||
_selectedRadiusNotifier = ValueNotifier(widget.radius);
|
||||
_selectedRadiusNotifier.addListener(_selectedRadiusListener);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue