no message

merge-update-with-lab-changes
haroon amjad 4 years ago
parent 76fb93fe9b
commit 1f077f71f8

@ -1581,5 +1581,7 @@ const Map localizedValues = {
"syncHealthData": { "en": "Sync Health Data", "ar": "مزامنة البيانات الصحية" },
"steps": { "en": "Steps", "ar": "الخطوات" },
"avgSteps": { "en": "Average Steps", "ar": "متوسط الخطوات" },
"avgDistance": { "en": "Average Distance", "ar": "متوسط المسافة" },
"enterDetails": {"en": "Enter Details", "ar": "أدخل التفاصيل"},
"avgHeartRate": { "en": "Average Heart Rate", "ar": "متوسط معدل ضربات القلب" },
};

@ -115,7 +115,9 @@ class BaseAppClient {
}
// body['PatientID'] = 1018977;
body['TokenID'] = "@dm!n";
// body['TokenID'] = "@dm!n";
body.removeWhere((key, value) => key == null || value == null);
print("URL : $url");
final jsonBody = json.encode(body);

@ -0,0 +1,26 @@
class WeeklyHeartRateResModel {
num valueAvg;
String machineDate;
int medCategoryID;
int patientID;
WeeklyHeartRateResModel(
{this.valueAvg, this.machineDate, this.medCategoryID, this.patientID});
WeeklyHeartRateResModel.fromJson(Map<String, dynamic> json) {
num value = json['ValueAvg'];
valueAvg = json['ValueAvg'] != null ? value.toInt() : 0;
machineDate = json['MachineDate'];
medCategoryID = json['MedCategoryID'];
patientID = json['PatientID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ValueAvg'] = this.valueAvg;
data['MachineDate'] = this.machineDate;
data['MedCategoryID'] = this.medCategoryID;
data['PatientID'] = this.patientID;
return data;
}
}

@ -17,7 +17,7 @@ class WeeklyStepsResModel {
patientID = json['PatientID'];
medCategoryID = json['MedCategoryID'];
medSubCategoryID = json['MedSubCategoryID'];
value = num.tryParse(json['Value']).toInt();
value = json['Value'] != null ? num.tryParse(json['Value']).toInt() : 0;
machineDate = json['MachineDate'];
patientOutSA = json['PatientOutSA'];
notes = json['Notes'];

@ -0,0 +1,37 @@
class YearlyHeartRateResModel {
num valueAvg;
int medCategoryID;
int month;
String monthName;
int patientID;
int year;
YearlyHeartRateResModel(
{this.valueAvg,
this.medCategoryID,
this.month,
this.monthName,
this.patientID,
this.year});
YearlyHeartRateResModel.fromJson(Map<String, dynamic> json) {
num value = json['ValueAvg'];
valueAvg = json['ValueAvg'] != null ? value.toInt() : 0;
medCategoryID = json['MedCategoryID'];
month = json['Month'];
monthName = json['MonthName'];
patientID = json['PatientID'];
year = json['Year'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ValueAvg'] = this.valueAvg;
data['MedCategoryID'] = this.medCategoryID;
data['Month'] = this.month;
data['MonthName'] = this.monthName;
data['PatientID'] = this.patientID;
data['Year'] = this.year;
return data;
}
}

@ -23,7 +23,6 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
// import 'package:table_calendar/table_calendar.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
@ -262,7 +261,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
final List<Meeting> meetings = <Meeting>[];
_events.forEach((key, value) {
final DateTime startTime = DateTime(key.year, key.month, key.day, 9, 0, 0);
final DateTime endTime = startTime.add(const Duration(hours: 2));
final DateTime endTime = startTime.add(const Duration(minutes: 20));
meetings.add(Meeting("", startTime, endTime, CustomColors.green, false));
});
return meetings;

@ -621,6 +621,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
GifLoaderDialogUtils.hideDialog(context),
Future.delayed(Duration(seconds: 1), () {
AppToast.showErrorToast(message: result);
startSMSService(tempType);
}),
}
})

