feat:更新UI布局
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:fitnote/config/app_config.dart';
|
||||
import 'package:fitnote/models/health.dart';
|
||||
import 'package:fitnote/provider/health_provider.dart';
|
||||
import 'package:fitnote/service/health_service.dart';
|
||||
@@ -19,11 +20,6 @@ class GoalProgress extends StatefulWidget {
|
||||
class _GoalProgressState extends State<GoalProgress> {
|
||||
final HealthService service = HealthService();
|
||||
|
||||
final int initWeight = 72;
|
||||
final int goalWeight = 70;
|
||||
final int goalTotalSpot = 600;
|
||||
final int goalAvgSleep = 8;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -55,27 +51,35 @@ class _GoalProgressState extends State<GoalProgress> {
|
||||
_buildProgressItem(
|
||||
title: '目标体重',
|
||||
current: provider.latestWeight.toString(),
|
||||
target: goalWeight.toString(),
|
||||
target: AppConfig.goalWeight.toString(),
|
||||
unit: 'kg',
|
||||
progress: calWeightProgress(provider.latestWeight, goalWeight, initWeight),
|
||||
progress: calWeightProgress(
|
||||
provider.latestWeight,
|
||||
AppConfig.goalWeight,
|
||||
AppConfig.initWeight,
|
||||
),
|
||||
color: RecordType.weight.color,
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
_buildProgressItem(
|
||||
title: '运动总时长',
|
||||
current: provider.totalSpot.toString(),
|
||||
target: goalTotalSpot.toString(),
|
||||
target: AppConfig.goalTotalSpot.toString(),
|
||||
unit: '分钟',
|
||||
progress: formatProgress(provider.totalSpot / goalTotalSpot),
|
||||
progress: formatProgress(
|
||||
provider.totalSpot / AppConfig.goalTotalSpot,
|
||||
),
|
||||
color: RecordType.sport.color,
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
_buildProgressItem(
|
||||
title: '日均睡眠',
|
||||
current: provider.avgSleep.toString(),
|
||||
target: goalAvgSleep.toString(),
|
||||
target: AppConfig.goalAvgSleep.toString(),
|
||||
unit: '小时',
|
||||
progress: formatProgress(provider.avgSleep / goalAvgSleep),
|
||||
progress: formatProgress(
|
||||
provider.avgSleep / AppConfig.goalAvgSleep,
|
||||
),
|
||||
color: RecordType.sleep.color,
|
||||
),
|
||||
],
|
||||
@@ -111,7 +115,7 @@ class _GoalProgressState extends State<GoalProgress> {
|
||||
percentage: progress,
|
||||
progressBarColor: color,
|
||||
child: Text(
|
||||
'${progress * 100}%',
|
||||
'${roundNum(progress * 100)}%',
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user