Commit 73fe2db2c4ef71894075e135d3d3ef603df0dafd

Authored by 常守达
1 parent 7a4cb72f

fix(today):健身卡片单位

@@ -115,12 +115,33 @@ class TodayActivityCard extends StatelessWidget { @@ -115,12 +115,33 @@ class TodayActivityCard extends StatelessWidget {
115 var activityStr = (activity > 0 && (activityTarget?.move ?? 0) > 0) 115 var activityStr = (activity > 0 && (activityTarget?.move ?? 0) > 0)
116 ? '$activity' 116 ? '$activity'
117 : '--'; 117 : '--';
118 - var exerciseStr = (exercise > 0 && (activityTarget?.exercise ?? 0) > 0)  
119 - ? '${exercise % 60}'  
120 - : '--';  
121 - var standStr = (stand > 0 && (activityTarget?.stand ?? 0) > 0)  
122 - ? '${stand ~/ 3600}'  
123 - : '--'; 118 + // exercise 单位为秒,转换为小时+分钟
  119 + List<_MetricValueSpan> exerciseSpans;
  120 + if (exercise > 0 && (activityTarget?.exercise ?? 0) > 0) {
  121 + final exHours = exercise ~/ 3600;
  122 + final exMinutes = (exercise % 3600) ~/ 60;
  123 + exerciseSpans = [
  124 + if (exHours > 0) _MetricValueSpan('$exHours', '小时'),
  125 + if (exMinutes > 0 || exHours == 0)
  126 + _MetricValueSpan(exMinutes > 0 ? '$exMinutes' : '0', '分钟'),
  127 + ];
  128 + } else {
  129 + exerciseSpans = [_MetricValueSpan('--', '分钟')];
  130 + }
  131 +
  132 + // stand 单位为秒,转换为小时+分钟
  133 + List<_MetricValueSpan> standSpans;
  134 + if (stand > 0 && (activityTarget?.stand ?? 0) > 0) {
  135 + final stHours = stand ~/ 3600;
  136 + final stMinutes = (stand % 3600) ~/ 60;
  137 + standSpans = [
  138 + if (stHours > 0) _MetricValueSpan('$stHours', '小时'),
  139 + if (stMinutes > 0 || stHours == 0)
  140 + _MetricValueSpan(stMinutes > 0 ? '$stMinutes' : '0', '分钟'),
  141 + ];
  142 + } else {
  143 + standSpans = [_MetricValueSpan('--', '小时')];
  144 + }
124 double activityProgress = 145 double activityProgress =
125 (activity > 0 && (activityTarget?.move ?? 0) > 0) 146 (activity > 0 && (activityTarget?.move ?? 0) > 0)
126 ? (activity / (activityTarget?.move ?? 0)) * 360 147 ? (activity / (activityTarget?.move ?? 0)) * 360
@@ -149,19 +170,12 @@ class TodayActivityCard extends StatelessWidget { @@ -149,19 +170,12 @@ class TodayActivityCard extends StatelessWidget {
149 _MetricData( 170 _MetricData(
150 label: context.l10n.exercise, 171 label: context.l10n.exercise,
151 labelColor: context.colors.chartGreen, 172 labelColor: context.colors.chartGreen,
152 - valueSpans: [  
153 - _MetricValueSpan(  
154 - exerciseStr,  
155 - '分钟',  
156 - ),  
157 - ], 173 + valueSpans: exerciseSpans,
158 ), 174 ),
159 _MetricData( 175 _MetricData(
160 label: context.l10n.standing, 176 label: context.l10n.standing,
161 labelColor: const Color(0xFF7B9BFB), 177 labelColor: const Color(0xFF7B9BFB),
162 - valueSpans: [  
163 - _MetricValueSpan(standStr, '小时'),  
164 - ], 178 + valueSpans: standSpans,
165 ), 179 ),
166 ], 180 ],
167 rightWidget: Container( 181 rightWidget: Container(