Skip to content

Commit

Permalink
fix: Use _locationFetcher for global locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Jun 7, 2023
1 parent df758e6 commit d649c44
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/screens/ViewDetailScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,18 @@ class _ViewDetailScreenState extends State<ViewDetailScreen> {
super.dispose();
}

VoidCallback handleTapOnDate(final Iterable<LocationPointService> locations) => () {
_controller.clear();
VoidCallback handleTapOnDate(final Iterable<LocationPointService> locations) {
return () {
_controller.clear();

if (locations.isNotEmpty) {
_controller.addAll(locations);
_controller.goTo(locations.last);
}
};
if (locations.isNotEmpty) {
_controller.addAll(locations);
_controller.goTo(locations.last);
}

setState(() {});
};
}

Widget buildDateSelectButton(
final List<LocationPointService> locations,
Expand All @@ -161,15 +165,15 @@ class _ViewDetailScreenState extends State<ViewDetailScreen> {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context);
final locationsPerHour = _controller.getLocationsPerHour();
final locationsPerHour = _locationFetcher.controller.getLocationsPerHour();
final maxLocations = locationsPerHour.values.isEmpty
? 0
: locationsPerHour.values.fold(0, (value, element) => value > element.length ? value : element.length);

return PlatformScaffold(
appBar: PlatformAppBar(
title: Text(l10n.viewDetails_title),
trailingActions: _controller.locations.isNotEmpty
trailingActions: _locationFetcher.controller.locations.isNotEmpty
? <Widget>[
Padding(
padding: const EdgeInsets.all(SMALL_SPACE),
Expand All @@ -186,8 +190,10 @@ class _ViewDetailScreenState extends State<ViewDetailScreen> {
context: context,
material: MaterialModalSheetData(),
builder: (context) => OpenInMaps(
destination:
Coords(_controller.locations.last.latitude, _controller.locations.last.longitude),
destination: Coords(
_locationFetcher.controller.locations.last.latitude,
_locationFetcher.controller.locations.last.longitude,
),
),
),
),
Expand Down

0 comments on commit d649c44

Please sign in to comment.