Disabling location tracking

This commit is contained in:
estevez-dev
2019-09-03 20:13:23 +03:00
parent ab5bf3b807
commit 620aa3b8d8
6 changed files with 1 additions and 273 deletions

View File

@ -9,40 +9,9 @@ class ConfigPanelWidget extends StatefulWidget {
class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
int _locationInterval = LocationManager().defaultUpdateIntervalMinutes;
bool _locationTrackingEnabled = false;
@override
void initState() {
super.initState();
_loadSettings();
}
_loadSettings() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.reload();
SharedPreferences.getInstance().then((prefs) {
setState(() {
_locationTrackingEnabled = prefs.getBool("location-enabled") ?? false;
_locationInterval = prefs.getInt("location-interval") ?? LocationManager().defaultUpdateIntervalMinutes;
});
});
}
void incLocationInterval() {
if (_locationInterval < 720) {
setState(() {
_locationInterval = _locationInterval + 1;
});
}
}
void decLocationInterval() {
if (_locationInterval > 1) {
setState(() {
_locationInterval = _locationInterval - 1;
});
}
}
restart() {
@ -123,43 +92,6 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
)
],
),
Divider(),
Text("Location tracking", style: TextStyle(fontSize: Sizes.largeFontSize-2)),
Container(height: Sizes.rowPadding,),
Row(
children: <Widget>[
Text("Enable device location tracking"),
Switch(
value: _locationTrackingEnabled,
onChanged: (value) {
SharedPreferences.getInstance().then((prefs) => prefs.setBool("location-enabled", value));
setState(() {
_locationTrackingEnabled = value;
});
},
),
],
),
Container(height: Sizes.rowPadding,),
Text("Location update interval in minutes:"),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
//Expanded(child: Container(),),
FlatButton(
padding: EdgeInsets.all(0.0),
child: Text("+", style: TextStyle(fontSize: Sizes.largeFontSize)),
onPressed: () => incLocationInterval(),
),
Text("$_locationInterval", style: TextStyle(fontSize: Sizes.largeFontSize)),
FlatButton(
padding: EdgeInsets.all(0.0),
child: Text("-", style: TextStyle(fontSize: Sizes.largeFontSize)),
onPressed: () => decLocationInterval(),
),
],
)
],
),
),
@ -183,7 +115,6 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
@override
void dispose() {
LocationManager().setSettings(_locationTrackingEnabled, _locationInterval);
super.dispose();
}
}