@ -0,0 +1,569 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/SmartWatch/WeeklyStepsResModel.dart';
import 'package:diplomaticquarterapp/models/SmartWatch/YearlyStepsResModel.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class DistanceTracker extends StatefulWidget {
@override
_DistanceTrackerState createState() => _DistanceTrackerState();
}
class _DistanceTrackerState extends State<DistanceTracker> with SingleTickerProviderStateMixin {
TabController _tabController;
ProjectViewModel projectViewModel;
num weeklyStatsAvgValue = 0;
num monthlyStatsAvgValue = 0;
num yearlyStatsAvgValue = 0;
num avgWeeklyStepsValue = 0;
num avgMonthlyStepsValue = 0;
num avgYearlyStepsValue = 0;
int weeklyDataLength = 0;
int monthlyDataLength = 0;
int yearlyDataLength = 0;
List<WeeklyStepsResModel> weekyStepsList = List();
List<WeeklyStepsResModel> monthlyStepsList = List();
List<YearlyStepsResModel> yearlyStepsList = List();
List<TimeSeriesSales2> weeklyTimeSeriesData = [];
List<TimeSeriesSales2> monthlyTimeSeriesData = [];
List<TimeSeriesSales2> yearlyTimeSeriesData = [];
bool isWeeklyDataLoaded = false;
bool isMonthlyDataLoaded = false;
bool isYearlyDataLoaded = false;
@override
void initState() {
_tabController = new TabController(length: 3, vsync: this);
WidgetsBinding.instance.addPostFrameCallback((_) {
getWeeklyDistanceData();
});
super.initState();
}
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
return AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).distance,
showNewAppBar: true,
showNewAppBarTitle: true,
isShowDecPage: false,
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
TabBar(
controller: _tabController,
indicatorWeight: 3.0,
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Color(0xff2B353E),
unselectedLabelColor: Color(0xff575757),
labelPadding: EdgeInsets.only(top: 0, bottom: 0, left: 20, right: 20),
labelStyle: TextStyle(
fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins',
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),
unselectedLabelStyle: TextStyle(
fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins',
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),
tabs: [
Tab(text: TranslationBase.of(context).weekly),
Tab(text: TranslationBase.of(context).monthly),
Tab(text: TranslationBase.of(context).yearly),
],
onTap: (value) {
print(value);
if (value == 0) {
getWeeklyDistanceData();
} else if (value == 1) {
getMonthlyDistanceData();
} else {
getYearlyDistanceData();
}
},
),
Expanded(
child: new TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
isWeeklyDataLoaded ? getWeeklyDistanceDetails() : Container(),
isMonthlyDataLoaded ? getMonthlyDistanceDetails() : Container(),
isYearlyDataLoaded ? getYearlyDistanceDetails() : Container()
],
controller: _tabController,
),
),
],
),
);
}
getWeeklyDistanceData() {
avgWeeklyStepsValue = 0;
weeklyDataLength = 0;
DoctorsListService service = new DoctorsListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(7, 1, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
weekyStepsList.clear();
res['Med_GetWeekStepsTransactionsStsList'].forEach((element) {
weekyStepsList.add(new WeeklyStepsResModel.fromJson(element));
if (element['Value'] != null) {
num value = num.tryParse(element['Value'] ?? "0");
avgWeeklyStepsValue += value;
weeklyDataLength++;
}
});
generateWeekData();
setState(() {
weeklyStatsAvgValue = avgWeeklyStepsValue ~/ weeklyDataLength;
weeklyStatsAvgValue = weeklyStatsAvgValue / 1000;
isWeeklyDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
getMonthlyDistanceData() {
avgMonthlyStepsValue = 0;
monthlyDataLength = 0;
DoctorsListService service = new DoctorsListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(7, 2, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
monthlyStepsList.clear();
res['Med_GetMonthStepsTransactionsStsList'].forEach((element) {
monthlyStepsList.add(new WeeklyStepsResModel.fromJson(element));
if (element['Value'] != null) {
num value = num.tryParse(element['Value'] ?? "0");
avgMonthlyStepsValue += value;
monthlyDataLength++;
}
});
generateMonthData();
setState(() {
monthlyStatsAvgValue = avgMonthlyStepsValue ~/ monthlyDataLength;
monthlyStatsAvgValue = monthlyStatsAvgValue / 1000;
isMonthlyDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
getYearlyDistanceData() {
avgYearlyStepsValue = 0;
yearlyDataLength = 0;
DoctorsListService service = new DoctorsListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(7, 3, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
yearlyStepsList.clear();
res['Med_GetYearStepsTransactionsStsList'].forEach((element) {
yearlyStepsList.add(new YearlyStepsResModel.fromJson(element));
if (element['ValueSum'] != null) {
num value = element['ValueSum'];
avgYearlyStepsValue += value;
yearlyDataLength++;
}
});
generateYearData();
setState(() {
yearlyStatsAvgValue = avgYearlyStepsValue ~/ yearlyDataLength;
yearlyStatsAvgValue = yearlyStatsAvgValue / 1000;
isYearlyDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
generateWeekData() {
if (weekyStepsList.length > 0) {
weeklyTimeSeriesData.clear();
weekyStepsList.forEach(
(element) {
weeklyTimeSeriesData.add(
TimeSeriesSales2(
DateUtil.convertStringToDate(element.machineDate),
element.value != null ? (element.value.toDouble() / 1000) : 0.0,
),
);
},
);
}
}
generateMonthData() {
if (monthlyStepsList.length > 0) {
monthlyTimeSeriesData.clear();
monthlyStepsList.forEach(
(element) {
monthlyTimeSeriesData.add(
TimeSeriesSales2(
DateUtil.convertStringToDate(element.machineDate),
element.value != null ? element.value.toDouble() / 1000 : 0.0,
),
);
},
);
}
}
generateYearData() {
if (yearlyStepsList.length > 0) {
yearlyTimeSeriesData.clear();
yearlyStepsList.forEach(
(element) {
yearlyTimeSeriesData.add(
TimeSeriesSales2(
new DateTime(element.year, element.month, 1),
element.valueSum != null ? element.valueSum.toDouble() / 1000 : 0.0,
),
);
},
);
}
}
getWeeklyDistanceDetails() {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ShowChart(
title: "",
timeSeries: weeklyTimeSeriesData,
indexes: weeklyTimeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
),
Container(
child: Container(
decoration: cardRadius(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 5.0),
child: Text(TranslationBase.of(context).avgDistance, style: TextStyle(fontSize: 18.0)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Text(weeklyStatsAvgValue.toString() + " " + TranslationBase.of(context).km_, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
),
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
)),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
weekyStepsList.isEmpty
? Container(
child: Center(
child: Text(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullDataWeekly(context),
),
],
),
)
],
),
),
],
),
);
}
getMonthlyDistanceDetails() {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ShowChart(
title: "",
timeSeries: monthlyTimeSeriesData,
indexes: monthlyTimeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
),
Container(
child: Container(
decoration: cardRadius(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 5.0),
child: Text(TranslationBase.of(context).avgDistance, style: TextStyle(fontSize: 18.0)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Text(monthlyStatsAvgValue.toString() + " " + TranslationBase.of(context).km_, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
),
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
)),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
monthlyStepsList.isEmpty
? Container(
child: Center(
child: Text(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullDataMonthly(context),
),
],
),
)
],
),
),
],
),
);
}
getYearlyDistanceDetails() {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ShowChart(
title: "",
timeSeries: yearlyTimeSeriesData,
indexes: yearlyTimeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
),
Container(
child: Container(
decoration: cardRadius(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 5.0),
child: Text(TranslationBase.of(context).avgDistance, style: TextStyle(fontSize: 18.0)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Text(yearlyStatsAvgValue.toString() + " " + TranslationBase.of(context).km_, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
),
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
)),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
yearlyStepsList.isEmpty
? Container(
child: Center(
child: Text(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullData(context),
),
],
),
)
],
),
),
],
),
);
}
List<TableRow> fullDataWeekly(BuildContext context) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).distance),
],
),
);
weekyStepsList.forEach(
(step) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(
'${DateUtil.getDayMonthYearDateFormatted(
DateUtil.convertStringToDate(step.machineDate),
)} ',
isCapitable: false,
mProjectViewModel: projectViewModel),
Utils.tableColumnValue((step.value / 1000).toString() + " " + TranslationBase.of(context).km_, isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
List<TableRow> fullDataMonthly(BuildContext context) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).distance),
],
),
);
monthlyStepsList.forEach(
(step) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(
'${DateUtil.getDayMonthYearDateFormatted(
DateUtil.convertStringToDate(step.machineDate),
)} ',
isCapitable: false,
mProjectViewModel: projectViewModel),
Utils.tableColumnValue((step.value / 1000).toString() + " " + TranslationBase.of(context).km_, isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
List<TableRow> fullData(BuildContext context) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).distance),
],
),
);
yearlyStepsList.forEach(
(step) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(
'${DateUtil.getDayMonthYearDateFormatted(
new DateTime(step.year, step.month, 1),
)} ',
isCapitable: false,
mProjectViewModel: projectViewModel),
Utils.tableColumnValue(step.valueSum != null ? (step.valueSum / 1000).toString() + " " + TranslationBase.of(context).km_ : "0.0 " + TranslationBase.of(context).km_ , isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
}

