Andesfit WeightScale InProgress
parent
4893a1f3af
commit
a494f454cb
@ -0,0 +1,175 @@
|
|||||||
|
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 AndesFitBloodPressureConnectScreen extends StatefulWidget {
|
||||||
|
final BluetoothDevice deviceModel;
|
||||||
|
final bool isEcgAvailable;
|
||||||
|
|
||||||
|
const AndesFitBloodPressureConnectScreen({this.deviceModel, this.isEcgAvailable = false});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AndesFitBloodPressureConnectScreen> createState() => _AndesFitBloodPressureConnectScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AndesFitBloodPressureConnectScreenState extends State<AndesFitBloodPressureConnectScreen> {
|
||||||
|
MyTrackersViewModel myTrackersVm;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
myTrackersVm = context.read<MyTrackersViewModel>();
|
||||||
|
myTrackersVm.connectAndesfitBloodPressureDevice(widget.deviceModel);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
myTrackersVm.andesfitBpCurrentStatus = null;
|
||||||
|
myTrackersVm.andesfitBpRtMeasuringModel = null;
|
||||||
|
myTrackersVm.andesfitBpRtResultModel = null;
|
||||||
|
myTrackersVm.selectedAndesFitScanResult = null;
|
||||||
|
myTrackersVm.isAndesfitDeviceConnected = null;
|
||||||
|
myTrackersVm.disConnectAndesfitDevice(widget.deviceModel);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildBloodPressureUI(MyTrackersViewModel myTrackersViewModel) {
|
||||||
|
return Expanded(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
if (myTrackersViewModel.andesfitBpCurrentStatus == kRealTimeDataBPMeasuring) ...[
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
mHeight(24.0),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtMeasuringModel.pressure.toString(), style: TextStyle(fontSize: 100, fontWeight: FontWeight.bold)),
|
||||||
|
Text("Pressure", style: TextStyle(fontSize: 20)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
mHeight(24.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
] else if (myTrackersViewModel.andesfitBpCurrentStatus == kRealTimeDataBPResult) ...[
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
mHeight(24.0),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text("Sys", style: TextStyle(fontSize: 20)),
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtResultModel.sys.toString(), style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
|
||||||
|
Text("mmHg", style: TextStyle(fontSize: 10)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text("Dia", style: TextStyle(fontSize: 20)),
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtResultModel.dia.toString(), style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
|
||||||
|
Text("mmHg", style: TextStyle(fontSize: 10)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text("♥︎", style: TextStyle(fontSize: 20)),
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtResultModel.pr.toString(), style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
|
||||||
|
Text("/min", style: TextStyle(fontSize: 10)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
mHeight(30.0),
|
||||||
|
// buildStatusForBP(myTrackersViewModel.bpRtResultModel.result),
|
||||||
|
// mHeight(24.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
] else ...[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(24.0),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
"Some animation with the instruction",
|
||||||
|
style: TextStyle(fontSize: 9.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildStatusForBP(int result) {
|
||||||
|
String resultStatus = "";
|
||||||
|
|
||||||
|
if (result == 0) {
|
||||||
|
resultStatus = "Normal";
|
||||||
|
} else if (result == 1) {
|
||||||
|
resultStatus = "Unable to analyze(cuff is too loose, inflation is slow, slow air leakage, large air volume)";
|
||||||
|
} else if (result == 2) {
|
||||||
|
resultStatus = "Waveform disorder(arm movement or other interference detected during pumping)";
|
||||||
|
} else if (result == 3) {
|
||||||
|
resultStatus = "Weak signal, unable to detect pulse wave(clothes with interference sleeves)";
|
||||||
|
} else {
|
||||||
|
resultStatus = "Equipment error(valve blocking, over-range blood pressure measurement, serious cuff leakage, software system abnormality, hardware system error, and other abnormalities)";
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Center(child: Text("$resultStatus", style: TextStyle(fontSize: 20))),
|
||||||
|
if (result != 0) ...[
|
||||||
|
mHeight(24.0),
|
||||||
|
Center(child: Text("Press START/STOP Button on the device to restart.", style: TextStyle(fontSize: 15))),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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: [
|
||||||
|
buildBloodPressureUI(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,148 @@
|
|||||||
|
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 AndesFitWeightScaleConnectScreen extends StatefulWidget {
|
||||||
|
final BluetoothDevice deviceModel;
|
||||||
|
|
||||||
|
const AndesFitWeightScaleConnectScreen({this.deviceModel});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AndesFitWeightScaleConnectScreen> createState() => _AndesFitWeightScaleConnectScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AndesFitWeightScaleConnectScreenState extends State<AndesFitWeightScaleConnectScreen> {
|
||||||
|
MyTrackersViewModel myTrackersVm;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
myTrackersVm = context.read<MyTrackersViewModel>();
|
||||||
|
myTrackersVm.connectAndesfitWeightDevice(widget.deviceModel);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
myTrackersVm.andesfitWeightScaleData = null;
|
||||||
|
myTrackersVm.selectedAndesFitScanResult = null;
|
||||||
|
myTrackersVm.isAndesfitDeviceConnected = null;
|
||||||
|
myTrackersVm.disConnectAndesfitDevice(widget.deviceModel);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildWeightScaleUI(MyTrackersViewModel myTrackersViewModel) {
|
||||||
|
return Expanded(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
if (myTrackersViewModel.andesfitBpCurrentStatus == kRealTimeDataBPMeasuring) ...[
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
mHeight(24.0),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtMeasuringModel.pressure.toString(), style: TextStyle(fontSize: 100, fontWeight: FontWeight.bold)),
|
||||||
|
Text("Pressure", style: TextStyle(fontSize: 20)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
mHeight(24.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
] else if (myTrackersViewModel.andesfitBpCurrentStatus == kRealTimeDataBPResult) ...[
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
mHeight(24.0),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text("Sys", style: TextStyle(fontSize: 20)),
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtResultModel.sys.toString(), style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
|
||||||
|
Text("mmHg", style: TextStyle(fontSize: 10)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text("Dia", style: TextStyle(fontSize: 20)),
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtResultModel.dia.toString(), style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
|
||||||
|
Text("mmHg", style: TextStyle(fontSize: 10)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text("♥︎", style: TextStyle(fontSize: 20)),
|
||||||
|
Text(myTrackersViewModel.andesfitBpRtResultModel.pr.toString(), style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold)),
|
||||||
|
Text("/min", style: TextStyle(fontSize: 10)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
mHeight(30.0),
|
||||||
|
// buildStatusForBP(myTrackersViewModel.bpRtResultModel.result),
|
||||||
|
// mHeight(24.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
] 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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue