Commit 9df25a57 authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬
Browse files

Fixed some settings, random reorg, overview pane

Added:
- Separated tiles in preferences to independant files
- Overview tiles
- Overview action buttons

Fixed:
- PreferenceKeys not retrieving correct element
- Regex preference validation
- ExpansionTile object tree removal of hidden objects

Changed:
- Reorganized File structure for preferences and overview
parent 8a3c38c3
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+5\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_blue","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-09-04 17:31:02.114416","version":"1.22.0-2.0.pre.18"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-0.4.9+2\\\\","dependencies":[]},{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-0.4.9+2\\\\","dependencies":[]},{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_macos-0.1.0+4\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"connectivity_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_for_web-0.3.1+2\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+5\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"flutter_blue","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-09-06 03:24:06.407665","version":"1.21.0-10.0.pre.193"}
\ No newline at end of file
......@@ -26,9 +26,11 @@ class PositionHandler {
/// The current [PermissionGroup] right's status.
GeolocationStatus _geolocationStatus;
int _timeSinceLastChange = 0;
/// Default location tweaking options.
/// TODO User configurable ?
LocationOptions locationOptions = LocationOptions(accuracy: LocationAccuracy.high, distanceFilter: 2);
LocationOptions locationOptions = LocationOptions(accuracy: LocationAccuracy.high, distanceFilter: 0, timeInterval: 1);
/// Get whether the user has granted the location permissions.
Stream<GeolocationStatus> getGeolocationStatus() async* {
......@@ -53,7 +55,6 @@ class PositionHandler {
}
/// Try getting the current [Position], and if that fails get the last known [Position]
// TODO Deprecate Last Known Position after <n> seconds
Stream<Position> getCurrentOrLastPosition() async* {
while (true) {
Position currentPosition;
......@@ -61,17 +62,23 @@ class PositionHandler {
await this._getGeolocationPermission();
_permissionChecked = true;
}
if (_geolocationStatus == GeolocationStatus.granted)
currentPosition = await _geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
if (currentPosition != null)
_lastPosition = currentPosition;
if (currentPosition != null)
if (this._timeSinceLastChange >= 10 && _lastPosition != null && currentPosition == null)
this._lastPosition = null;
if (currentPosition != null) {
this._timeSinceLastChange = 0;
yield currentPosition;
else if (currentPosition == null && _lastPosition != null)
} else if (currentPosition == null && _lastPosition != null) {
this._timeSinceLastChange += 1;
yield _lastPosition;
else
} else
yield null;
await Future.delayed(Duration(milliseconds: 1000));
......
import 'package:flutter/cupertino.dart';
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
class BTOverviewWidget extends StatelessWidget {
BTOverviewWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: BTLEHandler().isDeviceConnected(),
initialData: false,
builder: (context, snapshot) {
final bool value = snapshot.data;
if (value)
return Text("Connected");
else
return Text("Not connected");
},
);
}
}
\ No newline at end of file
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttericon/linecons_icons.dart';
import 'package:intersperse/intersperse.dart';
import 'package:intl/intl.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
class DBOverviewWidget extends StatelessWidget {
DBOverviewWidget({Key key}) : super(key: key);
Stream<int> mockStream() async* {
while(true) {
yield 1000000000000000;
await Future.delayed(Duration(seconds: 1));
}
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
width: 50,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(90),
border: Border.all(
color: Colors.blue[500]
),
color: Colors.blue[600],
),
child: Icon(
Linecons.database,
color: Colors.white,
size: 30,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.blue[500]
),
color: Colors.blue[500],
),
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 10),
alignment: Alignment.center,
child: Column(
children: [
Text(
'Packets stored',
style: TextStyle(
color: Colors.white,
fontSize: 16
)
),
StreamBuilder<int>(
stream: DatabaseHandler().getDBSize(),
initialData: 0,
builder: (BuildContext context, AsyncSnapshot snapshot) => Text(
'${NumberFormat.compact().format(snapshot.data)}',
style: TextStyle(
color: Colors.white,
fontSize: 24
)
)
)
],
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.blue[500]
),
color: Colors.blue[500],
),
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 10),
alignment: Alignment.center,
child: Column(
children: [
Text(
'Unsent packets',
style: TextStyle(
color: Colors.white,
fontSize: 16
)
),
StreamBuilder<int>(
stream: DatabaseHandler().getUnsentPacketsLength(),
initialData: 0,
builder: (BuildContext context, AsyncSnapshot snapshot) => Text(
'${NumberFormat.compact().format(snapshot.data)}',
style: TextStyle(
color: Colors.white,
fontSize: 24
)
)
)
],
),
)
],
)
],
);
}
}
\ No newline at end of file
import 'package:flutter/cupertino.dart';
class MapPositionOverviewWidget extends StatelessWidget {
MapPositionOverviewWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Text('Map x GPS oversight');
}
}
\ No newline at end of file
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:logair_application/logic/handlers/network_handler.dart';
class NetworkOverviewWidget extends StatelessWidget {
NetworkOverviewWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
width: 50,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(90),
border: Border.all(
color: Colors.blue[500]
),
color: Colors.blue[600],
),
child: Icon(
Icons.network_check,
color: Colors.white,
size: 30,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.blue[500]
),
color: Colors.blue[500],
),
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 10),
alignment: Alignment.center,
child: Column(
children: [
Text(
'Packets stored',
style: TextStyle(
color: Colors.white,
fontSize: 16
)
),
StreamBuilder<DateTime>(
stream: NetworkHandler().getLastServerConnection(),
initialData: null,
builder: (BuildContext context, AsyncSnapshot snapshot) => Text(
'${(snapshot.data != null) ? DateFormat('kk:mm:ss').format(snapshot.data) : null}',
style: TextStyle(
color: Colors.white,
fontSize: 24
)
)
)
],
),
)
],
),
]
);
}
}
\ No newline at end of file
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class OverviewNavigationButton extends StatelessWidget {
final IconData icon;
final String title;
final Function action;
OverviewNavigationButton({@required this.icon, @required this.title, @required this.action, Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
Spacer(flex: 1),
Expanded(
flex: 3,
child: GestureDetector(
onTap: this.action,
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 7, horizontal: 10),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
offset: Offset(2, -2),
color: Colors.grey[400]
)
],
borderRadius: BorderRadius.circular(10),
color: Colors.blueGrey[100]
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
flex: 2,
child: Icon(
this.icon,
size: 30,
),
),
Expanded(
flex: 8,
child: Text(
this.title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20
),
)
),
],
)
)
)
),
Spacer(flex: 1)
],
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
import 'package:logair_application/ui/animation/forward_animation.dart';
import 'package:logair_application/ui/components/body/overview/bt_overview_widget.dart';
import 'package:logair_application/ui/components/body/overview/db_overview_widget.dart';
import 'package:logair_application/ui/components/body/overview/map_position_overview_widget.dart';
import 'package:logair_application/ui/components/body/overview/network_overview_widget.dart';
import 'package:logair_application/ui/components/body/overview/overview_navigation_button.dart';
import 'package:logair_application/ui/components/dialog/bluetooth_dialog/dialog.dart';
import 'package:logair_application/ui/components/header/header.dart';
import 'package:logair_application/ui/routes/preferences.dart';
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/logic/handlers/network_handler.dart';
import 'package:logair_application/ui/components/common/base_widget.dart';
class OverviewWidget extends StatelessWidget {
OverviewWidget({Key key}) : super(key: key);
Container _buildOverviewCell({@required Widget child}) => Container(
width: double.infinity,
height: double.infinity,
alignment: Alignment.center,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
),
child: Container(
width: double.infinity,
height: double.infinity,
padding: EdgeInsets.all(7),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.grey[400]
),
color: Colors.grey[200],
),
child: child,
),
);
@override
Widget build(BuildContext context) {
return BaseWidget(
builder: (context, sizingInfo) => SafeArea(
child: Scaffold(
body: Center(
child: Column(
children: <Widget>[
Expanded(
flex: 3,
child: Row(
children: [
Expanded(
child: _buildOverviewCell(
child: NetworkOverviewWidget(),
),
),
Expanded(
child: _buildOverviewCell(
child: DBOverviewWidget(),
),
)
],
),
),
Expanded(
flex: 3,
child: Row(
children: [
Expanded(
child: _buildOverviewCell(
child: BTOverviewWidget(),
),
),
Expanded(
child: _buildOverviewCell(
child: MapPositionOverviewWidget(),
),
)
],
),
),
// Carousel
Expanded(
flex: 3,
child: BaseWidget(
builder: (context, sizingInfo) => Container(
width: double.infinity,
height: double.infinity,
child: Column(
children: [
/*
RaisedButton( onPressed: () => DatabaseHandler().data.then((value) => print(value.join("\n"))), child: Text('Print DB'), ),
RaisedButton( onPressed: () => DatabaseHandler().recreateDB(), child: Text('Delete DB'), ),
RaisedButton( onPressed: () => DatabaseHandler().getUnsent(20).then((value) => value.forEach(print)), child: Text('Print unsent'), ),
RaisedButton( onPressed: () => BTWakeHandler().switchState(), child: Text('Toggle BTLE Service'), ),
Spacer( flex: 1, ),
RaisedButton( onPressed: () => DataHandler().printLatest(), child: Text('Print Data Set'), ),
RaisedButton( onPressed: () => DataHandler().clearData(), child: Text('Clear Data'), ),
/// DEBUG END
Spacer( flex: 1, ),*/
Spacer(flex: 2),
/// Access the app settings
OverviewNavigationButton(
icon: Icons.settings,
title: 'Preferences',
action: () => Navigator.push(context, PopForwardRoute(page: SettingsView()))
),
Spacer(flex: 1),
OverviewNavigationButton(
icon: Icons.bluetooth,
title: 'Bluetooth',
action: () => Navigator.push(context, PopForwardRoute(page: BluetoothDialog()))
),
Spacer(flex: 1),
OverviewNavigationButton(
icon: Icons.book,
title: 'Terms of Service',
action: () => {}
),
Spacer(flex: 2),
]
)
)
),
),
/// Header Widget with battery status
Expanded(
flex: 1,
child: Listener(
behavior: HitTestBehavior.opaque,
onPointerDown: (_) => null,
child: GestureDetector(
onLongPress: () {
Navigator.of(context).pop();
},
child: HeaderWidget(false)
),
),
),
],
),
),
),
),
);
}
}
\ No newline at end of file
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttericon/linecons_icons.dart';
import 'package:intersperse/intersperse.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
import 'package:logair_application/logic/handlers/preference_handler.dart';
import 'package:logair_application/ui/components/body/preferences/tiles/text_input_tile.dart';
import 'package:logair_application/ui/components/common/custom_expansion_tile.dart';
import 'package:logair_application/ui/components/common/dash_separator.dart';
import 'package:logair_application/utils/enums/preference_keys.dart';
/// This [Widget] is a [Form] that enables users to change settings.
/// It interacts with the [PreferencesHandler] to affect changes that will be maintained on app restart.
class SettingsForm extends StatefulWidget {
SettingsForm({Key key});
class PreferencesWidget extends StatefulWidget {
PreferencesWidget({Key key});
@override
State<StatefulWidget> createState() => _SettingsFormState(key: key);
State<StatefulWidget> createState() => _PreferencesWidgetState(key: key);
}
class _SettingsFormState extends State<SettingsForm> {
_SettingsFormState({Key key}) {
class _PreferencesWidgetState extends State<PreferencesWidget> {
_PreferencesWidgetState({Key key}) {
PreferencesHandler().getPreferencesBool('BT.USING_ADVANCED').then((value) {
if (this._advancedBTOptions == null)
setState(() {
......@@ -38,8 +39,8 @@ class _SettingsFormState extends State<SettingsForm> {
bool _advancedBTOptions;
bool _advancedMapOptions;
final _netQueryMaxPush = TextEditingController();
final _netQueryFrequency = TextEditingController();
final _netQueryMaxPushController = TextEditingController();
final _netQueryFrequencyController = TextEditingController();
final _bleServiceController = TextEditingController();
final _bleCharacteristicController = TextEditingController();
final _mapQueryLimitController = TextEditingController();
......@@ -52,6 +53,8 @@ class _SettingsFormState extends State<SettingsForm> {
_bleCharacteristicController.dispose();
_mapQueryLimitController.dispose();
_mapQueryAgeController.dispose();
_netQueryMaxPushController.dispose();
_netQueryFrequencyController.dispose();
super.dispose();
}
......@@ -87,11 +90,28 @@ class _SettingsFormState extends State<SettingsForm> {
title: Text('Network'),
initiallyExpanded: true,
leading: Icon(Icons.network_check),
maintainState: true,
children: [
ListTile(title: _buildInputTile(_netQueryMaxPush, 'Maximum number of items per push', 'NET.MAX_ITEMS_PER_PUSH', TextInputType.number, <TextInputFormatter>[ FilteringTextInputFormatter.allow('0-9') ], RegExp(r'.*'))),
ListTile(title: _buildInputTile(_netQueryFrequency, 'Frequency between push attempts (seconds)', 'NET.TIME_TO_PUSH', TextInputType.number, <TextInputFormatter>[ FilteringTextInputFormatter.allow('0-9') ], RegExp(r'.*'))),
ListTile(
title: TextInputTile(
controller: _netQueryMaxPushController,
labelText: 'Maximum number of items per push',
prefsKey: 'NET.MAX_ITEMS_PER_PUSH',
inputType: TextInputType.number,
inputFormatters: <TextInputFormatter>[ FilteringTextInputFormatter.allow('0-9') ],
validation: RegExp(r'\d+')
)
),
ListTile(
title: TextInputTile(
controller: _netQueryFrequencyController,
labelText: 'Frequency between push attempts (seconds)',
prefsKey: 'NET.TIME_TO_PUSH',
inputType: TextInputType.number,
inputFormatters: <TextInputFormatter>[ FilteringTextInputFormatter.allow('0-9') ],
validation: RegExp(r'\d+')
)
),
ListTile(title: Text('TODO: Push on 3G/4G')),
],
),
......@@ -99,7 +119,8 @@ class _SettingsFormState extends State<SettingsForm> {
CustomExpansionTile(
title: Text('Local Data'),
initiallyExpanded: true,
leading: Icon(Icons.storage),
maintainState: true,