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