Added till andesfit blood sugar device
parent
a494f454cb
commit
0967e45752
@ -0,0 +1,131 @@
|
||||
import 'package:diplomaticquarterapp/extensions/string_extensions.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/my_trackers_view_model/my_trackers_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class AndesFitBloodSugarConnectScreen extends StatefulWidget {
|
||||
final BluetoothDevice deviceModel;
|
||||
|
||||
const AndesFitBloodSugarConnectScreen({this.deviceModel});
|
||||
|
||||
@override
|
||||
State<AndesFitBloodSugarConnectScreen> createState() => _AndesFitBloodSugarConnectScreenState();
|
||||
}
|
||||
|
||||
class _AndesFitBloodSugarConnectScreenState extends State<AndesFitBloodSugarConnectScreen> {
|
||||
MyTrackersViewModel myTrackersVm;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
myTrackersVm = context.read<MyTrackersViewModel>();
|
||||
myTrackersVm.connectAndesfitBloodSugarDevice(widget.deviceModel);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
myTrackersVm.bloodSugarValuesStream.cancel();
|
||||
myTrackersVm.currentBloodGlucose = null;
|
||||
myTrackersVm.selectedAndesFitScanResult = null;
|
||||
myTrackersVm.isAndesfitDeviceConnected = null;
|
||||
myTrackersVm.disConnectAndesfitDevice(widget.deviceModel);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget buildWeightScaleUI(MyTrackersViewModel myTrackersViewModel) {
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
if (myTrackersViewModel.currentBloodGlucose == null && myTrackersViewModel.isAndesfitDeviceConnected) ...[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
mHeight(24.0),
|
||||
Column(
|
||||
children: [
|
||||
Text("Please Wait", style: TextStyle(fontSize: 20)),
|
||||
],
|
||||
),
|
||||
mHeight(24.0),
|
||||
],
|
||||
),
|
||||
] else if (myTrackersViewModel.currentBloodGlucose != null) ...[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
mHeight(24.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text("Blood Sugar", style: TextStyle(fontSize: 20)),
|
||||
Text(myTrackersViewModel.currentBloodGlucose.toString(), style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)),
|
||||
Text("mg/dL", style: TextStyle(fontSize: 15)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
] else ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Some animation with the instruction",
|
||||
style: TextStyle(fontSize: 9.0),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppScaffold(
|
||||
appBarTitle: "${widget.deviceModel.localName}",
|
||||
showNewAppBar: true,
|
||||
isShowDecPage: false,
|
||||
showNewAppBarTitle: true,
|
||||
backgroundColor: Color(0xffF8F8F8),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Consumer(
|
||||
builder: (BuildContext context, MyTrackersViewModel myTrackersViewModel, Widget child) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
buildWeightScaleUI(myTrackersViewModel),
|
||||
if (myTrackersViewModel.isAndesfitDeviceConnected != null && myTrackersViewModel.isAndesfitDeviceConnected) ...[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultButton(
|
||||
"Disconnect with ${widget.deviceModel.localName}",
|
||||
() async {
|
||||
myTrackersVm.disConnectAndesfitDevice(widget.deviceModel);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,138 @@
|
||||
import 'package:diplomaticquarterapp/extensions/string_extensions.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/my_trackers_view_model/my_trackers_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class AndesFitTemperatureConnectScreen extends StatefulWidget {
|
||||
final BluetoothDevice deviceModel;
|
||||
|
||||
const AndesFitTemperatureConnectScreen({this.deviceModel});
|
||||
|
||||
@override
|
||||
State<AndesFitTemperatureConnectScreen> createState() => _AndesFitTemperatureConnectScreenState();
|
||||
}
|
||||
|
||||
class _AndesFitTemperatureConnectScreenState extends State<AndesFitTemperatureConnectScreen> {
|
||||
MyTrackersViewModel myTrackersVm;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
myTrackersVm = context.read<MyTrackersViewModel>();
|
||||
myTrackersVm.connectAndesfitTemperatureDevice(widget.deviceModel);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
myTrackersVm.currentTempInCelsius = null;
|
||||
myTrackersVm.selectedAndesFitScanResult = null;
|
||||
myTrackersVm.isAndesfitDeviceConnected = null;
|
||||
myTrackersVm.disConnectAndesfitDevice(widget.deviceModel);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget buildTemperatureScaleUI(MyTrackersViewModel myTrackersViewModel) {
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
if (myTrackersViewModel.currentTempInCelsius == null && (myTrackersViewModel.isAndesfitDeviceConnected != null && myTrackersViewModel.isAndesfitDeviceConnected)) ...[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
mHeight(24.0),
|
||||
Column(
|
||||
children: [
|
||||
// Text("Please stay Still.", style: TextStyle(fontSize: 100, fontWeight: FontWeight.bold)),
|
||||
Text("Please Wait", style: TextStyle(fontSize: 20)),
|
||||
],
|
||||
),
|
||||
mHeight(24.0),
|
||||
],
|
||||
),
|
||||
] else if (myTrackersViewModel.currentTempInCelsius != null) ...[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
mHeight(24.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
// Text("Temperature", style: TextStyle(fontSize: 20)),
|
||||
Text((myTrackersViewModel.currentTempInCelsius.split(" / ")[0]).toString(), style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)),
|
||||
Text("Celsius", style: TextStyle(fontSize: 15)),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
// Text("Temperature", style: TextStyle(fontSize: 20)),
|
||||
Text((myTrackersViewModel.currentTempInCelsius.split(" / ")[1]).toString(), style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)),
|
||||
Text("Fahrenheit", style: TextStyle(fontSize: 15)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
] else ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Some animation with the instruction",
|
||||
style: TextStyle(fontSize: 9.0),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppScaffold(
|
||||
appBarTitle: "${widget.deviceModel.localName}",
|
||||
showNewAppBar: true,
|
||||
isShowDecPage: false,
|
||||
showNewAppBarTitle: true,
|
||||
backgroundColor: Color(0xffF8F8F8),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Consumer(
|
||||
builder: (BuildContext context, MyTrackersViewModel myTrackersViewModel, Widget child) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
buildTemperatureScaleUI(myTrackersViewModel),
|
||||
if (myTrackersViewModel.isAndesfitDeviceConnected != null && myTrackersViewModel.isAndesfitDeviceConnected) ...[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultButton(
|
||||
"Disconnect with ${widget.deviceModel.localName}",
|
||||
() async {
|
||||
myTrackersVm.disConnectAndesfitDevice(widget.deviceModel);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue