Commit 73fe2db2c4ef71894075e135d3d3ef603df0dafd

Authored by 常守达
1 parent 7a4cb72f

fix(today):健身卡片单位

... ... @@ -115,12 +115,33 @@ class TodayActivityCard extends StatelessWidget {
var activityStr = (activity > 0 && (activityTarget?.move ?? 0) > 0)
? '$activity'
: '--';
var exerciseStr = (exercise > 0 && (activityTarget?.exercise ?? 0) > 0)
? '${exercise % 60}'
: '--';
var standStr = (stand > 0 && (activityTarget?.stand ?? 0) > 0)
? '${stand ~/ 3600}'
: '--';
// exercise 单位为秒,转换为小时+分钟
List<_MetricValueSpan> exerciseSpans;
if (exercise > 0 && (activityTarget?.exercise ?? 0) > 0) {
final exHours = exercise ~/ 3600;
final exMinutes = (exercise % 3600) ~/ 60;
exerciseSpans = [
if (exHours > 0) _MetricValueSpan('$exHours', '小时'),
if (exMinutes > 0 || exHours == 0)
_MetricValueSpan(exMinutes > 0 ? '$exMinutes' : '0', '分钟'),
];
} else {
exerciseSpans = [_MetricValueSpan('--', '分钟')];
}
// stand 单位为秒,转换为小时+分钟
List<_MetricValueSpan> standSpans;
if (stand > 0 && (activityTarget?.stand ?? 0) > 0) {
final stHours = stand ~/ 3600;
final stMinutes = (stand % 3600) ~/ 60;
standSpans = [
if (stHours > 0) _MetricValueSpan('$stHours', '小时'),
if (stMinutes > 0 || stHours == 0)
_MetricValueSpan(stMinutes > 0 ? '$stMinutes' : '0', '分钟'),
];
} else {
standSpans = [_MetricValueSpan('--', '小时')];
}
double activityProgress =
(activity > 0 && (activityTarget?.move ?? 0) > 0)
? (activity / (activityTarget?.move ?? 0)) * 360
... ... @@ -149,19 +170,12 @@ class TodayActivityCard extends StatelessWidget {
_MetricData(
label: context.l10n.exercise,
labelColor: context.colors.chartGreen,
valueSpans: [
_MetricValueSpan(
exerciseStr,
'分钟',
),
],
valueSpans: exerciseSpans,
),
_MetricData(
label: context.l10n.standing,
labelColor: const Color(0xFF7B9BFB),
valueSpans: [
_MetricValueSpan(standStr, '小时'),
],
valueSpans: standSpans,
),
],
rightWidget: Container(
... ...