Working on Health data
parent
2062b96652
commit
2032053cb7
@ -0,0 +1,42 @@
|
|||||||
|
class WeeklyStepsResModel {
|
||||||
|
int iD;
|
||||||
|
int patientID;
|
||||||
|
int medCategoryID;
|
||||||
|
int medSubCategoryID;
|
||||||
|
num value;
|
||||||
|
String machineDate;
|
||||||
|
bool patientOutSA;
|
||||||
|
dynamic notes;
|
||||||
|
bool isActive;
|
||||||
|
String createdOn;
|
||||||
|
|
||||||
|
WeeklyStepsResModel({this.iD, this.patientID, this.medCategoryID, this.medSubCategoryID, this.value, this.machineDate, this.patientOutSA, this.notes, this.isActive, this.createdOn});
|
||||||
|
|
||||||
|
WeeklyStepsResModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
iD = json['ID'];
|
||||||
|
patientID = json['PatientID'];
|
||||||
|
medCategoryID = json['MedCategoryID'];
|
||||||
|
medSubCategoryID = json['MedSubCategoryID'];
|
||||||
|
value = num.tryParse(json['Value']).toInt();
|
||||||
|
machineDate = json['MachineDate'];
|
||||||
|
patientOutSA = json['PatientOutSA'];
|
||||||
|
notes = json['Notes'];
|
||||||
|
isActive = json['IsActive'];
|
||||||
|
createdOn = json['CreatedOn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['ID'] = this.iD;
|
||||||
|
data['PatientID'] = this.patientID;
|
||||||
|
data['MedCategoryID'] = this.medCategoryID;
|
||||||
|
data['MedSubCategoryID'] = this.medSubCategoryID;
|
||||||
|
data['Value'] = this.value;
|
||||||
|
data['MachineDate'] = this.machineDate;
|
||||||
|
data['PatientOutSA'] = this.patientOutSA;
|
||||||
|
data['Notes'] = this.notes;
|
||||||
|
data['IsActive'] = this.isActive;
|
||||||
|
data['CreatedOn'] = this.createdOn;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,426 @@
|
|||||||
|
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 StepsTracker extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_StepsTrackerState createState() => _StepsTrackerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StepsTrackerState extends State<StepsTracker> with SingleTickerProviderStateMixin {
|
||||||
|
TabController _tabController;
|
||||||
|
|
||||||
|
ProjectViewModel projectViewModel;
|
||||||
|
|
||||||
|
int weeklyStatsAvgValue = 0;
|
||||||
|
int monthlyStatsAvgValue = 0;
|
||||||
|
int yearlyStatsAvgValue = 0;
|
||||||
|
|
||||||
|
int avgWeeklyStepsValue = 0;
|
||||||
|
int weeklyDataLength = 0;
|
||||||
|
|
||||||
|
int avgMonthlyStepsValue = 0;
|
||||||
|
int monthlyDataLength = 0;
|
||||||
|
|
||||||
|
int avgYearlyStepsValue = 0;
|
||||||
|
int yearlyDataLength = 0;
|
||||||
|
|
||||||
|
List<WeeklyStepsResModel> weekyStepsList = 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((_) {
|
||||||
|
// getYearlyStepsData();
|
||||||
|
getWeeklyStepsData();
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
projectViewModel = Provider.of(context);
|
||||||
|
return AppScaffold(
|
||||||
|
isShowAppBar: true,
|
||||||
|
appBarTitle: TranslationBase.of(context).steps,
|
||||||
|
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) {
|
||||||
|
if (value == 0) {
|
||||||
|
getWeeklyStepsData();
|
||||||
|
} else if (value == 1) {
|
||||||
|
} else {
|
||||||
|
getYearlyStepsData();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: new TabBarView(
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
children: [
|
||||||
|
isWeeklyDataLoaded ? getWeeklyStepsDetails() : Container(),
|
||||||
|
isMonthlyDataLoaded ? getMonthlyStepsDetails() : Container(),
|
||||||
|
isYearlyDataLoaded ? getYearlyStepsDetails() : Container()
|
||||||
|
],
|
||||||
|
controller: _tabController,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getWeeklyStepsData() {
|
||||||
|
avgWeeklyStepsValue = 0;
|
||||||
|
weeklyDataLength = 0;
|
||||||
|
DoctorsListService service = new DoctorsListService();
|
||||||
|
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));
|
||||||
|
if (element['Value'] != null) {
|
||||||
|
num value = num.tryParse(element['Value'] ?? "0");
|
||||||
|
avgWeeklyStepsValue += value.toInt();
|
||||||
|
weeklyDataLength++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
generateWeekData();
|
||||||
|
setState(() {
|
||||||
|
weeklyStatsAvgValue = avgWeeklyStepsValue ~/ weeklyDataLength;
|
||||||
|
isWeeklyDataLoaded = true;
|
||||||
|
});
|
||||||
|
}).catchError((err) {
|
||||||
|
GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
print(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getMonthlyStepsData() {}
|
||||||
|
|
||||||
|
getYearlyStepsData() {
|
||||||
|
avgYearlyStepsValue = 0;
|
||||||
|
yearlyDataLength = 0;
|
||||||
|
DoctorsListService service = new DoctorsListService();
|
||||||
|
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));
|
||||||
|
if (element['ValueSum'] != null) {
|
||||||
|
num value = element['ValueSum'];
|
||||||
|
avgYearlyStepsValue += value.toInt();
|
||||||
|
yearlyDataLength++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
generateYearData();
|
||||||
|
setState(() {
|
||||||
|
yearlyStatsAvgValue = avgYearlyStepsValue ~/ yearlyDataLength;
|
||||||
|
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 : 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 ? double.tryParse(element.valueSum.toString()) : 0.0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getWeeklyStepsDetails() {
|
||||||
|
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).avgSteps, style: TextStyle(fontSize: 18.0)),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(bottom: 10.0),
|
||||||
|
child: Text(weeklyStatsAvgValue.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>[
|
||||||
|
weekyStepsList.isEmpty
|
||||||
|
? Container(
|
||||||
|
child: Center(
|
||||||
|
child: Text(TranslationBase.of(context).noDataAvailable),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Table(
|
||||||
|
columnWidths: {
|
||||||
|
0: FlexColumnWidth(2.5),
|
||||||
|
},
|
||||||
|
children: fullDataWeekly(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getMonthlyStepsDetails() {
|
||||||
|
return Container(
|
||||||
|
child: Text("Monthly"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getYearlyStepsDetails() {
|
||||||
|
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).avgSteps, style: TextStyle(fontSize: 18.0)),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(bottom: 10.0),
|
||||||
|
child: Text(yearlyStatsAvgValue.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>[
|
||||||
|
yearlyStepsList.isEmpty
|
||||||
|
? Container(
|
||||||
|
child: Center(
|
||||||
|
child: Text(TranslationBase.of(context).noDataAvailable),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Table(
|
||||||
|
columnWidths: {
|
||||||
|
0: FlexColumnWidth(2.5),
|
||||||
|
},
|
||||||
|
children: fullData(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TableRow> fullData(BuildContext context) {
|
||||||
|
List<TableRow> tableRow = [];
|
||||||
|
tableRow.add(
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
Utils.tableColumnTitle(TranslationBase.of(context).date),
|
||||||
|
Utils.tableColumnTitle(TranslationBase.of(context).steps),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
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.toString(), isCapitable: false, mProjectViewModel: projectViewModel),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return tableRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TableRow> fullDataWeekly(BuildContext context) {
|
||||||
|
List<TableRow> tableRow = [];
|
||||||
|
tableRow.add(
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
Utils.tableColumnTitle(TranslationBase.of(context).date),
|
||||||
|
Utils.tableColumnTitle(TranslationBase.of(context).steps),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
weekyStepsList.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,249 +0,0 @@
|
|||||||
import 'package:charts_flutter/flutter.dart' as charts;
|
|
||||||
import 'package:diplomaticquarterapp/models/SmartWatch/YearlyStepsResModel.dart';
|
|
||||||
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
|
||||||
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
||||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
||||||
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
|
|
||||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class StepsTracker extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
_StepsTrackerState createState() => _StepsTrackerState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _StepsTrackerState extends State<StepsTracker>
|
|
||||||
with SingleTickerProviderStateMixin {
|
|
||||||
TabController _tabController;
|
|
||||||
|
|
||||||
int weeklyStatsAvgValue = 0;
|
|
||||||
int monthlyStatsAvgValue = 0;
|
|
||||||
int yearlyStatsAvgValue = 0;
|
|
||||||
|
|
||||||
int avgStepsValue = 0;
|
|
||||||
int dataLength = 0;
|
|
||||||
|
|
||||||
List<YearlyStepsResModel> yearlyStepsList = List();
|
|
||||||
|
|
||||||
List<TimeSeriesSales> yearlyTimeSeriesData = [];
|
|
||||||
|
|
||||||
bool isDataLoaded = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
_tabController = new TabController(length: 3, vsync: this);
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
getYearlyStepsData();
|
|
||||||
});
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AppScaffold(
|
|
||||||
isShowAppBar: true,
|
|
||||||
appBarTitle: "Steps",
|
|
||||||
isShowDecPage: false,
|
|
||||||
body: Container(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
TabBar(
|
|
||||||
tabs: [
|
|
||||||
Tab(text: TranslationBase.of(context).weekly),
|
|
||||||
Tab(text: TranslationBase.of(context).monthly),
|
|
||||||
Tab(text: TranslationBase.of(context).yearly),
|
|
||||||
],
|
|
||||||
controller: _tabController,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: new TabBarView(
|
|
||||||
physics: NeverScrollableScrollPhysics(),
|
|
||||||
children: [
|
|
||||||
isDataLoaded ? getWeeklyStepsDetails() : Container(),
|
|
||||||
isDataLoaded ? getMonthlyStepsDetails() : Container(),
|
|
||||||
isDataLoaded ? getYearlyStepsDetails() : Container()
|
|
||||||
],
|
|
||||||
controller: _tabController,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getYearlyStepsData() {
|
|
||||||
avgStepsValue = 0;
|
|
||||||
dataLength = 0;
|
|
||||||
|
|
||||||
DoctorsListService service = new DoctorsListService();
|
|
||||||
GifLoaderDialogUtils.showMyDialog(context);
|
|
||||||
service.getPatientHealthDataStats(6, 3, context).then((res) {
|
|
||||||
GifLoaderDialogUtils.hideDialog(context);
|
|
||||||
print(res['Med_GetYearStepsTransactionsStsList']);
|
|
||||||
yearlyStepsList.clear();
|
|
||||||
res['Med_GetYearStepsTransactionsStsList'].forEach((element) {
|
|
||||||
print('in forEach');
|
|
||||||
yearlyStepsList.add(new YearlyStepsResModel.fromJson(element));
|
|
||||||
if (element['ValueSum'] != null) {
|
|
||||||
double value = element['ValueSum'];
|
|
||||||
avgStepsValue += value.toInt();
|
|
||||||
dataLength++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
print("innnnnnnnnnnnnnnnn");
|
|
||||||
print(avgStepsValue);
|
|
||||||
print(dataLength);
|
|
||||||
setState(() {
|
|
||||||
yearlyStatsAvgValue = avgStepsValue ~/ dataLength;
|
|
||||||
isDataLoaded = true;
|
|
||||||
});
|
|
||||||
}).catchError((err) {
|
|
||||||
GifLoaderDialogUtils.hideDialog(context);
|
|
||||||
// AppToast.showErrorToast(message: err);
|
|
||||||
print(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
generateData() {
|
|
||||||
if (yearlyStepsList.length > 0) {
|
|
||||||
yearlyTimeSeriesData.clear();
|
|
||||||
yearlyStepsList.forEach(
|
|
||||||
(element) {
|
|
||||||
yearlyTimeSeriesData.add(
|
|
||||||
TimeSeriesSales(
|
|
||||||
new DateTime(element.year, element.month, 1),
|
|
||||||
element.valueSum != null ? element.valueSum.toInt() : 0,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
yearlyTimeSeriesData.forEach((element) {
|
|
||||||
print(element.sales);
|
|
||||||
print(element.time);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
new charts.Series<TimeSeriesSales, DateTime>(
|
|
||||||
id: 'Sales',
|
|
||||||
colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault,
|
|
||||||
domainFn: (TimeSeriesSales sales, _) => sales.time,
|
|
||||||
measureFn: (TimeSeriesSales sales, _) => sales.sales,
|
|
||||||
data: yearlyTimeSeriesData,
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
getWeeklyStepsDetails() {
|
|
||||||
return Container(
|
|
||||||
child: Text("Weekly"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getMonthlyStepsDetails() {
|
|
||||||
return Container(
|
|
||||||
child: Text("Monthly"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getYearlyStepsDetails() {
|
|
||||||
return Container(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
child: AppTimeSeriesChart(
|
|
||||||
seriesList: generateData(),
|
|
||||||
chartName: "Steps",
|
|
||||||
startDate: DateTime(
|
|
||||||
yearlyStepsList[0].year, yearlyStepsList[0].month, 1),
|
|
||||||
endDate: DateTime(
|
|
||||||
yearlyStepsList[yearlyStepsList.length - 1].year,
|
|
||||||
yearlyStepsList[yearlyStepsList.length - 1].month,
|
|
||||||
1),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(top: 5.0),
|
|
||||||
child: Card(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
side: BorderSide(color: Colors.grey[400], width: 0.6)),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 15.0),
|
|
||||||
child:
|
|
||||||
Text("Average Steps", style: TextStyle(fontSize: 18.0)),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(bottom: 10.0),
|
|
||||||
child: Text(yearlyStatsAvgValue.toString() + " Steps",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20.0, fontWeight: FontWeight.bold)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.all(10.0),
|
|
||||||
child: Divider(
|
|
||||||
color: Colors.grey[500],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
transform: Matrix4.translationValues(0.0, -10.0, 0.0),
|
|
||||||
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 5.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text("History", style: TextStyle(fontSize: 14.0)),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text("view more", style: TextStyle(fontSize: 14.0)),
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(left: 3.0, right: 3.0),
|
|
||||||
transform: Matrix4.translationValues(0.0, 1.5, 0.0),
|
|
||||||
width: 30.0,
|
|
||||||
height: 30.0,
|
|
||||||
child: Image.asset(
|
|
||||||
"assets/images/new-design/view_more.png",
|
|
||||||
fit: BoxFit.contain),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 5.0),
|
|
||||||
child: Card(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
side: BorderSide(color: Colors.grey[400], width: 0.6)),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.fromLTRB(30.0, 15.0, 30.0, 15.0),
|
|
||||||
child: Text("Date",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18.0, fontWeight: FontWeight.bold)),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.fromLTRB(30.0, 0.0, 30.0, 0.0),
|
|
||||||
child: Text("Steps", style: TextStyle(fontSize: 18.0)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue