@ -1,15 +1,20 @@
import ' package:diplomaticquarterapp/config/shared_pref_kay.dart ' ;
import ' package:diplomaticquarterapp/pages/landing/landing_page.dart ' ;
import ' package:diplomaticquarterapp/pages/medical/my_trackers/ble_models/ble_devices_model.dart ' ;
import ' package:diplomaticquarterapp/pages/medical/my_trackers/my_trackers_view_model/my_trackers_view_model.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_shared_preferences.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 ' ;
import ' package:flutter_toggle_tab/flutter_toggle_tab.dart ' ;
class BloodPressureConnectScreen extends StatefulWidget {
final BleDeviceModel deviceModel ;
final bool isEcgAvailable ;
const BloodPressureConnectScreen ( { this . deviceModel }) ;
const BloodPressureConnectScreen ( { this . deviceModel , this . isEcgAvailable = false }) ;
@ override
State < BloodPressureConnectScreen > createState ( ) = > _BloodPressureConnectScreenState ( ) ;
@ -27,10 +32,286 @@ class _BloodPressureConnectScreenState extends State<BloodPressureConnectScreen>
@ override
void dispose ( ) {
myTrackersVm . bpCurrentStatus = null ;
myTrackersVm . bpRtMeasuringModel = null ;
myTrackersVm . bpRtResultModel = null ;
myTrackersVm . ecgCurrentStatus = null ;
myTrackersVm . ecgRtMeasuringModelFromBP = null ;
myTrackersVm . ecgRtResultModelFromBP = null ;
myTrackersVm . disConnectDevice ( ) ;
super . dispose ( ) ;
}
Widget buildBloodPressureUI ( MyTrackersViewModel myTrackersViewModel ) {
return Expanded (
child: ListView (
children: [
if ( myTrackersViewModel . bpCurrentStatus = = kRealTimeDataBPMeasuring ) . . . [
Row (
mainAxisAlignment: MainAxisAlignment . center ,
children: [
mHeight ( 24.0 ) ,
Column (
children: [
Text ( myTrackersViewModel . bpRtMeasuringModel . pressure . toString ( ) , style: TextStyle ( fontSize: 100 , fontWeight: FontWeight . bold ) ) ,
Text ( " Pressure " , style: TextStyle ( fontSize: 20 ) ) ,
] ,
) ,
mHeight ( 24.0 ) ,
] ,
) ,
] else if ( myTrackersViewModel . bpCurrentStatus = = kRealTimeDataBPResult ) . . . [
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
mHeight ( 24.0 ) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
Column (
children: [
Text ( " Dia " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . bpRtResultModel . dia . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " mmHg " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
Column (
children: [
Text ( " Sys " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . bpRtResultModel . sys . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " mmHg " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
Column (
children: [
Text ( " ♥︎ " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . bpRtResultModel . 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 buildECGUI ( MyTrackersViewModel myTrackersViewModel ) {
return Expanded (
child: ListView (
children: [
if ( myTrackersViewModel . ecgCurrentStatus = = kRealTimeDataECGMeasuring ) . . . [
mHeight ( 24.0 ) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
Column (
children: [
Text ( " Duration " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . ecgRtMeasuringModelFromBP . curDuration . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " seconds " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
Column (
children: [
Text ( " ♥︎ " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . ecgRtMeasuringModelFromBP . hr . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " /min " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
] ,
) ,
mHeight ( 30.0 ) ,
] else if ( myTrackersViewModel . ecgCurrentStatus = = kRealTimeDataECGResult ) . . . [
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
mHeight ( 24.0 ) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
Column (
children: [
Text ( " Regular " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . ecgRtResultModelFromBP . diagnosis . isRegular ? " YES " : " NO " , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
Column (
children: [
Text ( " ♥︎ " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . ecgRtResultModelFromBP . hr . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " /min " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
/ / Column (
/ / children: [
/ / Text ( " Heart Pause " , style: TextStyle ( fontSize: 20 ) ) ,
/ / Text ( myTrackersViewModel . ecgRtResultModelFromBP . diagnosis . isHeartPause ? " YES " : " NO " , style: TextStyle ( fontSize: 40 , fontWeight: FontWeight . bold ) ) ,
/ / Text ( " " , style: TextStyle ( fontSize: 10 ) ) ,
/ / ] ,
/ / ) ,
] ,
) ,
mHeight ( 30.0 ) ,
/ / Row (
/ / mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
/ / children: [
/ / Column (
/ / children: [
/ / Text ( " Lead Off " , style: TextStyle ( fontSize: 20 ) ) ,
/ / Text ( myTrackersViewModel . ecgRtResultModelFromBP . diagnosis . isLeadOff ? " YES " : " NO " , style: TextStyle ( fontSize: 40 , fontWeight: FontWeight . bold ) ) ,
/ / Text ( " " , style: TextStyle ( fontSize: 10 ) ) ,
/ / ] ,
/ / ) ,
/ / Column (
/ / children: [
/ / Text ( " Poor Signal " , style: TextStyle ( fontSize: 20 ) ) ,
/ / Text ( myTrackersViewModel . ecgRtResultModelFromBP . diagnosis . isPoorSignal ? " YES " : " NO " , style: TextStyle ( fontSize: 40 , fontWeight: FontWeight . bold ) ) ,
/ / Text ( " " , style: TextStyle ( fontSize: 10 ) ) ,
/ / ] ,
/ / ) ,
/ / Column (
/ / children: [
/ / Text ( " PVCs " , style: TextStyle ( fontSize: 20 ) ) ,
/ / Text ( myTrackersViewModel . ecgRtResultModelFromBP . diagnosis . isPvcs ? " YES " : " NO " , style: TextStyle ( fontSize: 40 , fontWeight: FontWeight . bold ) ) ,
/ / Text ( " " , style: TextStyle ( fontSize: 10 ) ) ,
/ / ] ,
/ / ) ,
/ / ] ,
/ / ) ,
mHeight ( 30.0 ) ,
buildStatusForECG ( myTrackersViewModel . ecgRtResultModelFromBP . result ) ,
] ,
) ,
] 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 ) ) ) ,
] ,
] ,
) ;
}
Widget buildStatusForECG ( int result ) {
String resultStatus = " " ;
if ( result = = 0 ) {
/ / resultStatus = " Normal " ;
resultStatus = " " ; / / NO NEED TO SHOW " 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 LIST Button on the device to restart. " , style: TextStyle ( fontSize: 15 ) ) ) ,
] ,
] ,
) ;
}
showHistoryDialog ( BuildContext context ) {
return showDialog (
context: context ,
builder: ( context ) = > Container (
decoration: BoxDecoration ( borderRadius: BorderRadius . all ( Radius . circular ( 15 ) ) , color: Colors . white ) ,
padding: const EdgeInsets . all ( 20 ) ,
margin: const EdgeInsets . symmetric ( vertical: 35 , horizontal: 30 ) ,
child: SingleChildScrollView (
child: Consumer ( builder: ( BuildContext context , MyTrackersViewModel myTrackersVm , Widget child ) {
return Column (
mainAxisSize: MainAxisSize . max ,
mainAxisAlignment: MainAxisAlignment . center ,
children: [
Material ( child: Center ( child: Text ( " Files History " , style: TextStyle ( fontSize: 20 ) ) ) ) ,
if ( myTrackersVm . filesLoader ) . . . [
Center ( child: CircularProgressIndicator ( ) )
] else if ( myTrackersVm . ecgHistoryFiles . isNotEmpty ) . . . [
myTrackersVm . getFilesListWidget ( myTrackersVm . ecgHistoryFiles , context ) ,
mHeight ( 15 ) ,
Row (
children: [
Expanded (
child: DefaultButton (
" Reset History " ,
( ) async {
myTrackersVm . clearEcgHistoryFiles ( ) ;
myTrackersVm . factoryResetECG ( widget . deviceModel ) ;
/ / Navigator . pop ( context ) ;
} ,
textColor: Colors . white ,
) ,
) ,
] ,
) ,
] else . . . [
Material ( child: Center ( child: Text ( " No History Files to show " , style: TextStyle ( fontSize: 20 ) ) ) ) ,
]
] ,
) ;
} ) ,
) ,
) ,
) ;
}
@ override
Widget build ( BuildContext context ) {
return AppScaffold (
@ -39,80 +320,67 @@ class _BloodPressureConnectScreenState extends State<BloodPressureConnectScreen>
isShowDecPage: false ,
showNewAppBarTitle: true ,
backgroundColor: Color ( 0xffF8F8F8 ) ,
appBarIcons: [
if ( myTrackersVm . isECGSelected ) . . . [
IconButton (
onPressed: ( ) async {
myTrackersVm . updateFilesLoader ( true ) ;
showHistoryDialog ( context ) ;
await myTrackersVm . getEcgFilesList ( widget . deviceModel ) ;
} ,
icon: Icon ( Icons . format_list_numbered_rounded ) ,
) ,
] ,
IconButton (
onPressed: ( ) {
AppSharedPreferences ( ) . remove ( IS_LIVECARE_APPOINTMENT ) ;
Navigator . pushAndRemoveUntil (
context ,
MaterialPageRoute ( builder: ( context ) = > LandingPage ( ) ) ,
( Route < dynamic > route ) = > false ,
) ;
} ,
icon: Icon ( Icons . home ) ,
) ,
] ,
body: Padding (
padding: const EdgeInsets . all ( 24.0 ) ,
child: Consumer (
builder: ( BuildContext context , MyTrackersViewModel myTrackersViewModel , Widget child ) {
return Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Expanded (
child: ListView (
children: [
if ( myTrackersViewModel . bpCurrentStatus = = " RealTimeDataBP2Measuring " ) . . . [
Row (
mainAxisAlignment: MainAxisAlignment . center ,
children: [
mHeight ( 24.0 ) ,
Column (
children: [
Text ( myTrackersViewModel . bpRtMeasuringModel . pressure . toString ( ) , style: TextStyle ( fontSize: 100 , fontWeight: FontWeight . bold ) ) ,
Text ( " Pressure " , style: TextStyle ( fontSize: 20 ) ) ,
] ,
) ,
mHeight ( 24.0 ) ,
] ,
) ,
] else if ( myTrackersViewModel . bpCurrentStatus = = " RealTimeDataBP2Result " ) . . . [
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
mHeight ( 24.0 ) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
Column (
children: [
Text ( " Dia " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . bpRtResultModel . dia . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " mmHg " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
Column (
children: [
Text ( " Sys " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . bpRtResultModel . sys . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " mmHg " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
Column (
children: [
Text ( " ♥︎ " , style: TextStyle ( fontSize: 20 ) ) ,
Text ( myTrackersViewModel . bpRtResultModel . pr . toString ( ) , style: TextStyle ( fontSize: 50 , fontWeight: FontWeight . bold ) ) ,
Text ( " /min " , style: TextStyle ( fontSize: 10 ) ) ,
] ,
) ,
] ,
) ,
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 ) ,
) ,
) ,
)
] ,
] ,
if ( widget . isEcgAvailable ) . . . [
FlutterToggleTab (
borderRadius: 30 ,
height: 40 ,
width: 80 ,
selectedIndex: myTrackersViewModel . isECGSelected ? 1 : 0 ,
selectedBackgroundColors: [ Color ( 0xffD02127 ) , Color ( 0xffD02127 ) ] ,
selectedTextStyle: TextStyle ( color: Colors . white , fontSize: 18 , fontWeight: FontWeight . w700 ) ,
unSelectedTextStyle: TextStyle ( color: Colors . black87 , fontSize: 14 , fontWeight: FontWeight . w500 ) ,
labels: [ " BP " , " ECG " ] ,
selectedLabelIndex: ( index ) {
if ( index = = 1 & & myTrackersViewModel . bpCurrentStatus = = kRealTimeDataBPMeasuring ) {
return ;
}
if ( index = = 0 & & myTrackersViewModel . ecgCurrentStatus = = kRealTimeDataECGMeasuring ) {
return ;
}
if ( index = = 0 ) {
myTrackersViewModel . updateIsECGSelected ( false ) ;
} else {
myTrackersViewModel . updateIsECGSelected ( true ) ;
}
setState ( ( ) { } ) ;
} ,
isScroll: false ,
) ,
) ,
if ( myTrackersViewModel . bpCurrentStatus ! = null ) . . . [
] ,
myTrackersViewModel . isECGSelected ? buildECGUI ( myTrackersViewModel ) : buildBloodPressureUI ( myTrackersViewModel ) ,
if ( myTrackersViewModel . bpCurrentStatus ! = null | | myTrackersViewModel . ecgCurrentStatus ! = null ) . . . [
Row (
children: [
Expanded (
@ -122,6 +390,9 @@ class _BloodPressureConnectScreenState extends State<BloodPressureConnectScreen>
myTrackersVm . bpCurrentStatus = null ;
myTrackersVm . bpRtMeasuringModel = null ;
myTrackersVm . bpRtResultModel = null ;
myTrackersVm . ecgCurrentStatus = null ;
myTrackersVm . ecgRtMeasuringModelFromBP = null ;
myTrackersVm . ecgRtResultModelFromBP = null ;
Navigator . pop ( context ) ;
} ,
textColor: Colors . white ,