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

Proximal points and ui

parent 802a2f34
......@@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:logair_application/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/ui/components/bluetooth_adapter_off.dart';
import 'package:logair_application/ui/components/bluetooth_adapter_unavailable.dart';
import 'package:logair_application/ui/dialog/bluetooth_selection_dialog.dart';
......
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:logair_application/localization/localization.dart';
import 'package:logair_application/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/ui/base_widget.dart';
import 'package:logair_application/ui/components/bt_scan_tile.dart';
import 'dart:convert';
import 'package:logair_application/handlers/preference_handler.dart';
import 'package:logair_application/logic/handlers/preference_handler.dart';
class Device {
final String name;
......@@ -38,9 +38,10 @@ class _BluetoothSelectionDialogState extends State<BluetoothSelectionDialog> {
@override
Widget build(BuildContext context) {
if (_frequentDevices != null)
PreferencesHandler().getPreferences().then((preferences) =>
setState(() => this._frequentDevices = List.from(json.decode((preferences.getString('json') ?? '[ ]')).map((device) => Device(name: device["name"], address: device["address"]))))
);
setState(
() => this._frequentDevices = List.from(
json.decode((PreferencesHandler().getPreferencesString('BT.FREQUENT') ?? '[ ]'))
.map((device) => Device(name: device["name"], address: device["address"]))));
return BaseWidget(
builder: (context, sizingInfo) => Container(
......
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:logair_application/controllers/map_display_controller.dart';
import 'package:logair_application/ui/animation/forward_animation.dart';
import 'package:logair_application/logic/controllers/map_display_controller.dart';
import 'package:logair_application/ui/routes/map_settings.dart';
import 'package:logair_application/ui/base_widget.dart';
import 'package:logair_application/ui/carousel_card.dart';
......@@ -22,28 +25,122 @@ class MapContainer extends BaseWidget {
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subdomains: ['a', 'b', 'c']
),
PolylineLayerOptions(
polylines: MapDisplayController().polylines()
),
CircleLayerOptions(
circles: MapDisplayController().pmMarkers()
),
MarkerLayerOptions(
markers: [
MapDisplayController().marker()
MapDisplayController().marker(),
],
),
PolylineLayerOptions(
polylines: MapDisplayController().polylines()
)
],
);
}
@override
Widget build(BuildContext context) {
TextEditingController _fromController = TextEditingController();
TextEditingController _toController = TextEditingController();
Expanded _buildMapLayerSelection(String text, Function onPressed) =>
Expanded(
child: RaisedButton(
onPressed: onPressed,
child: Text(text)
),
);
return CarouselCard(
child: Center(
child: Column(
children: [
BaseWidget(
builder: (ctx, sizingInformation) => Container(
height: sizingInformation.screenSize.height * 0.2,
child: Text('Map'),
height: sizingInformation.unnotchedHeight() * 33/40 * 0.16,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Stack(
alignment: Alignment.center,
children: [
Row(
children: [
Expanded(
flex: 4,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
TextField(
enabled: false,
controller: _fromController,
decoration: InputDecoration(
labelText: 'From...',
contentPadding: EdgeInsets.zero,
),
),
TextField(
enabled: false,
controller: _toController,
decoration: InputDecoration(
labelText: 'To...',
contentPadding: EdgeInsets.zero,
),
),
],
),
),
),
Expanded(
flex: 1,
child: Container(
height: 40,
width: 40,
child: IconButton(
constraints: BoxConstraints.expand(height: 40, width: 40),
icon: Icon(
Icons.navigation,
color: Colors.blue,
),
onPressed: () => {}
)
)
),
]
),
IgnorePointer(
child: Transform(
transform: Matrix4.identity()..rotateZ(-15 * 3.1415927 / 180),
child: Text(
'WIP',
style: TextStyle(
color: Colors.red[300],
fontFamily: 'Roboto',
fontSize: 40,
)
),
)
),
]
)
]
),
),
),
BaseWidget(
builder: (ctx, sizingInformation) => Container(
height: sizingInformation.unnotchedHeight() * 33/40 * 0.05,
child: Row(
children: [
_buildMapLayerSelection('PM 1', () => MapDisplayController().setPMKeyIndex(0)),
_buildMapLayerSelection('PM 2.5', () => MapDisplayController().setPMKeyIndex(1)),
_buildMapLayerSelection('PM 4', () => MapDisplayController().setPMKeyIndex(2)),
_buildMapLayerSelection('PM 10', () => MapDisplayController().setPMKeyIndex(3)),
],
),
)
),
Stack(
......@@ -51,7 +148,7 @@ class MapContainer extends BaseWidget {
children: [
BaseWidget(
builder: (ctx, sizingInformation) => Container(
height: sizingInformation.screenSize.height * 0.65,
height: sizingInformation.unnotchedHeight() * 33/40 * 0.75,
child: Listener(
behavior: HitTestBehavior.deferToChild,
child: _buildMap()
......@@ -72,6 +169,7 @@ class MapContainer extends BaseWidget {
width: 40,
height: 40,
child: FloatingActionButton(
heroTag: "buttonMapZoomIn",
onPressed: () => MapDisplayController().setControllerZoom(true),
backgroundColor: Colors.grey[400],
child: Icon(
......@@ -84,6 +182,7 @@ class MapContainer extends BaseWidget {
width: 40,
height: 40,
child: FloatingActionButton(
heroTag: "buttonMapZoomOut",
onPressed: () => MapDisplayController().setControllerZoom(false),
backgroundColor: Colors.grey[400],
child: Icon(
......@@ -94,6 +193,19 @@ class MapContainer extends BaseWidget {
],
),
),
Container(
padding: EdgeInsets.all(3),
width: 50,
height: 50,
child: FloatingActionButton(
heroTag: "buttonMapSettings",
onPressed: () => Navigator.push(context, PopForwardRoute(page: MapSettingsView())),
backgroundColor: Colors.grey[400],
child: Icon(
Icons.settings
)
)
),
StreamBuilder(
stream: MapDisplayController().isManualMotionUsed(),
initialData: false,
......@@ -105,6 +217,7 @@ class MapContainer extends BaseWidget {
child: Container(
padding: EdgeInsets.all(5),
child: FloatingActionButton(
heroTag: "buttonMap",
onPressed: () => MapDisplayController().setControllerAutomatic(),
child: Icon(
Icons.adjust
......@@ -119,7 +232,6 @@ class MapContainer extends BaseWidget {
],
)
]
)
),
);
......
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:logair_application/animation/slide_animation.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';
class HomeView extends StatelessWidget {
HomeView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
Widget base = BaseWidget(
builder: (context, sizingInfo) =>
Scaffold(
body: Center(
child: Column(
children: <Widget>[
Expanded(
flex: 1,
child: Listener(
behavior: HitTestBehavior.opaque,
onPointerDown: (_) => null,
child: GestureDetector(
onLongPress: () {
Navigator.push(
context,
SlideUpRoute(
page: StatsView(),
),
);
},
child: Row(
children: [
Expanded(
flex: 1,
child: Container(color: Colors.blue.shade100, alignment: Alignment.center, child: Text("BATTERY INDIC 1"),),
),
Expanded(
flex: 1,
child: Container(color: Colors.blue.shade200, alignment: Alignment.center, child: Text("BATTERY INDIC 2"),), // TODO STATEFUL INDIC.
),
],
),
),
),
),
// Carousel
Expanded(
flex: 9,
child: BaseWidget(
builder: (context, sizingInfo) => CarouselSlider(
height: sizingInfo.unnotchedHeight(),
autoPlay: false,
enlargeCenterPage: false,
viewportFraction: 1.0,
initialPage: 1,
items: [
MapContainer(),
DataWidget(),
SocialWidget()
],
),
)
),
],
),
),
),
);
return SafeArea(
child: base
);
}
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:logair_application/ui/animation/slide_animation.dart';
import 'package:logair_application/logic/controllers/home_controller.dart';
import 'package:logair_application/ui/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);
@override
Widget build(BuildContext context) {
Widget base = BaseWidget(
builder: (context, sizingInfo) =>
Scaffold(
body: Center(
child: Column(
children: <Widget>[
Expanded(
flex: 4,
child: Listener(
behavior: HitTestBehavior.opaque,
onPointerDown: (_) => null,
child: GestureDetector(
onLongPress: () {
Navigator.push(
context,
SlideUpRoute(
page: StatsView(),
),
);
},
child: Row(
children: [
Expanded(
flex: 1,
child: LocalBatteryVisualizerWidget()
),
Expanded(
flex: 1,
child: Container(color: Colors.blue.shade200, alignment: Alignment.center, child: Text("BATTERY INDIC 2"),), // TODO STATEFUL INDIC.
),
],
),
),
),
),
// Carousel
Expanded(
flex: 33,
child: BaseWidget(
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)),
],
)
)
],
),
),
),
);
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(
appBar: AppBar(
title: Text('Map Settings'),
),
body: Center(
child: Column(
children: <Widget>[
Expanded(
flex: 1,
child: BaseWidget(
builder: (context, sizingInfo) => Container(
width: double.infinity,
height: double.infinity,
child: MapSettingsForm()
),
),
),
],
),
),
),
),
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:logair_application/enums/bluetooth_connection_status.dart';
import 'package:logair_application/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/handlers/data_handler.dart';
import 'package:logair_application/services/battery_service.dart';
import 'package:logair_application/ui/base_widget.dart';
class StatsView extends StatelessWidget {
StatsView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BaseWidget(
builder: (context, sizingInfo) => SafeArea(
child: Scaffold(
body: Center(
child: Column(
children: <Widget>[
// Carousel
Expanded(
flex: 9,
child: BaseWidget(
builder: (context, sizingInfo) => Container(
width: double.infinity,
height: double.infinity,
child: Column(
children: [
Text('Test'),
Spacer( flex: 1, ),
RaisedButton(
onPressed: () => {
BatteryService().batteryLevel.then((value) => print('Battery is at $value%'))
},
child: Text(
'Test',
style: TextStyle(fontSize: 20)
),
),
Spacer( flex: 1, ),
Text("Data", style: TextStyle(fontFamily: "Consolas", fontSize: 22)),
Spacer( flex: 1, ),
RaisedButton(
onPressed: () => BTLEHandler().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'),
),
Spacer( flex: 1, ),
StreamBuilder<BluetoothConnectionStatus>(
stream: BTLEHandler().getConnectionStatus(),
builder: (context, snapshot) {
BluetoothConnectionStatus data = snapshot.data;
return Text(data.toString());
},
),
],
)
),
),
),
Expanded(
flex: 1,
child: Listener(
behavior: HitTestBehavior.opaque,
onPointerDown: (_) => null,
child: GestureDetector(
onLongPress: () {
Navigator.of(context).pop();
},
child: Row(
children: [
Expanded(
flex: 1,
child: Container(color: Colors.blue.shade100, alignment: Alignment.center, child: Text("BATTERY INDIC 1"),),
),
Expanded(
flex: 1,
child: Container(color: Colors.blue.shade200, alignment: Alignment.center, child: Text("BATTERY INDIC 2"),), // TODO STATEFUL INDIC.
),
],
),
),
),
),
],
),
),
),
),
);
}
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:logair_application/ui/animation/forward_animation.dart';
import 'package:logair_application/utils/enums/bluetooth_connection_status.dart';
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/logic/handlers/bluetooth_wake_handler.dart';
import 'package:logair_application/logic/handlers/data_handler.dart';
import 'package:logair_application/logic/handlers/network_handler.dart';
import 'package:logair_application/ui/routes/map_settings.dart';
import 'package:logair_application/services/battery_service.dart';
import 'package:logair_application/ui/base_widget.dart';
import 'package:logair_application/ui/components/battery_visualizer.dart';
class StatsView extends StatelessWidget {
StatsView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BaseWidget(
builder: (context, sizingInfo) => SafeArea(
child: Scaffold(
body: Center(
child: Column(
children: <Widget>[
// Carousel
Expanded(
flex: 9,
child: BaseWidget(
builder: (context, sizingInfo) => Container(
width: double.infinity,
height: double.infinity,
child: Column(
children: [
Text('Test'),
Spacer( flex: 1, ),
RaisedButton(
onPressed: () => {
BatteryService().getBatteryLevel().first.then((value) => print('Battery is at $value%'))
},
child: Text(
'Print Battery Level',
style: TextStyle(fontSize: 20)
),
),
Spacer( flex: 1, ),