You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/pages/medical/my_trackers/Weight/WeightYeaPage.dart

183 lines
6.4 KiB
Dart

4 years ago
import 'package:diplomaticquarterapp/core/model/my_trakers/blood_pressur/BloodPressureResult.dart';
import 'package:diplomaticquarterapp/core/model/my_trakers/blood_sugar/DiabtecPatientResult.dart';
import 'package:diplomaticquarterapp/core/model/my_trakers/chartData/WeekChartDate.dart';
import 'package:diplomaticquarterapp/core/model/my_trakers/weight/WeightMeasurementResult.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/weight_pressure_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/medical/my_trackers/widget/LineChartCurved.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
4 years ago
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
4 years ago
class WeightYearPage extends StatelessWidget {
final WeightPressureViewModel model;
4 years ago
const WeightYearPage({Key key, this.model, })
4 years ago
: super(key: key);
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
4 years ago
return AppScaffold(
body: model.weightYearTimeSeriesData.isEmpty ? Container(child: Center(child: Texts(TranslationBase.of(context).noDataAvailable),),) : ListView(
4 years ago
children: [
Container(
width: double.maxFinite,
color: Colors.white,
child: LineChartCurved(
horizontalInterval: 2.0,
title: TranslationBase.of(context).weight,
timeSeries: model.weightYearTimeSeriesData,
indexes: model.weightYearTimeSeriesData.length ~/ 5.5,
)
4 years ago
),
SizedBox(
height: 12,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Texts(TranslationBase.of(context).details),
4 years ago
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Table(
border: TableBorder.symmetric(
inside: BorderSide(width: 2.0, color: Colors.grey[300]),
),
children: fullData(context, projectViewModel, model),
4 years ago
),
],
),
)
],
),
);
}
List<TableRow> fullData(BuildContext context,
ProjectViewModel projectViewModel, WeightPressureViewModel model) {
4 years ago
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
4 years ago
borderRadius: BorderRadius.only(
topLeft: projectViewModel.isArabic
? Radius.circular(0.0)
: Radius.circular(10.0),
topRight: projectViewModel.isArabic
? Radius.circular(10.0)
: Radius.circular(0.0),
4 years ago
),
),
child: Center(
child: Texts(
TranslationBase.of(context).date,
4 years ago
color: Colors.white,
fontSize: 15,
),
),
height: 40,
),
Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
4 years ago
),
child: Center(
4 years ago
child: Texts(
TranslationBase.of(context).time,
4 years ago
color: Colors.white,
fontSize: 15,
),
4 years ago
),
height: 40),
Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.only(
topLeft: projectViewModel.isArabic
? Radius.circular(10.0)
: Radius.circular(0.0),
topRight: projectViewModel.isArabic
? Radius.circular(0.0)
: Radius.circular(10.0),
),
4 years ago
),
child: Center(
4 years ago
child: Texts(
TranslationBase.of(context).value,
4 years ago
color: Colors.white,
fontSize: 15,
),
4 years ago
),
height: 40),
],
),
);
model.yearWeightMeasurementResult.forEach(
(diabtec) {
4 years ago
tableRow.add(
TableRow(
children: [
Container(
child: Container(
height: 70,
padding: EdgeInsets.all(10),
color: Colors.white,
child: Center(
child: Texts(
'${projectViewModel.isArabic ? DateUtil.getMonthDayYearDateFormattedAr(diabtec.weightDate) : DateUtil.getMonthDayYearDateFormatted(diabtec.weightDate)} ',
4 years ago
textAlign: TextAlign.center,
fontSize: 12,
),
),
),
),
Container(
height: 70,
padding: EdgeInsets.all(10),
color: Colors.white,
child: Center(
child: Texts(
'${diabtec.weightDate.hour}:${diabtec.weightDate.minute}',
textAlign: TextAlign.center,
fontSize: 12,
),
),
),
Container(
child: Container(
height: 70,
padding: EdgeInsets.all(10),
color: Colors.white,
child: Center(
child: Texts(
'${diabtec.weightMeasured}',
textAlign: TextAlign.center,
fontSize: 12,
),
),
),
),
],
),
);
},
);
return tableRow;
}
}