@ -1,4 +1,6 @@
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/Steps/stepsTracker.dart';
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/distance/distanceTracker.dart';
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/heartrate/heartrateTracker.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -40,16 +42,26 @@ class _HealthDataListState extends State<HealthDataList> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text("Heart Rate", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: HeartRateTracker(),
),
);
},
child: Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text(TranslationBase.of(context).heart, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
Divider(
color: Colors.grey[500],
@ -84,7 +96,7 @@ class _HealthDataListState extends State<HealthDataList> {
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text("Steps", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
child: Text(TranslationBase.of(context).steps, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
@ -92,34 +104,44 @@ class _HealthDataListState extends State<HealthDataList> {
Divider(
color: Colors.grey[500],
),
Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text("Distance", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
Divider(
color: Colors.grey[500],
),
Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text("Energy", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: DistanceTracker(),
),
);
},
child: Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text(TranslationBase.of(context).distance, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
Divider(
color: Colors.grey[500],
),
// Row(
// children: [
// Container(
// child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
// ),
// Container(
// margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
// child: Text("Energy", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
// ),
// ],
// ),
// Divider(
// color: Colors.grey[500],
// ),
],
),
),

@ -0,0 +1,570 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/SmartWatch/WeeklyHeartRateResModel.dart';
import 'package:diplomaticquarterapp/models/SmartWatch/YearlyHeartRateResModel.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class HeartRateTracker extends StatefulWidget {
@override
_HeartRateTrackerState createState() => _HeartRateTrackerState();
}
class _HeartRateTrackerState extends State<HeartRateTracker> with SingleTickerProviderStateMixin {
TabController _tabController;
ProjectViewModel projectViewModel;
num weeklyStatsAvgValue = 0;
num monthlyStatsAvgValue = 0;
num yearlyStatsAvgValue = 0;
num avgWeeklyHearRateValue = 0;
num avgMonthlyHearRateValue = 0;
num avgYearlyHearRateValue = 0;
int weeklyDataLength = 0;
int monthlyDataLength = 0;
int yearlyDataLength = 0;
List<WeeklyHeartRateResModel> weekyHearRateList = List();
List<WeeklyHeartRateResModel> monthlyHearRateList = List();
List<YearlyHeartRateResModel> yearlyHearRateList = List();
List<TimeSeriesSales2> weeklyTimeSeriesData = [];
List<TimeSeriesSales2> monthlyTimeSeriesData = [];
List<TimeSeriesSales2> yearlyTimeSeriesData = [];
bool isWeeklyDataLoaded = false;
bool isMonthlyDataLoaded = false;
bool isYearlyDataLoaded = false;
@override
void initState() {
_tabController = new TabController(length: 3, vsync: this);
WidgetsBinding.instance.addPostFrameCallback((_) {
getWeeklyHeartRateData();
});
super.initState();
}
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
return AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).heart,
showNewAppBar: true,
showNewAppBarTitle: true,
isShowDecPage: false,
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
TabBar(
controller: _tabController,
indicatorWeight: 3.0,
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Color(0xff2B353E),
unselectedLabelColor: Color(0xff575757),
labelPadding: EdgeInsets.only(top: 0, bottom: 0, left: 20, right: 20),
labelStyle: TextStyle(
fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins',
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),
unselectedLabelStyle: TextStyle(
fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins',
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),
tabs: [
Tab(text: TranslationBase.of(context).weekly),
Tab(text: TranslationBase.of(context).monthly),
Tab(text: TranslationBase.of(context).yearly),
],
onTap: (value) {
print(value);
if (value == 0) {
getWeeklyHeartRateData();
} else if (value == 1) {
getMonthlyHeartRateData();
} else {
// getYearlyHeartRateData();
}
},
),
Expanded(
child: new TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
isWeeklyDataLoaded ? getWeeklyHeartRateDetails() : Container(),
isMonthlyDataLoaded ? getMonthlyHeartRateDetails() : Container(),
// isYearlyDataLoaded ? getYearlyDistanceDetails() : Container()
// Container(),
// Container(),
Container()
],
controller: _tabController,
),
),
],
),
);
}
getWeeklyHeartRateData() {
avgWeeklyHearRateValue = 0;
weeklyDataLength = 0;
DoctorsListService service = new DoctorsListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(3, 1, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
weekyHearRateList.clear();
res['Med_GetAvgWeekTransactionsStsList'].forEach((element) {
weekyHearRateList.add(new WeeklyHeartRateResModel.fromJson(element));
if (element['ValueAvg'] != null) {
num value = element['ValueAvg'];
avgWeeklyHearRateValue += value.toInt();
weeklyDataLength++;
}
});
generateWeekData();
setState(() {
weeklyStatsAvgValue = avgWeeklyHearRateValue ~/ weeklyDataLength;
isWeeklyDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
getMonthlyHeartRateData() {
avgMonthlyHearRateValue = 0;
monthlyDataLength = 0;
DoctorsListService service = new DoctorsListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(3, 2, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
monthlyHearRateList.clear();
print(res['Med_GetAvgMonthTransactionsStsList'].length);
res['Med_GetAvgMonthTransactionsStsList'].forEach((element) {
monthlyHearRateList.add(new WeeklyHeartRateResModel.fromJson(element));
if (element['ValueAvg'] != null) {
num value = element['ValueAvg'];
avgMonthlyHearRateValue += value.toInt();
monthlyDataLength++;
}
});
generateMonthData();
setState(() {
monthlyStatsAvgValue = avgMonthlyHearRateValue ~/ monthlyDataLength;
isMonthlyDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
getYearlyHeartRateData() {
avgYearlyHearRateValue = 0;
yearlyDataLength = 0;
DoctorsListService service = new DoctorsListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(7, 3, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
yearlyHearRateList.clear();
res['Med_GetYearTransactionsStsList'].forEach((element) {
yearlyHearRateList.add(new YearlyHeartRateResModel.fromJson(element));
if (element['ValueSum'] != null) {
num value = element['ValueSum'];
avgYearlyHearRateValue += value;
yearlyDataLength++;
}
});
generateYearData();
setState(() {
yearlyStatsAvgValue = avgYearlyHearRateValue ~/ yearlyDataLength;
isYearlyDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
generateWeekData() {
if (weekyHearRateList.length > 0) {
weeklyTimeSeriesData.clear();
weekyHearRateList.forEach(
(element) {
weeklyTimeSeriesData.add(
TimeSeriesSales2(
DateUtil.convertStringToDate(element.machineDate),
element.valueAvg != null ? element.valueAvg.toDouble() : 0.0,
),
);
},
);
}
}
generateMonthData() {
if (monthlyHearRateList.length > 0) {
monthlyTimeSeriesData.clear();
monthlyHearRateList.forEach(
(element) {
monthlyTimeSeriesData.add(
TimeSeriesSales2(
DateUtil.convertStringToDate(element.machineDate),
element.valueAvg != null ? element.valueAvg.toDouble() : 0.0,
),
);
},
);
}
}
generateYearData() {
if (yearlyHearRateList.length > 0) {
yearlyTimeSeriesData.clear();
yearlyHearRateList.forEach(
(element) {
yearlyTimeSeriesData.add(
TimeSeriesSales2(
new DateTime(element.year, element.month, 1),
element.valueAvg != null ? element.valueAvg.toDouble() : 0.0,
),
);
},
);
}
}
getWeeklyHeartRateDetails() {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ShowChart(
title: "",
timeSeries: weeklyTimeSeriesData,
indexes: weeklyTimeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
),
Container(
child: Container(
decoration: cardRadius(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 5.0),
child: Text(TranslationBase.of(context).avgHeartRate, style: TextStyle(fontSize: 18.0)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Text(weeklyStatsAvgValue.toString() + " " + TranslationBase.of(context).bpm, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
),
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
)),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
weekyHearRateList.isEmpty
? Container(
child: Center(
child: Text(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullDataWeekly(context),
),
],
),
)
],
),
),
],
),
);
}
getMonthlyHeartRateDetails() {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ShowChart(
title: "",
timeSeries: monthlyTimeSeriesData,
indexes: monthlyTimeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
),
Container(
child: Container(
decoration: cardRadius(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 5.0),
child: Text(TranslationBase.of(context).avgHeartRate, style: TextStyle(fontSize: 18.0)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Text(monthlyStatsAvgValue.toString() + " " + TranslationBase.of(context).bpm, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
),
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
)),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
monthlyHearRateList.isEmpty
? Container(
child: Center(
child: Text(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullDataMonthly(context),
),
],
),
)
],
),
),
],
),
);
}
getYearlyHeartRateDetails() {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ShowChart(
title: "",
timeSeries: yearlyTimeSeriesData,
indexes: yearlyTimeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
),
Container(
child: Container(
decoration: cardRadius(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 5.0),
child: Text(TranslationBase.of(context).avgDistance, style: TextStyle(fontSize: 18.0)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Text(yearlyStatsAvgValue.toString() + " " + TranslationBase.of(context).km_, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
),
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
)),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
yearlyHearRateList.isEmpty
? Container(
child: Center(
child: Text(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullData(context),
),
],
),
)
],
),
),
],
),
);
}
List<TableRow> fullDataWeekly(BuildContext context) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).heart),
],
),
);
weekyHearRateList.forEach(
(step) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(
'${DateUtil.getDayMonthYearDateFormatted(
DateUtil.convertStringToDate(step.machineDate),
)} ',
isCapitable: false,
mProjectViewModel: projectViewModel),
Utils.tableColumnValue(step.valueAvg.toString() + " " + TranslationBase.of(context).bpm, isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
List<TableRow> fullDataMonthly(BuildContext context) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).heart),
],
),
);
monthlyHearRateList.forEach(
(step) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(
'${DateUtil.getDayMonthYearDateFormatted(
DateUtil.convertStringToDate(step.machineDate),
)} ',
isCapitable: false,
mProjectViewModel: projectViewModel),
Utils.tableColumnValue(step.valueAvg.toString() + " " + TranslationBase.of(context).bpm, isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
List<TableRow> fullData(BuildContext context) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).distance),
],
),
);
yearlyHearRateList.forEach(
(step) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(
'${DateUtil.getDayMonthYearDateFormatted(
new DateTime(step.year, step.month, 1),
)} ',
isCapitable: false,
mProjectViewModel: projectViewModel),
Utils.tableColumnValue(step.valueAvg.toString() + " " + TranslationBase.of(context).bpm, isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
}

