Commit 2e89d17e authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬
Browse files

LOI

parent bf89a2ff
{"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-11 01:27:58.536487","version":"1.21.0-10.0.pre.193"}
\ 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-11 14:39:52.190164","version":"1.22.0-2.0.pre.18"}
\ No newline at end of file
......@@ -52,6 +52,7 @@ class DataPacket {
DataPacket(this._data) {
_timestamp = DateTime.now().millisecondsSinceEpoch;
List<String> acquiredData = String.fromCharCodes(this._data.sublist(1, this._data.length - 1)).split(',');
this._latitude = (acquiredData[0] != '') ? parseDoubleWrapper(acquiredData[0]) : null;
this._longitude = (acquiredData[1] != '') ? parseDoubleWrapper(acquiredData[1]) : null;
this._altitude = (acquiredData[2] != '') ? int.tryParse(acquiredData[2]) : null;
......@@ -81,8 +82,13 @@ class DataPacket {
DataPacket.fromData(this._timestamp, this._latitude, this._longitude, this._altitude, this._speed, this._heading, this._temperature, this._pressure, this._relativeHumidity, this._pm1, this._pm2_5, this._pm4, this._pm10, this._extraData);
// TODO Guard clause
DataPacket.fromMappedData(Map<String, dynamic> data) {
List<String> guardSet = ['device_id', 'timestamp_nix', 'latitude', 'longitude', 'altitude', 'speed', 'heading', 'temperature', 'pressure', 'relative_humidity', 'pm_1', 'pm_2_5', 'pm_4', 'pm_10', 'extra'];
if(data.keys.toList().where((String key) => guardSet.contains(key)).length < guardSet.length) {
throw Exception('Mapped Data Error');
}
this._deviceId = data['device_id'];
this._timestamp = data['timestamp_nix'];
this._latitude = data['latitude'];
......@@ -91,8 +97,8 @@ class DataPacket {
this._speed = data['speed'];
this._heading = data['heading'];
this._temperature = data['temperature'];
this._relativeHumidity = data['relative_humidity'];
this._pressure = data['pressure'];
this._relativeHumidity = data['relative_humidity'];
this._pm1 = data['pm_1'];
this._pm2_5 = data['pm_2_5'];
this._pm4 = data['pm_4'];
......@@ -127,7 +133,7 @@ class DataPacket {
'speed': this._speed,
'heading': this._heading,
'temperature': this._temperature,
'relative_humidity': this._temperature,
'relative_humidity': this.relativeHumidity,
'pressure': this._pressure,
'pm_1': this._pm1,
'pm_2_5': this._pm2_5,
......
......@@ -97,14 +97,6 @@ class DataHandler {
await Future.delayed(Duration(seconds: 1));
}
}
@deprecated
Stream<DataPacket> getMockDataStream() async* {
while(true) {
yield new DataPacket.fromData(1597957282000, 5, 42, 420, 3.0, 32, 24, 10123, 32, null, 5, null, 9, "");
await Future.delayed(Duration(seconds: 1));
}
}
/// This destroys the elements it depends on to avoid duplication or wrong information
void dispose() {
......
......@@ -3,6 +3,7 @@ import 'dart:convert';
import 'dart:collection';
import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:http/http.dart' as http;
......@@ -12,6 +13,8 @@ import 'package:logair_application/logic/handlers/data_handler.dart';
import 'package:logair_application/logic/handlers/main_database_handler.dart';
import 'package:logair_application/logic/handlers/preference_handler.dart';
import 'package:logair_application/utils/enums/preference_keys.dart';
import 'package:logair_application/utils/location_of_interest.dart';
import 'package:logair_application/utils/utils.dart';
import 'package:rxdart/rxdart.dart';
import 'package:tuple/tuple.dart';
......@@ -189,5 +192,64 @@ class NetworkHandler {
}
}
Future<http.Response> _getLocationOfInterestData({@required double latitude, @required double longitude}) async {
if (!(await checkNetworkAllowed())) return null;
// TODO retrieve from preferences.
double focus = 0.0001;
int age = 60000;
/// The default endpoint.
// TODO get focus from preferences
String url = 'https://api.logair.unige.ch/v1/geo/proximity?lat=$latitude&lng=$longitude&age=$age&focus=$focus';
/// Attempt to send the data to the endpoint via HTTP POST request.
http.Response response;
try {
response = await http.get(
url,
headers: { "accept": "application/json", "content-type": "application/json" },
);
/// On error, the error should be ignored and not break the thread.
} catch (e) {
print("${e.toString()} COULDN'T CONNECT");
response = null;
}
return response;
}
//TODO Generate a stream from a place for Place display
Stream<DataPacket> generateLocationOfInterestStream({@required LocationOfInterest loi}) async* {
while (true) {
print('ping');
http.Response response;
try {
response = await _getLocationOfInterestData(latitude: loi.latitude, longitude: loi.longitude);
} catch (e) {
print("${e.toString()} COULDN'T CONNECT");
yield null;
}
DataPacket packet;
if (response != null && response.statusCode == 200) {
Map<String, dynamic> responseBody = json.decode(response.body);
packet = DataPacket.fromData(
0,
loi.latitude, loi.longitude, 0, 0, 0,
castDoubleWrapper(responseBody['avg_temperature']), castDoubleWrapper(responseBody['avg_pressure']), castDoubleWrapper(responseBody['avg_relative_humidity']),
castDoubleWrapper(responseBody['avg_pm_1']), castDoubleWrapper(responseBody['avg_pm_2_5']), castDoubleWrapper(responseBody['avg_pm_4']), castDoubleWrapper(responseBody['avg_pm_10']),
''
);
yield packet;
} else
yield null;
// TODO: Preferences.
await Future.delayed(Duration(seconds: 60));
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart';
import 'package:intersperse/intersperse.dart';
import 'package:logair_application/logic/handlers/data_handler.dart';
import 'package:logair_application/ui/components/body/data/locations_of_interest_tiles.dart';
import 'package:logair_application/ui/components/common/carousel_card.dart';
import 'package:logair_application/ui/components/body/data/graph/graph.dart';
import 'package:logair_application/ui/components/body/data/tiles/data_tile.dart';
......@@ -47,24 +48,7 @@ class DataWidget extends StatelessWidget {
],
),
),
Column(
children: intersperse(
Divider(indent: 10, endIndent: 10, color: Colors.black, height: 5,),
[
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'Home'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'Work'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'C'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'D'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'E'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'F'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'G'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'H'),
DataTile(stream: DataHandler().getMockDataStream(), locationName: 'I')
]
).toList() + [
SizedBox(height: 30,)
],
),
LocationsOfInterestWidget()
],
)
);
......
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intersperse/intersperse.dart';
import 'package:logair_application/logic/handlers/locations_interest_database_handler.dart';
import 'package:logair_application/logic/handlers/network_handler.dart';
import 'package:logair_application/ui/components/body/data/tiles/data_tile.dart';
import 'package:logair_application/utils/location_of_interest.dart';
class LocationsOfInterestWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() => _LocationsOfInterestWidgetState();
}
class _LocationsOfInterestWidgetState extends State<LocationsOfInterestWidget> {
_LocationsOfInterestWidgetState();
List<DataTile> _children = [];
Future<List<DataTile>> _generateChildren() async {
List<LocationOfInterest> loi = await LocationsOfInterestDatabaseHandler().data;
return [];
}
@override
void initState() {
super.initState();
// TODO Listeners.
LocationsOfInterestDatabaseHandler().onUpdate.listen((_) async {
setState(() => {
});
});
}
@override
Widget build(BuildContext context) {
return Column(
children: intersperse(
Divider(indent: 10, endIndent: 10, color: Colors.black, height: 5,),
[
DataTile(
stream: NetworkHandler().generateLocationOfInterestStream(
loi: LocationOfInterest(
id: 0,
latitude: 46.1764826,
longitude: 6.1400497,
name: 'FacLab'
)
),
isDistant: true,
locationName: 'FacLab',
),
]
).toList() + [
SizedBox(height: 30,)
],
);
}
}
\ No newline at end of file
......@@ -79,74 +79,88 @@ class _DataTileState extends State<DataTile> {
@override
Widget build(BuildContext context) {
/// Builds an indicator for a specific PM value, with appropriate AQI color scheme
Widget _buildPMDataCell(PMSymbol pmSymbol, double value) => Expanded(
flex: 1,
child: Container(
padding: EdgeInsets.symmetric(vertical: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: (value != -1 && value != null) ? pmSymbol.colorizeValue(value) : Colors.grey[200],
),
child: Column(
children: [
Text(
pmSymbol.key,
style: TextStyle(
fontSize: 19,
color: (value != -1 && value != null) ? Colors.black : Colors.grey[500]
),
),
SizedBox(height: 4),
Text(
(value != -1 && value != null) ? value.toString() : '',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold
Widget _buildPMDataCell(PMSymbol pmSymbol, double value) {
String valueRepresentation = (value != -1 && value != null) ? value.toStringAsFixed(2) : '';
if (valueRepresentation.endsWith('.00'))
valueRepresentation = valueRepresentation.split('.')[0];
return Expanded(
flex: 1,
child: Container(
padding: EdgeInsets.symmetric(vertical: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: (value != -1 && value != null) ? pmSymbol.colorizeValue(value) : Colors.grey[200],
),
child: Column(
children: [
Text(
pmSymbol.key,
style: TextStyle(
fontSize: 19,
color: (value != -1 && value != null) ? Colors.black : Colors.grey[500]
),
),
)
]
SizedBox(height: 4),
Text(
valueRepresentation,
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold
),
)
]
)
)
)
);
);
}
/// Builds the headers indicator for environmental data cells
Widget _buildEnvironmentalDataCells(String title, String unit, double value) => Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.all(2),
padding: EdgeInsets.symmetric(vertical: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.grey[200],
),
child: Column(
children: [
Text(
title,
style: TextStyle(
fontSize: 20,
color: (value != -1 && value != null) ? Colors.black : Colors.grey[500]
),
),
Text(
unit,
style: TextStyle(
fontSize: 14,
color: (value != -1 && value != null) ? Colors.black : Colors.grey[500]
Widget _buildEnvironmentalDataCells({@required String title, @required String unit, @required double value}) {
String valueRepresentation = (value != -1 && value != null) ? value.toStringAsFixed(2) : '';
if (valueRepresentation.endsWith('.00'))
valueRepresentation = valueRepresentation.split('.')[0];
return Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.all(2),
padding: EdgeInsets.symmetric(vertical: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.grey[200],
),
child: Column(
children: [
Text(
title,
style: TextStyle(
fontSize: 20,
color: (value != -1 && value != null) ? Colors.black : Colors.grey[500]
),
),
),
SizedBox(height: 8),
Text(
(value != -1 && value != null) ? value.toString() : '',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold
Text(
unit,
style: TextStyle(
fontSize: 14,
color: (value != -1 && value != null) ? Colors.black : Colors.grey[500]
),
),
)
]
SizedBox(height: 8),
Text(
valueRepresentation,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold
),
)
]
)
)
)
);
);
}
Widget tile = Container(
margin: EdgeInsets.symmetric(horizontal: 3, vertical: 3),
......@@ -200,9 +214,9 @@ class _DataTileState extends State<DataTile> {
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
_buildEnvironmentalDataCells('Temp.', '(C°)', _temperature),
_buildEnvironmentalDataCells('Pres.', '(hPa)', _pressure),
_buildEnvironmentalDataCells('Rel. Hum.', '(%)', _relativeHumidity),
_buildEnvironmentalDataCells(title: 'Temp.', unit: '(C°)', value: this._temperature),
_buildEnvironmentalDataCells(title: 'Pres.', unit: '(hPa)', value: this._pressure),
_buildEnvironmentalDataCells(title: 'Rel. Hum.', unit: '(%)', value: this._relativeHumidity),
],
),
]
......
......@@ -11,6 +11,7 @@ import 'package:logair_application/ui/routes/preferences.dart';
import 'package:logair_application/ui/components/common/base_widget.dart';
/// [Widget] displaying activity relevant information to the user to provide transparency on the metrics used.
class OverviewWidget extends StatelessWidget {
OverviewWidget({Key key}) : super(key: key);
......
......@@ -14,6 +14,17 @@ double parseDoubleWrapper(String data) {
return result;
}
double castDoubleWrapper(dynamic value) {
if (value.runtimeType == double)
return value;
else if (value.runtimeType == int)
return value.toDouble();
else if (value.runtimeType == String)
return parseDoubleWrapper(value);
else
return null;
}
/// Retrieves the appropriate [IconData] for a given battery [level].
IconData getBatteryLevelIcon({@required int level}) {
IconData icon;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment