added dialog when location is disabled
This commit is contained in:
parent
9fbc19ff7e
commit
27ffb07256
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:app/extensions/obtainProviderExtension.dart';
|
import 'package:app/extensions/obtainProviderExtension.dart';
|
||||||
import 'package:app/extensions/positionLatLngExtension.dart';
|
import 'package:app/extensions/positionLatLngExtension.dart';
|
||||||
import 'package:app/state/mapState.dart';
|
import 'package:app/state/mapState.dart';
|
||||||
@ -32,14 +34,42 @@ class _HomePageState extends State<HomeView> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
requestLiveLocation(context.obtainState<MapState>(), false, true, true);
|
requestLiveLocation(false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> requestLiveLocation(MapState mapState, bool ask, bool orLast, bool loadingIndicator) async {
|
Future<void> requestLiveLocation(bool ask, bool orLast, bool loadingIndicator) async {
|
||||||
Position? position;
|
Position? position;
|
||||||
|
MapState mapState = context.obtainState<MapState>();
|
||||||
LocationPermission permission = await Geolocator.checkPermission();
|
LocationPermission permission = await Geolocator.checkPermission();
|
||||||
|
log(permission.toString());
|
||||||
|
|
||||||
if (loadingIndicator && permission != LocationPermission.deniedForever) {
|
if(
|
||||||
|
permission == LocationPermission.denied
|
||||||
|
|| permission == LocationPermission.deniedForever
|
||||||
|
|| permission == LocationPermission.unableToDetermine
|
||||||
|
) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text("Standort"),
|
||||||
|
content: const Text("Dein Standort konnte nicht bestimmt werden.\nAktiviere für die Standortbestimmung deinen Standort und gib der App die entsprechenden Berechtigungen."),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text("Okay"),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
loadingIndicator
|
||||||
|
&& permission != LocationPermission.deniedForever
|
||||||
|
&& permission != LocationPermission.denied
|
||||||
|
) {
|
||||||
setState(() {
|
setState(() {
|
||||||
locationLoading = true;
|
locationLoading = true;
|
||||||
});
|
});
|
||||||
@ -125,7 +155,7 @@ class _HomePageState extends State<HomeView> {
|
|||||||
}
|
}
|
||||||
return const Icon(Icons.location_disabled);
|
return const Icon(Icons.location_disabled);
|
||||||
}),
|
}),
|
||||||
onPressed: () => requestLiveLocation(context.obtainState<MapState>(), true, false, true),
|
onPressed: () => requestLiveLocation(true, false, true),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
|
Reference in New Issue
Block a user