Commit 97210f76 authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬
Browse files

Grouping files by usage, added BT button to header, graph WIP

parent 795567f4
{"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-07-03 18:51:09.681273","version":"1.20.0-3.0.pre.126"}
\ 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-07-09 14:40:40.685116","version":"1.19.0-2.0.pre.49"}
\ No newline at end of file
......@@ -11,7 +11,7 @@ class BatteryVisualizerWidget extends StatelessWidget {
Stream<int> getBatteryLevel2() async* {
Random r = new Random();
while (true) {
yield r.nextInt(100);
yield 100; //r.nextInt(100);
await Future.delayed(Duration(seconds: 10));
}
}
......@@ -32,7 +32,7 @@ class BatteryVisualizerWidget extends StatelessWidget {
Widget build(BuildContext context) {
return StreamBuilder<int>(
stream: this.isLeft ? BatteryService().getBatteryLevel() : getBatteryLevel2(),
initialData: null,
initialData: 0,
builder: (context, snapshot) {
int data = snapshot.data;
return Stack(
......
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:logair_application/ui/animation/forward_animation.dart';
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/ui/bluetooth_dialog/dialog.dart';
import 'package:logair_application/utils/enums/bluetooth_connection_status.dart';
/// Button enabling the app to connect to a PM detector device.
class BluetoothButton extends StatefulWidget {
BluetoothButton({Key key}) : super(key: key);
@override
_BluetoothButtonState createState() => _BluetoothButtonState();
}
class _BluetoothButtonState extends State<BluetoothButton> {
_BluetoothButtonState({Key key});
Color _color;
BluetoothConnectionStatus _status;
// Can ignore dart(cancel_subscriptions) because linter error, subscription canceled in dispose.
// ignore: cancel_subscriptions
StreamSubscription<BluetoothConnectionStatus> _connectionStatusListener;
/// This [Function] enables non-dirty transitions, only on value change, reducing overhead.
void connectionStatusStateChanger(BluetoothConnectionStatus newStatus) {
if (mounted && newStatus != _status) {
Color newColor;
switch (newStatus) {
case BluetoothConnectionStatus.BTSTATUS_NOT_STREAMING:
newColor = Colors.grey[350];
break;
case BluetoothConnectionStatus.BTSTATUS_DISCOVERING_SERVICES:
newColor = Colors.blue[100];
break;
case BluetoothConnectionStatus.BTSTATUS_GETTING_CHARACTERISTICS:
newColor = Colors.blue[200];
break;
case BluetoothConnectionStatus.BTSTATUS_SETTING_MTU:
newColor = Colors.blue[300];
break;
case BluetoothConnectionStatus.BTSTATUS_STREAMING:
newColor = Colors.blueAccent;
break;
default:
}
setState(() {
_color = newColor;
_status = newStatus;
});
}
}
@override
void initState() {
super.initState();
this._connectionStatusListener = BTLEHandler().getConnectionStatus().listen(connectionStatusStateChanger);
}
@override
Future<void> dispose() async {
this._connectionStatusListener.cancel();
this._connectionStatusListener = null;
super.dispose();
}
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: StreamBuilder<BluetoothConnectionStatus>(
stream: BTLEHandler().getConnectionStatus(),
initialData: BluetoothConnectionStatus.BTSTATUS_NOT_STREAMING,
builder: (context, snapshot) {
BluetoothConnectionStatus _bluetoothStatus = snapshot.data;
return Ink(
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
width: 2.0,
),
shape: BoxShape.circle,
),
child: Ink(
decoration: BoxDecoration(
border: Border.all(
color: Colors.indigoAccent,
width: 2.0,
),
color: _color,
shape: BoxShape.circle,
),
child: InkWell(
borderRadius: BorderRadius.circular(100.0),
onTap: () {
print("onTap");
if (_bluetoothStatus != BluetoothConnectionStatus.BTSTATUS_STREAMING) {
print("Tap On");
Navigator.push(
context,
PopForwardRoute(
page: BluetoothDialog(),
),
);
return true;
} else {
BTLEHandler().disconnect();
print('Tap off');
return true;
}
},
child: Padding(
padding: EdgeInsets.all(10),
child: Icon(
Icons.bluetooth,
color: Colors.white,
size: 30.0,
),
),
)
)
);
}
),
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'dart:math';
class CardPainter extends CustomPainter {
CardPainter({@required this.isLeft, @required this.battery, @required this.color});
......
import 'package:flutter/material.dart';
import 'package:logair_application/ui/components/battery_visualizer.dart';
import 'package:logair_application/ui/components/bluetooth_button.dart';
import 'package:logair_application/ui/base/battery_visualizer.dart';
import 'package:logair_application/ui/base/bluetooth_button.dart';
class HeaderWidget extends StatelessWidget {
HeaderWidget({Key key}) : super(key: key);
......
......@@ -3,9 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_blue/flutter_blue.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 'package:logair_application/ui/bluetooth_dialog/bluetooth_adapter_off.dart';
import 'package:logair_application/ui/bluetooth_dialog/adapter_unavailable.dart';
import 'package:logair_application/ui/bluetooth_dialog/selection_dialog.dart';
class BluetoothDialog extends StatefulWidget {
BluetoothDialog({Key key}) : super(key: key);
......@@ -61,10 +61,12 @@ class _BluetoothDialogState extends State<BluetoothDialog> {
),
Expanded(
flex: 1,
child: RaisedButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text("Back"),
)
child: Center(
child: RaisedButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text("Back"),
),
),
),
],
),
......
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/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 'package:logair_application/logic/handlers/preference_handler.dart';
class Device {
final String name;
final String address;
Device({this.name, this.address});
Device.fromJson(Map<String, dynamic> data) : name = data["name"], address = data["address"];
@override
String toString() => 'DEVICE $name@$address';
}
class BluetoothSelectionDialog extends StatefulWidget {
BluetoothSelectionDialog({Key key}) : super(key: key);
@override
_BluetoothSelectionDialogState createState() => _BluetoothSelectionDialogState();
}
class _BluetoothSelectionDialogState extends State<BluetoothSelectionDialog> {
_BluetoothSelectionDialogState();
List<Device> _frequentDevices;
@override
Widget build(BuildContext context) {
if (_frequentDevices != null)
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(
height: sizingInfo.screenSize.height * 0.9,
child: RefreshIndicator(
onRefresh: () => BTLEHandler().fblueInstance.startScan(),
child: SingleChildScrollView(
padding: EdgeInsets.all(0),
child: Container(
child: Column(
children: <Widget>[
ListTile(
leading: IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.arrow_back),
onPressed: () async {
if (await BTLEHandler().fblueInstance.isScanning.first)
BTLEHandler().fblueInstance.stopScan();
Navigator.of(context).pop(false);
},
),
title: Text(
AppLocalization.of(context).bluetoothScanMessage,
style: Theme.of(context).textTheme.headline6,
textAlign: TextAlign.center,
),
dense: true,
trailing: IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.refresh),
onPressed: () => BTLEHandler().fblueInstance.startScan(timeout: Duration(seconds: 10)),
),
),
Divider(),
Text(
AppLocalization.of(context).bluetoothFrequent
),
StreamBuilder<List<ScanResult>>(
stream: BTLEHandler().fblueInstance.scanResults.transform(
new StreamTransformer.fromHandlers(
handleData: (List<ScanResult> list, EventSink<List<ScanResult>> sink) =>
sink.add(list.where((result) => _frequentDevices != null ? _frequentDevices.map((Device d) => d.address).contains(result.device.id.toString()) : false).toList())
)
),
initialData: [],
builder: (context, snapshot) => Column(
children: (snapshot.data.length > 0) ?
snapshot.data.map(
(result) => BTLEScanTile(
result: result,
onTap: () {
BTLEHandler().setDevice(result.device);
BTLEHandler().connect();
Navigator.of(context).pop(true);
}
),
).toList() : <Widget>[
Text(
AppLocalization.of(context).none,
style: Theme.of(context).textTheme.caption,
)
],
)
),
Divider(),
Text(
AppLocalization.of(context).bluetoothAvailable
),
StreamBuilder<List<ScanResult>>(
stream: BTLEHandler().fblueInstance.scanResults.transform(
new StreamTransformer.fromHandlers(
handleData: (List<ScanResult> list, EventSink<List<ScanResult>> sink) =>
sink.add(
list.where(
(result) =>
((_frequentDevices != null) ?
!_frequentDevices.map((Device d) => d.address).contains(result.device.id.toString())
: true) && result.device.name.length > 0).toList())
)
),
initialData: [],
builder: (context, snapshot) => Column(
children: (snapshot.data.length > 0) ?
snapshot.data.map(
(result) => BTLEScanTile(
result: result,
onTap: () {
BTLEHandler().fblueInstance.stopScan();
BTLEHandler().setDevice(result.device);
BTLEHandler().connect();
Navigator.of(context).pop(true);
}
),
).toList() : <Widget>[
Text(
"None",
style: Theme.of(context).textTheme.caption,
)
],
)
),
],
),
),
),
),
),
);
}
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/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 'package:logair_application/logic/handlers/preference_handler.dart';
class Device {
final String name;
final String address;
Device({this.name, this.address});
Device.fromJson(Map<String, dynamic> data) : name = data["name"], address = data["address"];
@override
String toString() => 'DEVICE $name@$address';
}
class BluetoothSelectionDialog extends StatefulWidget {
BluetoothSelectionDialog({Key key}) : super(key: key);
@override
_BluetoothSelectionDialogState createState() => _BluetoothSelectionDialogState();
}
class _BluetoothSelectionDialogState extends State<BluetoothSelectionDialog> {
_BluetoothSelectionDialogState();
List<Device> _frequentDevices;
@override
Widget build(BuildContext context) {
if (_frequentDevices != null)
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(
height: sizingInfo.screenSize.height * 0.9,
child: RefreshIndicator(
onRefresh: () => BTLEHandler().fblueInstance.startScan(),
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: EdgeInsets.all(0),
child: Container(
child: Column(
children: <Widget>[
ListTile(
leading: IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.arrow_back),
onPressed: () async {
if (await BTLEHandler().fblueInstance.isScanning.first)
BTLEHandler().fblueInstance.stopScan();
Navigator.of(context).pop(false);
},
),
title: Text(
AppLocalization.of(context).bluetoothScanMessage,
style: Theme.of(context).textTheme.headline6,
textAlign: TextAlign.center,
),
dense: true,
trailing: IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.refresh),
onPressed: () async {
if (await BTLEHandler().fblueInstance.isScanning.first)
BTLEHandler().fblueInstance.stopScan();
try {
BTLEHandler().fblueInstance.startScan(timeout: Duration(seconds: 10));
} catch (e) {
}
},
),
),
Divider(),
Text(
AppLocalization.of(context).bluetoothFrequent
),
StreamBuilder<List<ScanResult>>(
stream: BTLEHandler().fblueInstance.scanResults.transform(
new StreamTransformer.fromHandlers(
handleData: (List<ScanResult> list, EventSink<List<ScanResult>> sink) =>
sink.add(list.where((result) => _frequentDevices != null ? _frequentDevices.map((Device d) => d.address).contains(result.device.id.toString()) : false).toList())
)
),
initialData: [],
builder: (context, snapshot) => Column(
children: (snapshot.data.length > 0) ?
snapshot.data.map(
(result) => BTLEScanTile(
result: result,
onTap: () {
BTLEHandler().setDevice(result.device);
BTLEHandler().connect();
Navigator.of(context).pop(true);
}
),
).toList() : <Widget>[
Text(
AppLocalization.of(context).none,
style: Theme.of(context).textTheme.caption,
)
],
)
),
Divider(),
Text(
AppLocalization.of(context).bluetoothAvailable
),
StreamBuilder<List<ScanResult>>(
stream: BTLEHandler().fblueInstance.scanResults.transform(
new StreamTransformer.fromHandlers(
handleData: (List<ScanResult> list, EventSink<List<ScanResult>> sink) =>
sink.add(
list.where(
(result) =>
((_frequentDevices != null) ?
!_frequentDevices.map((Device d) => d.address).contains(result.device.id.toString())
: true) && result.device.name.length > 0).toList())
)
),
initialData: [],
builder: (context, snapshot) => Column(
children: (snapshot.data.length > 0) ?
snapshot.data.map(
(result) => BTLEScanTile(
result: result,
onTap: () {
BTLEHandler().fblueInstance.stopScan();
BTLEHandler().setDevice(result.device);
BTLEHandler().connect();
Navigator.of(context).pop(true);
}
),
).toList() : <Widget>[
Text(
"None",
style: Theme.of(context).textTheme.caption,
)
],
)
),
],
),
),
),
),
),
);
}
}
\ No newline at end of file
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:logair_application/ui/animation/forward_animation.dart';
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/ui/dialog/bluetooth_dialog.dart';
class BluetoothButton extends StatefulWidget {
BluetoothButton({Key key}) : super(key: key);
@override
_BluetoothButtonState createState() => _BluetoothButtonState();
}
class _BluetoothButtonState extends State<BluetoothButton> {
_BluetoothButtonState({Key key});
@override
Widget build(BuildContext context) {
return Material(
child: StreamBuilder<bool>(
stream: BTLEHandler().isDeviceConnected(),
initialData: false,
builder: (context, snapshot) {
bool _bluetoothConnected = snapshot.data;
return Ink(
decoration: BoxDecoration(
border: Border.all(
color: Colors.indigoAccent,
width: 2.0,
),
color: _bluetoothConnected ? Colors.blue[200] : Colors.white,
shape: BoxShape.circle,
),
child: InkWell(
borderRadius: BorderRadius.circular(100.0),
onTap: () {
print("onTap");
if (!_bluetoothConnected) {
print("Tap On");
Navigator.push(
context,
PopForwardRoute(
page: BluetoothDialog(),
),
);
return true;
} else {
BTLEHandler().disconnect();
print('Tap off');
return true;
}
},
child: Padding(
padding: EdgeInsets.all(10),
child: Icon(
Icons.bluetooth,
color: _bluetoothConnected ? Colors.grey : Colors.red,
size: 30.0,
),
),
)
);
}
),
);