@ -28,15 +28,15 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
int yearlyStatsAvgValue = 0;
int avgWeeklyStepsValue = 0;
int weeklyDataLength = 0;
int avgMonthlyStepsValue = 0;
int monthlyDataLength = 0;
int avgYearlyStepsValue = 0;
int weeklyDataLength = 0;
int monthlyDataLength = 0;
int yearlyDataLength = 0;
List<WeeklyStepsResModel> weekyStepsList = List();
List<WeeklyStepsResModel> monthlyStepsList = List();
List<YearlyStepsResModel> yearlyStepsList = List();
List<TimeSeriesSales2> weeklyTimeSeriesData = [];
@ -51,7 +51,6 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
void initState() {
_tabController = new TabController(length: 3, vsync: this);
WidgetsBinding.instance.addPostFrameCallback((_) {
// getYearlyStepsData();
getWeeklyStepsData();
});
super.initState();
@ -97,6 +96,7 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
if (value == 0) {
getWeeklyStepsData();
} else if (value == 1) {
getMonthlyStepsData();
} else {
getYearlyStepsData();
}
@ -125,7 +125,6 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(6, 1, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
print(res['Med_GetYearStepsTransactionsStsList']);
weekyStepsList.clear();
res['Med_GetWeekStepsTransactionsStsList'].forEach((element) {
weekyStepsList.add(new WeeklyStepsResModel.fromJson(element));
@ -146,7 +145,32 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
});
}
getMonthlyStepsData() {}
getMonthlyStepsData() {
avgMonthlyStepsValue = 0;
monthlyDataLength = 0;
DoctorsListService service = new DoctorsListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(6, 2, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
monthlyStepsList.clear();
res['Med_GetMonthStepsTransactionsStsList'].forEach((element) {
monthlyStepsList.add(new WeeklyStepsResModel.fromJson(element));
if (element['Value'] != null) {
num value = num.tryParse(element['Value'] ?? "0");
avgMonthlyStepsValue += value.toInt();
monthlyDataLength++;
}
});
generateMonthData();
setState(() {
monthlyStatsAvgValue = avgMonthlyStepsValue ~/ monthlyDataLength;
isMonthlyDataLoaded = true;
});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
getYearlyStepsData() {
avgYearlyStepsValue = 0;
@ -155,7 +179,6 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
GifLoaderDialogUtils.showMyDialog(context);
service.getPatientHealthDataStats(6, 3, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
print(res['Med_GetYearStepsTransactionsStsList']);
yearlyStepsList.clear();
res['Med_GetYearStepsTransactionsStsList'].forEach((element) {
yearlyStepsList.add(new YearlyStepsResModel.fromJson(element));
@ -184,7 +207,23 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
weeklyTimeSeriesData.add(
TimeSeriesSales2(
DateUtil.convertStringToDate(element.machineDate),
element.value != null ? element.value : 0.0,
element.value != null ? element.value.toDouble() : 0.0,
),
);
},
);
}
}
generateMonthData() {
if (monthlyStepsList.length > 0) {
monthlyTimeSeriesData.clear();
monthlyStepsList.forEach(
(element) {
monthlyTimeSeriesData.add(
TimeSeriesSales2(
DateUtil.convertStringToDate(element.machineDate),
element.value != null ? element.value.toDouble() : 0.0,
),
);
},
@ -284,8 +323,77 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
}
getMonthlyStepsDetails() {
return Container(
child: Text("Monthly"),
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ShowChart(
title: "",
timeSeries: monthlyTimeSeriesData,
indexes: monthlyTimeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
),
Container(
child: Container(
decoration: cardRadius(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 5.0),
child: Text(TranslationBase.of(context).avgSteps, style: TextStyle(fontSize: 18.0)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Text(monthlyStatsAvgValue.toString() + " " + TranslationBase.of(context).steps, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
),
),
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
)),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
monthlyStepsList.isEmpty
? Container(
child: Center(
child: Text(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullDataMonthly(context),
),
],
),
)
],
),
),
],
),
);
}
@ -423,4 +531,34 @@ class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderSt
);
return tableRow;
}
List<TableRow> fullDataMonthly(BuildContext context) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).steps),
],
),
);
monthlyStepsList.forEach(
(step) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(
'${DateUtil.getDayMonthYearDateFormatted(
DateUtil.convertStringToDate(step.machineDate),
)} ',
isCapitable: false,
mProjectViewModel: projectViewModel),
Utils.tableColumnValue(step.value.toString(), isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
}

@ -2526,6 +2526,10 @@ class TranslationBase {
String get steps => localizedValues["steps"][locale.languageCode];
String get avgSteps => localizedValues["avgSteps"][locale.languageCode];
String get avgDistance => localizedValues["avgDistance"][locale.languageCode];
String get avgHeartRate => localizedValues["avgHeartRate"][locale.languageCode];
}
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

@ -17,7 +17,7 @@ class SMSOTP {
final Function onFailure;
final context;
int remainingTime = 600;
int remainingTime = 120;
Future<Null> timer;

Loading…
Cancel
Save