feat:增加变化提醒功能

This commit is contained in:
2025-12-03 14:28:39 +08:00
parent e672442d6a
commit 8d23f06f74
10 changed files with 194 additions and 68 deletions

View File

@@ -7,7 +7,6 @@ import 'package:fitnote/widget/record/common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_common/widget/common_widget.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:getwidget/getwidget.dart';
import 'package:provider/provider.dart';
class GoalProgress extends StatefulWidget {
@@ -48,11 +47,11 @@ class _GoalProgressState extends State<GoalProgress> {
icon: FontAwesomeIcons.trophy,
),
const SizedBox(height: 28),
_buildProgressItem(
buildProgressItem(
title: '目标体重',
current: provider.latestWeight.toString(),
target: AppConfig.goalWeight.toString(),
unit: 'kg',
unit: RecordType.weight.unit,
progress: calWeightProgress(
provider.latestWeight,
AppConfig.goalWeight,
@@ -61,22 +60,22 @@ class _GoalProgressState extends State<GoalProgress> {
color: RecordType.weight.color,
),
const SizedBox(height: 28),
_buildProgressItem(
buildProgressItem(
title: '运动总时长',
current: provider.totalSpot.toString(),
target: AppConfig.goalTotalSpot.toString(),
unit: '分钟',
unit: RecordType.sport.unit,
progress: formatProgress(
provider.totalSpot / AppConfig.goalTotalSpot,
),
color: RecordType.sport.color,
),
const SizedBox(height: 28),
_buildProgressItem(
buildProgressItem(
title: '日均睡眠',
current: provider.avgSleep.toString(),
target: AppConfig.goalAvgSleep.toString(),
unit: '小时',
unit: RecordType.sleep.unit,
progress: formatProgress(
provider.avgSleep / AppConfig.goalAvgSleep,
),
@@ -86,41 +85,4 @@ class _GoalProgressState extends State<GoalProgress> {
),
);
}
Widget _buildProgressItem({
required String title,
required String current,
required String target,
required String unit,
required double progress,
required Color color,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(title),
Text(
'$current/$target $unit',
style: TextStyle(fontWeight: FontWeight.w500, color: color),
),
],
),
const SizedBox(height: 8),
GFProgressBar(
animation: true,
lineHeight: 20,
percentage: progress,
progressBarColor: color,
child: Text(
'${roundNum(progress * 100)}%',
textAlign: TextAlign.end,
style: TextStyle(color: Colors.white),
),
),
],
);
}
}