96 lines
2.6 KiB
Dart
96 lines
2.6 KiB
Dart
import 'package:fitnote/models/health.dart';
|
|
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';
|
|
|
|
class GoalProgress extends StatefulWidget {
|
|
const GoalProgress({super.key});
|
|
|
|
@override
|
|
State<GoalProgress> createState() => _GoalProgressState();
|
|
}
|
|
|
|
class _GoalProgressState extends State<GoalProgress> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CommonCard(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
buildCardTitle(
|
|
context: context,
|
|
title: '本月目标进度',
|
|
icon: FontAwesomeIcons.trophy,
|
|
),
|
|
const SizedBox(height: 28),
|
|
_buildProgressItem(
|
|
title: '目标体重',
|
|
current: '65.2',
|
|
target: '60',
|
|
unit: 'kg',
|
|
progress: 0.85,
|
|
color: RecordType.weight.color,
|
|
),
|
|
const SizedBox(height: 28),
|
|
_buildProgressItem(
|
|
title: '运动总时长',
|
|
current: '450',
|
|
target: '600',
|
|
unit: '分钟',
|
|
progress: 0.75,
|
|
color: RecordType.sport.color,
|
|
),
|
|
const SizedBox(height: 28),
|
|
_buildProgressItem(
|
|
title: '日均睡眠',
|
|
current: '7.2',
|
|
target: '8',
|
|
unit: '小时',
|
|
progress: 0.9,
|
|
color: RecordType.sleep.color,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
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(
|
|
'${progress * 100}%',
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|