forked from eatvio/eatvio_app
Added body mass index chart to the carousel
This commit is contained in:
@@ -102,8 +102,7 @@ class AuthScreen extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Ошибка'),
|
||||
content:
|
||||
Text(dotenv.env['SERVER_ROOT']! + '/login'),
|
||||
content: Text('wrong_credentials'.tr),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/exit_button.dart';
|
||||
import 'package:eatvio_app/widgets/next_step_button.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
@@ -39,7 +40,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
SizedBox(height: 15.v),
|
||||
_buildSettings(context),
|
||||
SizedBox(height: 30.v),
|
||||
_buildChart(
|
||||
/*_buildChart(
|
||||
context,
|
||||
state.chartPoints?.values
|
||||
.map<int>((e) => e['weight'])
|
||||
@@ -49,7 +50,59 @@ class MyProfileScreen extends StatelessWidget {
|
||||
[0.0, 0.0, 0.0, 0.0],
|
||||
state.chartPoints?.values
|
||||
.map<String>((e) => e['created_at'])
|
||||
.toList()),
|
||||
.toList()),*/
|
||||
CarouselSlider(
|
||||
options: CarouselOptions(height: 370.0),
|
||||
items: [1, 2, 3].map((chartType) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
switch (chartType) {
|
||||
case 1: // График веса
|
||||
return Container(
|
||||
decoration:
|
||||
BoxDecoration(color: Colors.white),
|
||||
child: _buildChart(
|
||||
context,
|
||||
state.chartPoints?.values
|
||||
.map<int>((e) => e['weight'])
|
||||
.toList()
|
||||
.map((i) => i.toDouble())
|
||||
.toList() ??
|
||||
[0.0, 0.0, 0.0, 0.0],
|
||||
state.chartPoints?.values
|
||||
.map<String>((e) => e['created_at'])
|
||||
.toList()),
|
||||
);
|
||||
case 2: // График ИМТ
|
||||
return Container(
|
||||
decoration:
|
||||
BoxDecoration(color: Colors.white),
|
||||
child: _buildChart(
|
||||
context,
|
||||
_bodyMassIndex(
|
||||
state.chartPoints!.values
|
||||
.map<int>((e) => e['weight'])
|
||||
.toList()
|
||||
.map((i) => i.toDouble())
|
||||
.toList(),
|
||||
state.userDetails!['height']
|
||||
.toInt()) ??
|
||||
[0.0, 0.0, 0.0, 0.0],
|
||||
state.chartPoints?.values
|
||||
.map<String>((e) => e['created_at'])
|
||||
.toList()),
|
||||
);
|
||||
case 3:
|
||||
return Text('text',
|
||||
style: TextStyle(fontSize: 16.0));
|
||||
default:
|
||||
return Text('text',
|
||||
style: TextStyle(fontSize: 16.0));
|
||||
}
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
SizedBox(height: 15.v),
|
||||
_buildWidget(context),
|
||||
SizedBox(height: 5.v),
|
||||
@@ -454,4 +507,13 @@ class MyProfileScreen extends StatelessWidget {
|
||||
]))
|
||||
]));
|
||||
}
|
||||
|
||||
List<double> _bodyMassIndex(List<double> weightPoints, int height) {
|
||||
List<double> bmiList = [];
|
||||
for (double weight in weightPoints) {
|
||||
double bmi = weight / ((height / 100) * (height / 100));
|
||||
bmiList.add(bmi);
|
||||
}
|
||||
return bmiList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user