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.
HMG_Patient_App/lib/pages/medical/my_trackers/Weight/WeightWeeklyPage.dart

140 lines
5.4 KiB
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';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.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:charts_flutter/flutter.dart' as charts;
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'AddWeightPage.dart';
class WeightWeeklyPage extends StatelessWidget {
final WeightPressureViewModel model;
const WeightWeeklyPage({Key key, this.model}) : super(key: key);
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return AppScaffold(
isShowDecPage: false,
body: ListView(
children: [
Container(
margin: EdgeInsets.only(top: 12, left: 8, right: 8),
color: Colors.white,
child: LineChartCurved(
horizontalInterval: 1.0,
title: TranslationBase.of(context).weight,
timeSeries: model.weightWeekTimeSeriesData.isEmpty ? [TimeSeriesSales2(DateTime.now(), 0.0)] : model.weightWeekTimeSeriesData,
indexes: model.weightWeekTimeSeriesData.length ~/ 5.5 ?? 0,
),
),
SizedBox(
height: 12,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Texts(TranslationBase.of(context).details),
),
Container(
padding: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
model.weightWeekTimeSeriesData.isEmpty
? Container(
child: Center(
child: Texts(TranslationBase.of(context).noDataAvailable),
),
)
: Table(
columnWidths: {
0: FlexColumnWidth(2.5),
},
children: fullData(context, projectViewModel, model),
),
],
),
)
],
),
);
}
List<TableRow> fullData(BuildContext context, ProjectViewModel projectViewModel, WeightPressureViewModel model) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).date),
Utils.tableColumnTitle(TranslationBase.of(context).time),
Utils.tableColumnTitle(TranslationBase.of(context).measured),
Utils.tableColumnTitle(TranslationBase.of(context).edit),
],
),
);
model.weekWeightMeasurementResult.forEach(
(diabtec) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue('${projectViewModel.isArabic ? DateUtil.getMonthDayYearDateFormattedAr(diabtec.weightDate) : DateUtil.getMonthDayYearDateFormatted(diabtec.weightDate)} ',
isCapitable: false),
Utils.tableColumnValue('${diabtec.weightDate.hour}:${diabtec.weightDate.minute}', isCapitable: false),
Utils.tableColumnValue('${diabtec.weightMeasured}', isCapitable: false),
Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 12),
Container(
child: InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: AddWeightPage(
isUpdate: true,
dayWeightDate: diabtec.weightDate,
measureTimeSelectedType: 'Kg',
weightValue: diabtec.weightMeasured.toString(),
lineItemNo: diabtec.lineItemNo,
weightUnit: int.parse(diabtec.unit),
model: model,
),
),
);
},
child: Container(
// height: 70,
// padding: EdgeInsets.all(10),
child: Icon(
Icons.edit,
color: Color(0xff575757),
),
),
),
),
SizedBox(height: 6),
Divider(
height: 1,
color: Color(0xffEFEFEF),
thickness: 1,
)
]),
],
),
);
},
);
return tableRow;
}
}