Added ECG chart view
parent
4ec93e8609
commit
55b93feda3
@ -0,0 +1,89 @@
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ble_models/checkmepro_all_in_one_models/checkme_ecg_wave_model.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CheckMeECGChartView extends StatelessWidget {
|
||||
final CheckMeECGWaveModel checkMeECGWave;
|
||||
|
||||
CheckMeECGChartView({@required this.checkMeECGWave});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<int> list = checkMeECGWave.bytes;
|
||||
List<List<int>> mainList = chunkIntList(list, 1250);
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: ScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(right: MediaQuery.of(context).size.width - (MediaQuery.of(context).size.width * (mainList[index].length / 1250))),
|
||||
child: SizedBox(
|
||||
height: 120.0,
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
lineTouchData: LineTouchData(handleBuiltInTouches: false),
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
verticalInterval: 30,
|
||||
horizontalInterval: 30,
|
||||
getDrawingVerticalLine: (value) {
|
||||
return FlLine(
|
||||
color: Colors.red[300],
|
||||
strokeWidth: 0.4,
|
||||
);
|
||||
},
|
||||
getDrawingHorizontalLine: (value) {
|
||||
return FlLine(
|
||||
color: Colors.red[300],
|
||||
strokeWidth: 0.4,
|
||||
);
|
||||
},
|
||||
),
|
||||
titlesData: FlTitlesData(show: false),
|
||||
borderData: FlBorderData(
|
||||
show: false,
|
||||
border: Border.all(color: const Color(0xff37434d), width: 1),
|
||||
),
|
||||
minX: 0,
|
||||
maxX: (mainList[index].length.toDouble() - 1),
|
||||
minY: list.reduce((value, element) => value < element ? value : element).toDouble(),
|
||||
maxY: list.reduce((value, element) => value > element ? value : element).toDouble(),
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
isCurved: false,
|
||||
preventCurveOverShooting: true,
|
||||
barWidth: 0.5,
|
||||
dotData: FlDotData(show: false),
|
||||
spots: getDataList(mainList[index]),
|
||||
colors: [Colors.grey[800]],
|
||||
isStrokeCapRound: true,
|
||||
belowBarData: BarAreaData(show: false),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: mainList.length,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 14),
|
||||
);
|
||||
}
|
||||
|
||||
List<List<int>> chunkIntList(List<int> list, int chunkSize) {
|
||||
List<List<int>> chunks = [];
|
||||
for (int i = 0; i < list.length; i += chunkSize) {
|
||||
int end = i + chunkSize;
|
||||
chunks.add(list.sublist(i, end > list.length ? list.length : end));
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
List<FlSpot> getDataList(List<int> list) {
|
||||
List<FlSpot> spotsList = [];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
spotsList.add(FlSpot(i.toDouble(), list[i].toDouble()));
|
||||
}
|
||||
return spotsList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ble_device_type_screens/checkme_ecg_chart_view.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ble_models/checkmepro_all_in_one_models/checkme_bp_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ble_models/checkmepro_all_in_one_models/checkme_ecg_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ble_models/checkmepro_all_in_one_models/checkme_glucose_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ble_models/checkmepro_all_in_one_models/checkme_oxi_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ble_models/checkmepro_all_in_one_models/checkme_temperature_model.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/others/app_scaffold_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CheckMeECGInfoScreen extends StatelessWidget {
|
||||
final TrackerTypeEnum allInOneTrackerTypeEnum;
|
||||
|
||||
const CheckMeECGInfoScreen(this.allInOneTrackerTypeEnum);
|
||||
|
||||
String getTrackerNameByEnum(TrackerTypeEnum trackerTypeEnum) {
|
||||
switch (trackerTypeEnum) {
|
||||
case TrackerTypeEnum.OxymeterTracker:
|
||||
return "Oxymeter";
|
||||
|
||||
case TrackerTypeEnum.BloodPressureTracker:
|
||||
return "Blood Pressure";
|
||||
|
||||
case TrackerTypeEnum.BloodSugarTracker:
|
||||
return "Blood Glucose";
|
||||
|
||||
case TrackerTypeEnum.ECGTracker:
|
||||
return "ECG";
|
||||
|
||||
case TrackerTypeEnum.WeightScale:
|
||||
return "Weight Scale";
|
||||
|
||||
case TrackerTypeEnum.Temperature:
|
||||
return "Temperature";
|
||||
|
||||
case TrackerTypeEnum.Spirometer:
|
||||
return "Spirometer";
|
||||
|
||||
case TrackerTypeEnum.AllInOneTracker:
|
||||
return "All in One";
|
||||
}
|
||||
return "All in One";
|
||||
}
|
||||
|
||||
Widget buildECGDetailsWidget(MyTrackersViewModel myTrackersVm, BuildContext context) {
|
||||
return Container(
|
||||
decoration: cardRadius(12),
|
||||
padding: EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Text("HR: ${myTrackersVm.checkMeECGWave.hr} bpm"),
|
||||
Text("ST: ${myTrackersVm.checkMeECGWave.st} mV"),
|
||||
Text("QRS: ${myTrackersVm.checkMeECGWave.qrs} ms"),
|
||||
],
|
||||
),
|
||||
mHeight(4.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Text("PVCS: ${myTrackersVm.checkMeECGWave.pvcs} "),
|
||||
Text("QTC: ${myTrackersVm.checkMeECGWave.qtc} ms"),
|
||||
Text("QT: ${myTrackersVm.checkMeECGWave.qt} ms"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppScaffold(
|
||||
appBarTitle: "${getTrackerNameByEnum(allInOneTrackerTypeEnum)}",
|
||||
showNewAppBar: true,
|
||||
isShowDecPage: false,
|
||||
showNewAppBarTitle: true,
|
||||
backgroundColor: Color(0xffF8F8F8),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Consumer(
|
||||
builder: (BuildContext context, MyTrackersViewModel myTrackersVm, Widget child) {
|
||||
if (myTrackersVm.checkMeECGWave == null) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Some animation with the instruction",
|
||||
style: TextStyle(fontSize: 9.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
buildECGDetailsWidget(myTrackersVm, context),
|
||||
mHeight(20),
|
||||
CheckMeECGChartView(checkMeECGWave: myTrackersVm.checkMeECGWave),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
class CheckMeECGWaveModel {
|
||||
List<int> bytes;
|
||||
int hr;
|
||||
List<int> hrList;
|
||||
int hrSize;
|
||||
int pvcs;
|
||||
int qrs;
|
||||
int qt;
|
||||
int qtc;
|
||||
int result;
|
||||
int st;
|
||||
int total;
|
||||
int waveIntSize;
|
||||
List<int> waveList;
|
||||
int waveSize;
|
||||
int waveViewSize;
|
||||
|
||||
CheckMeECGWaveModel(
|
||||
{this.bytes, this.hr, this.hrList, this.hrSize, this.pvcs, this.qrs, this.qt, this.qtc, this.result, this.st, this.total, this.waveIntSize, this.waveList, this.waveSize, this.waveViewSize});
|
||||
|
||||
CheckMeECGWaveModel.fromJson(Map<String, dynamic> json) {
|
||||
bytes = json['bytes'].cast<int>();
|
||||
hr = json['hr'];
|
||||
hrList = json['hrList'].cast<int>();
|
||||
hrSize = json['hrSize'];
|
||||
pvcs = json['pvcs'];
|
||||
qrs = json['qrs'];
|
||||
qt = json['qt'];
|
||||
qtc = json['qtc'];
|
||||
result = json['result'];
|
||||
st = json['st'];
|
||||
total = json['total'];
|
||||
waveIntSize = json['waveIntSize'];
|
||||
waveList = json['waveList'].cast<int>();
|
||||
waveSize = json['waveSize'];
|
||||
waveViewSize = json['waveViewSize'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['bytes'] = this.bytes;
|
||||
data['hr'] = this.hr;
|
||||
data['hrList'] = this.hrList;
|
||||
data['hrSize'] = this.hrSize;
|
||||
data['pvcs'] = this.pvcs;
|
||||
data['qrs'] = this.qrs;
|
||||
data['qt'] = this.qt;
|
||||
data['qtc'] = this.qtc;
|
||||
data['result'] = this.result;
|
||||
data['st'] = this.st;
|
||||
data['total'] = this.total;
|
||||
data['waveIntSize'] = this.waveIntSize;
|
||||
data['waveList'] = this.waveList;
|
||||
data['waveSize'] = this.waveSize;
|
||||
data['waveViewSize'] = this.waveViewSize;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue