Working on Health data

merge-update-with-lab-changes
haroon amjad 4 years ago
parent 2062b96652
commit 2032053cb7

@ -1578,4 +1578,7 @@ const Map localizedValues = {
"medicalFileSubtitle": {"en": "Details", "ar": "ملفي الطبي"},
"healthConvertersTitle": {"en": "Health", "ar": "تحويل"},
"healthConvertersSubtitle": {"en": "Converters", "ar": "القياسات"},
"syncHealthData": { "en": "Sync Health Data", "ar": "مزامنة البيانات الصحية" },
"steps": { "en": "Steps", "ar": "الخطوات" },
"avgSteps": { "en": "Average Steps", "ar": "متوسط الخطوات" },
};

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

@ -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;
}
}

@ -1,5 +1,5 @@
class YearlyStepsResModel {
double valueSum;
num valueSum;
int medCategoryID;
int month;
String monthName;
@ -21,6 +21,7 @@ class YearlyStepsResModel {
monthName = json['MonthName'];
patientID = json['PatientID'];
year = json['Year'];
valueSum = valueSum != null ? valueSum.toInt() : valueSum;
}
Map<String, dynamic> toJson() {

@ -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,6 +1,9 @@
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/stepsTracker.dart';
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/Steps/stepsTracker.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';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
// import 'package:fit_kit/fit_kit.dart';
import 'package:flutter/material.dart';
@ -10,7 +13,6 @@ class HealthDataList extends StatefulWidget {
}
class _HealthDataListState extends State<HealthDataList> {
// List<DataType> dataTypes = List();
@override
@ -27,191 +29,134 @@ class _HealthDataListState extends State<HealthDataList> {
@override
Widget build(BuildContext context) {
return AppScaffold(
appBarTitle: "Smartwatches",
isShowAppBar: true,
body: Container(
height: MediaQuery
.of(context)
.size
.height,
margin: EdgeInsets.all(20.0),
child: SingleChildScrollView(
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)),
),
],
),
Divider(
color: Colors.grey[500],
),
Row(
children: [
Container(
child: Image.asset(
"assets/images/SmartWatches/sleep_data.png",
width: 60.0,
height: 60.0),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text("Sleep Data",
style: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
Divider(
color: Colors.grey[500],
),
InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: StepsTracker(),
),
);
},
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("Steps",
style: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
appBarTitle: TranslationBase.of(context).smartWatches,
isShowAppBar: true,
showNewAppBar: true,
showNewAppBarTitle: true,
body: Container(
height: MediaQuery.of(context).size.height,
margin: EdgeInsets.all(20.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
),
),
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)),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text("Heart Rate", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
Divider(
color: Colors.grey[500],
),
Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/sleep_data.png", width: 60.0, height: 60.0),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Text("Sleep Data", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
Divider(
color: Colors.grey[500],
),
InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: StepsTracker(),
),
],
),
Divider(
color: Colors.grey[500],
),
Row(
);
},
child: Row(
children: [
Container(
child: Image.asset(
"assets/images/SmartWatches/heartrate_icon.png",
width: 60.0,
height: 60.0),
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)),
child: Text("Steps", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
],
),
Divider(
color: Colors.grey[500],
),
],
),
),
),
bottomSheet: Container(
width: double.infinity,
height: MediaQuery
.of(context)
.size
.height * 0.1,
color: Colors.grey[100],
child: Column(
children: <Widget>[
),
Divider(
color: Colors.transparent,
color: Colors.grey[500],
),
InkWell(
onTap: () {
print("ReadLast");
// readLast();
},
child:Container(
height: (MediaQuery
.of(context)
.size
.height/2)*0.12,
width: MediaQuery
.of(context)
.size
.width * 0.8,
decoration: BoxDecoration(
color: Colors.grey[800],
borderRadius: BorderRadius.circular(6.0),
Row(
children: [
Container(
child: Image.asset("assets/images/SmartWatches/heartrate_icon.png", width: 60.0, height: 60.0),
),
child: Container(
padding: EdgeInsets.only(top: 10.0),
child: Text(
'Sync Health Data' , textAlign: TextAlign.center,style: TextStyle(
color: Colors.white , fontSize: 18.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)),
),
],
),
Divider(
color: Colors.grey[500],
),
],
),
));
),
),
bottomSheet: Container(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: DefaultButton(TranslationBase.of(context).syncHealthData, () {
print("ReadLast");
// readLast();
}),
),
),
);
}
// void readLast() async {
// print("ReadLast");
// final result = await FitKit.readLast(DataType.DISTANCE);
// print(result);
// print(result);
// }
//
// void readAll() async {
// if (await FitKit.requestPermissions(dataTypes)) {
// for (DataType type in dataTypes) {
// final results = await FitKit.read(
// type,
// dateFrom: DateTime.now().subtract(Duration(days: 7)),
// dateTo: DateTime.now(),
// limit: 100,
// );
// print(results);
// print(results.length);
// }
// readLast();
// }
// }
}
// void readLast() async {
// print("ReadLast");
// final result = await FitKit.readLast(DataType.DISTANCE);
// print(result);
// print(result);
// }
//
// void readAll() async {
// if (await FitKit.requestPermissions(dataTypes)) {
// for (DataType type in dataTypes) {
// final results = await FitKit.read(
// type,
// dateFrom: DateTime.now().subtract(Duration(days: 7)),
// dateTo: DateTime.now(),
// limit: 100,
// );
// print(results);
// print(results.length);
// }
// readLast();
// }
// }
}

