Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bloc/location/location_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LocationCubit extends Cubit<LocationState> {
final GeolocationRepository geolocationRepository;

Future<void> locate() async {
if (state is LocationReady) {
if (state is! LocationDetermining) {
emit(LocationDetermining());
var result = await geolocationRepository.locate();
emit(LocationDetermined(
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/map/map_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _MapScreenState extends State<MapScreen> {
panelBuilder: (ScrollController sc) => Container(
decoration: BoxDecoration(borderRadius: radius),
child: BottomPanel(scrollController: sc)),
body: const RasterMap()),
body: RasterMap(floatingPanelPosition: _floatingPanelPosition)),
const MapHeader(),
FloatingPanel(floatingPanelPosition: _floatingPanelPosition),
const MarkerSelectionFooter()
Expand Down
39 changes: 38 additions & 1 deletion lib/screens/map/raster_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:aed_map/bloc/edit/edit_state.dart';
import 'package:aed_map/bloc/routing/routing_cubit.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
Expand All @@ -20,7 +21,9 @@ import '../../shared/cached_network_tile_provider.dart';
import '../../shared/utils.dart';

class RasterMap extends StatefulWidget {
const RasterMap({super.key});
const RasterMap({super.key, required this.floatingPanelPosition});

final double floatingPanelPosition;

@override
State<RasterMap> createState() => _RasterMapState();
Expand Down Expand Up @@ -222,6 +225,31 @@ class _RasterMapState extends State<RasterMap> with TickerProviderStateMixin {
}
return Container();
}),
Positioned(
right: 16,
bottom: 116 + (widget.floatingPanelPosition * 340),
child: SafeArea(
maintainBottomViewPadding: true,
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
context.read<LocationCubit>().locate();
},
child: Card(
color: CupertinoColors.secondarySystemBackground
.resolveFrom(context),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
CupertinoIcons.location,
color:
CupertinoColors.label.resolveFrom(context),
),
),
),
),
),
),
],
)),
],
Expand All @@ -237,6 +265,15 @@ class _RasterMapState extends State<RasterMap> with TickerProviderStateMixin {
if (!isMapInitialized) {
return;
}

final distance = const Distance().as(
LengthUnit.Kilometer, mapController.camera.center, destLocation);

if (distance > 50) {
mapController.move(destLocation, destZoom);
return;
}

final latTween = Tween<double>(
begin: mapController.camera.center.latitude,
end: destLocation.latitude);
Expand Down
Loading