Commit ee3283eb authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬

Added Settings, UI and tweaks, basics for proximal points (need to test pull)

parent e102d8f4
{"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.4.3\\\\","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.4.3\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"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":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-05-12 01:26:21.344576","version":"1.18.0-10.0.pre"}
\ No newline at end of file
{"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-05-14 20:55:39.262677","version":"1.19.0-2.0.pre.49"}
\ No newline at end of file
......@@ -5,9 +5,10 @@
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="logair_application"
android:label="logair.io"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
......
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<item android:drawable="@android:color/splash_bg" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher_foreground" />
</item>
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
......
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_bg">#f3f3f3</color>
</resources>
\ No newline at end of file
......@@ -13,6 +13,6 @@
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowBackground">@android:color/splash_bg</item>
</style>
</resources>
<svg viewBox="0 0 316 316" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h316v316H0V0zm58 202v20h200v-20H58zm30 40v20h140v-20H88zM98 54v120h120V54H98z" fill="#FBFBFB" fill-rule="evenodd"/></svg>
\ No newline at end of file
import 'package:flutter/cupertino.dart';
class HomeController {
factory HomeController() => _singleton;
HomeController._internal();
static final HomeController _singleton = new HomeController._internal();
PageController _pageController;
set carouselController(PageController carouselController) => this._pageController = carouselController;
get carouselController => this._pageController;
void gotoPage(int page) => (this._pageController != null) ? this._pageController.jumpToPage(page) : {};
}
\ No newline at end of file
import 'dart:async';
import 'dart:collection';
import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:latlong/latlong.dart';
import 'package:logair_application/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/handlers/data_handler.dart';
import 'package:logair_application/handlers/network_handler.dart';
import 'package:logair_application/logic/data_header.dart';
import 'package:logair_application/logic/data_packet.dart';
import 'package:logair_application/handlers/position_handler.dart';
......@@ -17,20 +23,18 @@ class MapDisplayController {
LatLng _lastPos;
/// The [FlutterMap]'s zoom level, used to keep centering stable.
/// TODO Modify zoom action buttons.
double _zoom;
/// The [FlutterMap]s [MapController], kept unique in order to avoid incessant reloading of resources.
MapController _controller;
/// [List] of [Polyline] representing the evolution of the PM2.5 value.
/// TODO Discuss [Polyline] efficiency vs. 3px [Marker], especially considering navigation.
List<Polyline> _polylines = [];
/// [Marker] representing the user's current [Position].
Marker _marker;
List<CircleMarker> _pmMarkers = [];
HashMap<String, List<CircleMarker>> _pmMarkers = HashMap.from({'PM1': <CircleMarker>[], 'PM2_5': <CircleMarker>[], 'PM4': <CircleMarker>[], 'PM10': <CircleMarker>[]});
/// [List] of [Color]s to be smudged as a gradient and cherry picked based on a value (lerped).
/// @see [_colorizeValue]
......@@ -42,6 +46,23 @@ class MapDisplayController {
/// [Singleton]() instantiation factory.
factory MapDisplayController() => _singleton;
/// @Getter for [_polylines].
List<Polyline> polylines() => this._polylines;
/// @Getter for [_marker].
Marker marker() => this._marker != null ? this._marker : _buildLocationMarker(LatLng(0, 0));
/// Object used to calculate the real-life distance of two [Position]s
final Distance _distance = new Distance();
List<CircleMarker> pmMarkers() => this._pmMarkers[_pmKey[_pmKeyIndex]];
List<String> _pmKey = ["PM1", "PM2_5", "PM4", "PM10"];
int _pmKeyIndex = 1;
void setPMKeyIndex(int value) { print('PM Index $value gives ${_pmKey[value]}'); this._pmKeyIndex = value; }
/// This function is executed on first initialization of the [MapDisplayController]
/// TODO: Throttle to 1 in 5 updates for efficiency ?
......@@ -75,7 +96,7 @@ class MapDisplayController {
/// Move the [Marker] to the current [Position].
this._marker = this._buildLocationMarker(this._currentPos);
if ((this._lastPos != null && this._currentPos != null && this._distance.as(LengthUnit.Meter, this._lastPos, this._currentPos) >= 2)) {
if ((this._lastPos != null && this._currentPos != null)) {// && this._distance.as(LengthUnit.Meter, this._lastPos, this._currentPos) >= 2)) {
if (this._polylines.length == 0) {
this._polylines.add(
Polyline(
......@@ -86,19 +107,27 @@ class MapDisplayController {
} else
this._polylines.last.points.add(this._currentPos);
if (latest != null) {
this._pmMarkers.add(_buildPMMarker(this._currentPos, latest.pm2_5()));
if (latest != null) {
if (latest.pm1() != null) this._pmMarkers['PM1'].add(_buildPMMarker(this._currentPos, latest.pm1()));
if (latest.pm2_5() != null) this._pmMarkers['PM2_5'].add(_buildPMMarker(this._currentPos, latest.pm2_5()));
if (latest.pm4() != null) this._pmMarkers['PM4'].add(_buildPMMarker(this._currentPos, latest.pm4()));
if (latest.pm10() != null) this._pmMarkers['PM10'].add(_buildPMMarker(this._currentPos, latest.pm10()));
}
}
});
// TODO Set user defined duration
// TODO Set user defined radius
new Timer.periodic(Duration(minutes: 1), (Timer t) {
if (this._controller != null && this._controller.bounds != null)
NetworkHandler().getProximityPoints(DataHeader().deviceID, this._controller.bounds);
});
}
/// Internal static [Singleton]() reference.
static final MapDisplayController _singleton = new MapDisplayController._internal();
/// Object used to calculate the real-life distance of two [Position]s
final Distance _distance = new Distance();
/// @Getter for [_currentPos]
LatLng currentPosition() => _currentPos != null ? _currentPos : LatLng(0, 0);
......@@ -134,14 +163,6 @@ class MapDisplayController {
}
}
/// @Getter for [_polylines].
List<Polyline> polylines() => this._polylines;
/// @Getter for [_marker].
Marker marker() => this._marker != null ? this._marker : _buildLocationMarker(LatLng(0, 0));
List<CircleMarker> pmMarkers() => this._pmMarkers;
/// Gets the lerped [Color] value at a for a given PM value.
Color _colorizeValue(double pmValue) {
for (int stop = 0; stop < _stops.length - 1; stop++) {
......@@ -170,11 +191,11 @@ class MapDisplayController {
/// TODO MAKE PM Value be switchable.
CircleMarker _buildPMMarker(LatLng position, double pmValue) {
return CircleMarker(
radius: 6,
radius: 8,
point: position,
color: _colorizeValue(pmValue).withAlpha(0xff),
borderStrokeWidth: 1,
borderColor: Colors.green
borderColor: Colors.blue[300]
);
}
}
\ No newline at end of file
......@@ -74,4 +74,11 @@ class DataHandler {
await Future.delayed(Duration(milliseconds: 500));
}
}
Stream<int> getUnsentPacketsLength() async* {
while (true) {
yield (_sortedData.length);
await Future.delayed(Duration(seconds: 1));
}
}
}
\ No newline at end of file
......@@ -2,7 +2,10 @@ import 'dart:async';
import 'dart:convert';
import 'dart:collection';
import 'package:flutter_map/flutter_map.dart';
import 'package:geolocator/geolocator.dart';
import 'package:http/http.dart' as http;
import 'package:latlong/latlong.dart';
import 'package:logair_application/logic/data_header.dart';
import 'package:logair_application/logic/data_packet.dart';
......@@ -67,6 +70,22 @@ class NetworkHandler {
}
}
void getProximityPoints(String deviceId, LatLngBounds bounds) async {
/// The default endpoint.
String url = 'https://api.logair.unige.ch/v1/service/map/bounds?localId=$deviceId&lat1=${bounds.northEast.latitude}&lng1=${bounds.northEast.longitude}&lat2=${bounds.southWest.latitude}&lng2=${bounds.southWest.longitude}&age=${5000}&limit=${200}&skip=0';
/// Attempt to send the data to the endpoint via HTTP POST request.
http.Response 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.
.catchError((e) => print('COULDN\'T CONNECT'));
if (response != null && response.statusCode == 200) {
}
}
Stream<DateTime> getLastServerConnection() async* {
while (true) {
yield _lastServerTransmission;
......
......@@ -5,15 +5,43 @@ class PreferencesHandler {
SharedPreferences _sharedPreferences;
PreferencesHandler._internal();
PreferencesHandler._internal() {
SharedPreferences.getInstance().then((SharedPreferences prefs) {
this._sharedPreferences = prefs;
/// Initial Setup
if (!prefs.containsKey('BT.USING_ADVANCED')) prefs.setBool('BT.USING_ADVANCED', false);
if (!prefs.containsKey('BT.USING_ADVANCED_DEFAULT')) prefs.setBool('BT.USING_ADVANCED_DEFAULT', false);
if (!prefs.containsKey('BT.FREQUENT')) prefs.setString('BT.FREQUENT', '[ ]');
if (!prefs.containsKey('BT.FREQUENT_DEFAULT')) prefs.setString('BT.FREQUENT_DEFAULT', '[ ]');
if (!prefs.containsKey('BT.SERVICE_UUID')) prefs.setString('BT.SERVICE_UUID', '0000ffe0-0000-1000-8000-00805f9b34fb');
if (!prefs.containsKey('BT.SERVICE_UUID_DEFAULT')) prefs.setString('BT.SERVICE_UUID_DEFAULT', '0000ffe0-0000-1000-8000-00805f9b34fb');
if (!prefs.containsKey('BT.CHARACTERISTIC_UUID')) prefs.setString('BT.CHARACTERISTIC_UUID', '0000ffe1-0000-1000-8000-00805f9b34fb');
if (!prefs.containsKey('BT.CHARACTERISTIC_UUID_DEFAULT')) prefs.setString('BT.CHARACTERISTIC_UUID_DEFAULT', '0000ffe1-0000-1000-8000-00805f9b34fb');
if (!prefs.containsKey('MAP.USING_ADVANCED')) prefs.setBool('MAP.USING_ADVANCED', false);
if (!prefs.containsKey('MAP.USING_ADVANCED_DEFAULT')) prefs.setBool('MAP.USING_ADVANCED_DEFAULT', false);
if (!prefs.containsKey('MAP.PROX.MAX_PER_QUERY')) prefs.setInt('MAP.PROX.MAX_PER_QUERY', 200);
if (!prefs.containsKey('MAP.PROX.MAX_PER_QUERY_DEFAULT')) prefs.setInt('MAP.PROX.MAX_PER_QUERY_DEFAULT', 200);
if (!prefs.containsKey('MAP.PROX.MAX_AGE_SECONDS')) prefs.setInt('MAP.PROX.MAX_AGE_SECONDS', 200);
if (!prefs.containsKey('MAP.PROX.MAX_AGE_SECONDS_DEFAULT')) prefs.setInt('MAP.PROX.MAX_AGE_SECONDS_DEFAULT', 200);
print('Setup Prefs ${prefs.getKeys()}');
});
}
int getPreferencesInt(String key) => this._sharedPreferences.getInt(key);
String getPreferencesString(String key) => this._sharedPreferences.getString(key);
bool getPreferencesBool(String key) => this._sharedPreferences.getBool(key);
void setPreferencesInt(String key, int value) => this._sharedPreferences.setInt(key, value);
void setPreferencesString(String key, String value) => this._sharedPreferences.setString(key, value);
void setPreferencesBool(String key, bool value) => this._sharedPreferences.setBool(key, value);
Future<SharedPreferences> getPreferences() async {
if (_sharedPreferences == null) {
_sharedPreferences = await SharedPreferences.getInstance();
}
return _sharedPreferences;
}
factory PreferencesHandler() => _singleton;
}
\ No newline at end of file
......@@ -23,6 +23,8 @@ class DataHeader {
this._headerSet = true;
}
String get deviceID => (this._headerData != null && this._headerData.length > 0) ? this._headerData[0] : '';
/// @Getter for _headerSet;
bool isHeaderSet() => _headerSet;
......
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:device_preview/device_preview.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:logair_application/controllers/home_controller.dart';
import 'package:logair_application/controllers/map_display_controller.dart';
import 'package:logair_application/handlers/data_handler.dart';
import 'package:logair_application/handlers/network_handler.dart';
......@@ -21,21 +25,24 @@ void main() {
runApp(displayMode ? DevicePreview(child: LogAirApplication()) : LogAirApplication());
}
class LogAirApplication extends StatelessWidget {
void _startHandlers() {
BTLEHandler();
NetworkHandler();
DataHandler();
PreferencesHandler();
PositionHandler();
MapDisplayController();
}
Future<void> _startHandlers() async {
HomeController();
BTLEHandler();
NetworkHandler();
DataHandler();
PreferencesHandler();
PositionHandler();
MapDisplayController();
}
class LogAirApplication extends StatelessWidget {
static const String _title = 'LogAir Connector';
@override
Widget build(BuildContext context) {
this._startHandlers();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
return MaterialApp(
localizationsDelegates: [
const AppLocalizationDelegate(),
......
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:logair_application/animation/slide_animation.dart';
import 'package:logair_application/controllers/home_controller.dart';
import 'package:logair_application/routes/stats.dart';
import 'package:logair_application/ui/base_widget.dart';
import 'package:logair_application/ui/map_widget.dart';
import 'package:logair_application/ui/data_widget.dart';
import 'package:logair_application/ui/social_widget.dart';
import 'package:logair_application/ui/components/battery_visualizer.dart';
class HomeView extends StatelessWidget {
HomeView({Key key}) : super(key: key);
......@@ -20,9 +22,8 @@ class HomeView extends StatelessWidget {
child: Column(
children: <Widget>[
Expanded(
flex: 1,
flex: 4,
child: Listener(
behavior: HitTestBehavior.opaque,
onPointerDown: (_) => null,
child: GestureDetector(
......@@ -38,7 +39,7 @@ class HomeView extends StatelessWidget {
children: [
Expanded(
flex: 1,
child: Container(color: Colors.blue.shade100, alignment: Alignment.center, child: Text("BATTERY INDIC 1"),),
child: LocalBatteryVisualizerWidget()
),
Expanded(
flex: 1,
......@@ -51,22 +52,37 @@ class HomeView extends StatelessWidget {
),
// Carousel
Expanded(
flex: 9,
flex: 33,
child: BaseWidget(
builder: (context, sizingInfo) => CarouselSlider(
height: sizingInfo.unnotchedHeight(),
autoPlay: false,
enlargeCenterPage: false,
viewportFraction: 1.0,
initialPage: 1,
items: [
MapContainer(),
DataWidget(),
SocialWidget()
],
),
builder: (context, sizingInfo) {
CarouselSlider carousel = CarouselSlider(
height: sizingInfo.unnotchedHeight() * 33/40,
autoPlay: false,
enlargeCenterPage: false,
viewportFraction: 1.0,
initialPage: 0,
items: [
DataWidget(),
SocialWidget(),
MapContainer(),
],
);
HomeController().carouselController = carousel.pageController;
return carousel;
}
)
),
Expanded(
flex: 3,
child: Row(
children: [
_buildMenuButton(Icons.map, 'Map', () => HomeController().gotoPage(0)),
_buildMenuButton(Icons.data_usage, 'Data', () => HomeController().gotoPage(1)),
_buildMenuButton(Icons.contacts, 'Social', () => HomeController().gotoPage(2)),
],
)
)
],
),
),
......@@ -75,6 +91,25 @@ class HomeView extends StatelessWidget {
return SafeArea(
child: base
);
);
}
Widget _buildMenuButton(IconData icon, String text, Function onPressed) =>
Expanded(
flex: 1,
child: RaisedButton(
onPressed: onPressed,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Spacer(flex: 1,),
Icon(icon, size: 20,),
Text(text),
Spacer(flex: 1,),
],
),
),
)
);
}
\ No newline at end of file
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:logair_application/ui/base_widget.dart';
import 'package:logair_application/ui/components/map_settings_form.dart';
class MapSettingsView extends StatelessWidget {
MapSettingsView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BaseWidget(
builder: (context, sizingInfo) => SafeArea(
child: Scaffold(