Integration settings improvements
This commit is contained in:
@ -30,7 +30,7 @@ class LocationManager {
|
||||
}
|
||||
}
|
||||
|
||||
void setSettings(bool enabled, int interval) async {
|
||||
setSettings(bool enabled, int interval) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (interval != _updateInterval.inMinutes) {
|
||||
prefs.setInt("location-interval", interval);
|
||||
|
@ -13,6 +13,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
|
||||
int _locationInterval = LocationManager().defaultUpdateIntervalMinutes;
|
||||
bool _locationTrackingEnabled = false;
|
||||
bool _wait = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -108,13 +109,15 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
Text("Enable device location tracking"),
|
||||
Switch(
|
||||
value: _locationTrackingEnabled,
|
||||
onChanged: (value) {
|
||||
SharedPreferences.getInstance().then((prefs) => prefs.setBool("location-enabled", value));
|
||||
if (value) {
|
||||
LocationManager().updateDeviceLocation();
|
||||
}
|
||||
onChanged: _wait ? null : (value) {
|
||||
setState(() {
|
||||
_locationTrackingEnabled = value;
|
||||
_wait = true;
|
||||
});
|
||||
LocationManager().setSettings(_locationTrackingEnabled, _locationInterval).then((_){
|
||||
setState(() {
|
||||
_wait = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user