@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/services/smartwatch_integration/SmartWatchI
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
@ -37,9 +38,11 @@ class _SmartWatchInstructionsState extends State<SmartWatchInstructions> {
@override
Widget build(BuildContext context) {
return AppScaffold(
appBarTitle: "Sync Health Data",
appBarTitle: TranslationBase.of(context).smartWatches,
isShowAppBar: true,
isShowDecPage: true,
showNewAppBar: true,
showNewAppBarTitle: true,
description: TranslationBase.of(context).infoHealthData,
imagesInfo: [
ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/health-data/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/health-data/ar/0.png'),
@ -56,9 +59,10 @@ class _SmartWatchInstructionsState extends State<SmartWatchInstructions> {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Container(
margin: EdgeInsets.only(top: 10.0),
Flexible(
// margin: EdgeInsets.only(top: 10.0),
child: CarouselSlider(
carouselController: buttonCarouselController,
options: CarouselOptions(
@ -85,8 +89,7 @@ class _SmartWatchInstructionsState extends State<SmartWatchInstructions> {
child: Text("Supported Smartwatches",
style: TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
fontFamily: "WorkSans")),
fontWeight: FontWeight.bold)),
),
Container(
child: Row(
@ -371,7 +374,7 @@ class _SmartWatchInstructionsState extends State<SmartWatchInstructions> {
),
Container(
margin: EdgeInsets.fromLTRB(
15.0, 110.0, 15.0, 15.0),
15.0, 80.0, 15.0, 15.0),
child: ButtonTheme(
shape: RoundedRectangleBorder(
borderRadius:
@ -854,6 +857,10 @@ class _SmartWatchInstructionsState extends State<SmartWatchInstructions> {
_openHealthDataList() {
Navigator.push(
context, MaterialPageRoute(builder: (context) => HealthDataList()));
context,
FadePage(
page: HealthDataList(),
),
);
}
}

@ -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)),
),
],
),
),
),
],
),
);
}
}

@ -2518,6 +2518,12 @@ class TranslationBase {
String get healthConvertersTitle => localizedValues["healthConvertersTitle"][locale.languageCode];
String get healthConvertersSubtitle => localizedValues["healthConvertersSubtitle"][locale.languageCode];
String get syncHealthData => localizedValues["syncHealthData"][locale.languageCode];
String get steps => localizedValues["steps"][locale.languageCode];
String get avgSteps => localizedValues["avgSteps"][locale.languageCode];
}
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

Loading…
Cancel
Save