forked from eatvio/eatvio_app
refactor: profile model
This commit is contained in:
@@ -1,114 +1,114 @@
|
||||
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||
import 'package:eatvio_app/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class ImtChartWidget extends StatelessWidget {
|
||||
final List<ChartPointModel> chartPoints;
|
||||
|
||||
const ImtChartWidget({
|
||||
super.key,
|
||||
required this.chartPoints,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'${chartPoints.last.bmi.toStringAsFixed(2)}',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
chartPoints.last.bmi > chartPoints[chartPoints.length - 2].bmi
|
||||
? Icon(
|
||||
Icons.arrow_drop_up,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
)
|
||||
: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SfCartesianChart(
|
||||
margin: EdgeInsets.symmetric(horizontal: 8),
|
||||
enableAxisAnimation: true,
|
||||
plotAreaBorderWidth: 0,
|
||||
trackballBehavior: TrackballBehavior(
|
||||
enable: true,
|
||||
activationMode: ActivationMode.singleTap,
|
||||
tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
|
||||
tooltipSettings: InteractiveTooltip(),
|
||||
lineType: TrackballLineType.vertical,
|
||||
),
|
||||
primaryXAxis: DateTimeCategoryAxis(
|
||||
initialVisibleMinimum: chartPoints.first.createdAt,
|
||||
initialVisibleMaximum: chartPoints.last.createdAt,
|
||||
tickPosition: TickPosition.inside,
|
||||
majorTickLines: MajorTickLines(
|
||||
size: 0,
|
||||
),
|
||||
edgeLabelPlacement: EdgeLabelPlacement.shift,
|
||||
dateFormat: DateFormat.MMMd('ru'),
|
||||
labelStyle: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
|
||||
axisLine: AxisLine(
|
||||
color: Colors.grey.withOpacity(0.3),
|
||||
width: 0.4,
|
||||
),
|
||||
),
|
||||
primaryYAxis: NumericAxis(
|
||||
isVisible: false,
|
||||
),
|
||||
series: _getSplineSeries(),
|
||||
tooltipBehavior: TooltipBehavior(enable: true),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<CartesianSeries<ChartPointModel, DateTime>> _getSplineSeries() {
|
||||
return <CartesianSeries<ChartPointModel, DateTime>>[
|
||||
SplineAreaSeries<ChartPointModel, DateTime>(
|
||||
markerSettings: MarkerSettings(
|
||||
isVisible: true,
|
||||
color: appTheme.blueA400,
|
||||
height: 8,
|
||||
width: 8,
|
||||
),
|
||||
dataLabelSettings: DataLabelSettings(
|
||||
labelAlignment: ChartDataLabelAlignment.top,
|
||||
isVisible: true,
|
||||
),
|
||||
dataSource: chartPoints,
|
||||
borderColor: appTheme.blueA400,
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
appTheme.blueA400.withOpacity(0.14),
|
||||
Colors.transparent,
|
||||
],
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment(0, 0.6),
|
||||
),
|
||||
name: 'ИМТ',
|
||||
xValueMapper: (ChartPointModel value, int index) => value.createdAt,
|
||||
yValueMapper: (ChartPointModel value, int index) => double.parse(value.bmi.toStringAsFixed(2)),
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
// import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||
// import 'package:eatvio_app/theme/theme_helper.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
// import 'package:intl/intl.dart';
|
||||
//
|
||||
// class ImtChartWidget extends StatelessWidget {
|
||||
// final List<ChartPointModel> chartPoints;
|
||||
//
|
||||
// const ImtChartWidget({
|
||||
// super.key,
|
||||
// required this.chartPoints,
|
||||
// });
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Text(
|
||||
// '${chartPoints.last.bmi.toStringAsFixed(2)}',
|
||||
// style: TextStyle(
|
||||
// color: Colors.black,
|
||||
// fontSize: 40,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// ),
|
||||
// ),
|
||||
// chartPoints.last.bmi > chartPoints[chartPoints.length - 2].bmi
|
||||
// ? Icon(
|
||||
// Icons.arrow_drop_up,
|
||||
// size: 40,
|
||||
// color: Colors.grey,
|
||||
// )
|
||||
// : Icon(
|
||||
// Icons.arrow_drop_down,
|
||||
// size: 40,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// SfCartesianChart(
|
||||
// margin: EdgeInsets.symmetric(horizontal: 8),
|
||||
// enableAxisAnimation: true,
|
||||
// plotAreaBorderWidth: 0,
|
||||
// trackballBehavior: TrackballBehavior(
|
||||
// enable: true,
|
||||
// activationMode: ActivationMode.singleTap,
|
||||
// tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
|
||||
// tooltipSettings: InteractiveTooltip(),
|
||||
// lineType: TrackballLineType.vertical,
|
||||
// ),
|
||||
// primaryXAxis: DateTimeCategoryAxis(
|
||||
// initialVisibleMinimum: chartPoints.first.createdAt,
|
||||
// initialVisibleMaximum: chartPoints.last.createdAt,
|
||||
// tickPosition: TickPosition.inside,
|
||||
// majorTickLines: MajorTickLines(
|
||||
// size: 0,
|
||||
// ),
|
||||
// edgeLabelPlacement: EdgeLabelPlacement.shift,
|
||||
// dateFormat: DateFormat.MMMd('ru'),
|
||||
// labelStyle: TextStyle(
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
|
||||
// axisLine: AxisLine(
|
||||
// color: Colors.grey.withOpacity(0.3),
|
||||
// width: 0.4,
|
||||
// ),
|
||||
// ),
|
||||
// primaryYAxis: NumericAxis(
|
||||
// isVisible: false,
|
||||
// ),
|
||||
// series: _getSplineSeries(),
|
||||
// tooltipBehavior: TooltipBehavior(enable: true),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// List<CartesianSeries<ChartPointModel, DateTime>> _getSplineSeries() {
|
||||
// return <CartesianSeries<ChartPointModel, DateTime>>[
|
||||
// SplineAreaSeries<ChartPointModel, DateTime>(
|
||||
// markerSettings: MarkerSettings(
|
||||
// isVisible: true,
|
||||
// color: appTheme.blueA400,
|
||||
// height: 8,
|
||||
// width: 8,
|
||||
// ),
|
||||
// dataLabelSettings: DataLabelSettings(
|
||||
// labelAlignment: ChartDataLabelAlignment.top,
|
||||
// isVisible: true,
|
||||
// ),
|
||||
// dataSource: chartPoints,
|
||||
// borderColor: appTheme.blueA400,
|
||||
// gradient: LinearGradient(
|
||||
// colors: [
|
||||
// appTheme.blueA400.withOpacity(0.14),
|
||||
// Colors.transparent,
|
||||
// ],
|
||||
// begin: Alignment.topCenter,
|
||||
// end: Alignment(0, 0.6),
|
||||
// ),
|
||||
// name: 'ИМТ',
|
||||
// xValueMapper: (ChartPointModel value, int index) => value.createdAt,
|
||||
// yValueMapper: (ChartPointModel value, int index) => double.parse(value.bmi.toStringAsFixed(2)),
|
||||
// ),
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user