update buttons
This commit is contained in:
@ -16,14 +16,21 @@ import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||
import 'package:rogapp/widgets/game_state_view.dart';
|
||||
|
||||
class MapWidget extends StatelessWidget {
|
||||
class MapWidget extends StatefulWidget {
|
||||
MapWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MapWidget> createState() => _MapWidgetState();
|
||||
}
|
||||
|
||||
class _MapWidgetState extends State<MapWidget> {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
MapWidget({Key? key}) : super(key: key);
|
||||
|
||||
StreamSubscription? subscription;
|
||||
Timer? _timer;
|
||||
|
||||
Widget getMarkerShape(GeoJSONFeature i, BuildContext context) {
|
||||
GeoJSONMultiPoint p = i.geometry as GeoJSONMultiPoint;
|
||||
@ -153,6 +160,29 @@ class MapWidget extends StatelessWidget {
|
||||
return pts;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_startIdleTimer();
|
||||
}
|
||||
|
||||
void _startIdleTimer() {
|
||||
_timer =
|
||||
Timer(const Duration(milliseconds: (1000 * 60 * 10)), _centerMapOnUser);
|
||||
}
|
||||
|
||||
void _resetTimer() {
|
||||
_timer?.cancel();
|
||||
_startIdleTimer();
|
||||
}
|
||||
|
||||
void _centerMapOnUser() {
|
||||
indexController.mapController.move(
|
||||
LatLng(
|
||||
destinationController.currentLat, destinationController.currentLon),
|
||||
15.0);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// print(
|
||||
@ -174,7 +204,8 @@ class MapWidget extends StatelessWidget {
|
||||
subscription = indexController.mapController.mapEventStream
|
||||
.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveStart) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
|
||||
// print(DateTime.now().toString() +
|
||||
// ' [MapEventMoveStart] START');
|
||||
// do something
|
||||
}
|
||||
if (mapEvent is MapEventMoveEnd) {}
|
||||
@ -191,7 +222,11 @@ class MapWidget extends StatelessWidget {
|
||||
interactiveFlags:
|
||||
InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
|
||||
onPositionChanged: (MapPosition pos, isvalue) {
|
||||
onPositionChanged: (MapPosition pos, hasGesture) {
|
||||
//print("map position changed ${pos.center!.latitude}");
|
||||
if (hasGesture) {
|
||||
_resetTimer();
|
||||
}
|
||||
indexController.currentBound = [pos.bounds!];
|
||||
},
|
||||
onTap: (_, __) => popupController
|
||||
|
||||
Reference in New Issue
Block a user