|
|
|
import 'package:doublefeel_flutter/app/utils/platform_compact.dart';
|
|
|
|
import 'package:doublefeel_flutter/app/modules/interact/widgets/friend_interaction_entry.dart';
|
|
|
|
import 'package:doublefeel_flutter/app/widget/circular_gradient_progress/arc_progress_widget.dart';
|
|
|
|
import 'package:doublefeel_flutter/app/widget/circular_gradient_progress/combine.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/theme/app_theme.dart';
|
|
...
|
...
|
@@ -28,29 +29,31 @@ class TodaySleepCard extends StatelessWidget { |
|
|
|
Color sleepStateColor = sleepDuration == 0
|
|
|
|
? context.colors.textPrimary
|
|
|
|
: healthData?.sleepStateColor(context) ??
|
|
|
|
context.colors.textPrimary;
|
|
|
|
String sleepStateStr =
|
|
|
|
sleepDuration == 0 ? '-' : healthData?.sleepStateStr() ?? '-';
|
|
|
|
context.colors.textPrimary;
|
|
|
|
String sleepStateStr = sleepDuration == 0
|
|
|
|
? '-'
|
|
|
|
: healthData?.sleepStateStr() ?? '-';
|
|
|
|
String sleepAverageHeartRate =
|
|
|
|
(healthData?.hrAvg == null || healthData?.hrAvg == 0)
|
|
|
|
? '-'
|
|
|
|
: '${healthData?.hrAvg}';
|
|
|
|
? '-'
|
|
|
|
: '${healthData?.hrAvg}';
|
|
|
|
double sleepDurationProgress =
|
|
|
|
(activityTarget?.sleepTargetDuration ?? 28800) == 0 ||
|
|
|
|
sleepDuration == 0
|
|
|
|
? -1
|
|
|
|
: ((healthData?.sleepDuration ?? 0) /
|
|
|
|
(activityTarget?.sleepTargetDuration ?? 28800) *
|
|
|
|
360);
|
|
|
|
double sleepScoreProgress =
|
|
|
|
sleepDuration == 0 ? -1 : (healthData?.sleepScore ?? 0.0) * 3.6;
|
|
|
|
sleepDuration == 0
|
|
|
|
? -1
|
|
|
|
: ((healthData?.sleepDuration ?? 0) /
|
|
|
|
(activityTarget?.sleepTargetDuration ?? 28800) *
|
|
|
|
360);
|
|
|
|
double sleepScoreProgress = sleepDuration == 0
|
|
|
|
? -1
|
|
|
|
: (healthData?.sleepScore ?? 0.0) * 3.6;
|
|
|
|
|
|
|
|
double? sleepDurationRatio =
|
|
|
|
(activityTarget?.sleepTargetDuration ?? 28800) == 0 ||
|
|
|
|
sleepDuration == 0
|
|
|
|
? null
|
|
|
|
: ((healthData?.sleepDuration ?? 0) /
|
|
|
|
(activityTarget?.sleepTargetDuration ?? 28800));
|
|
|
|
sleepDuration == 0
|
|
|
|
? null
|
|
|
|
: ((healthData?.sleepDuration ?? 0) /
|
|
|
|
(activityTarget?.sleepTargetDuration ?? 28800));
|
|
|
|
double? sleepScoreRatio = sleepDuration == 0
|
|
|
|
? null
|
|
|
|
: ((healthData?.sleepScore ?? 0.0) / 100.0);
|
|
...
|
...
|
@@ -62,50 +65,51 @@ class TodaySleepCard extends StatelessWidget { |
|
|
|
actionText: l10n.viewSleepReport,
|
|
|
|
metrics: [
|
|
|
|
_MetricBlock(
|
|
|
|
label: l10n.duration,
|
|
|
|
labelColor: context.colors.primary,
|
|
|
|
value: (sleepDuration > 0)
|
|
|
|
? Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
if (sleepHours > 0) ...[
|
|
|
|
TextSpan(text: '$sleepHours'),
|
|
|
|
TextSpan(
|
|
|
|
text: l10n.sleepDailyUnitHour,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textSecondary,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
if (sleepMinutes > 0) ...[
|
|
|
|
TextSpan(text: '$sleepMinutes'),
|
|
|
|
TextSpan(
|
|
|
|
text: l10n.sleepDailyUnitMinute,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textSecondary,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Text(
|
|
|
|
'-',
|
|
|
|
label: l10n.duration,
|
|
|
|
labelColor: context.colors.primary,
|
|
|
|
value: (sleepDuration > 0)
|
|
|
|
? Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
children: [
|
|
|
|
if (sleepHours > 0) ...[
|
|
|
|
TextSpan(text: '$sleepHours'),
|
|
|
|
TextSpan(
|
|
|
|
text: l10n.sleepDailyUnitHour,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textSecondary,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
if (sleepMinutes > 0) ...[
|
|
|
|
TextSpan(text: '$sleepMinutes'),
|
|
|
|
TextSpan(
|
|
|
|
text: l10n.sleepDailyUnitMinute,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textSecondary,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Text(
|
|
|
|
'-',
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_MetricBlock(
|
|
|
|
label: l10n.quality,
|
|
|
|
labelColor: const Color(0xFF7B9BFB),
|
|
...
|
...
|
@@ -192,8 +196,10 @@ class TodaySleepCard extends StatelessWidget { |
|
|
|
],
|
|
|
|
centerCircleSizeRatio: 0.3,
|
|
|
|
gapRatio: 0.1,
|
|
|
|
interpolatedColorRatio: 1),
|
|
|
|
interpolatedColorRatio: 1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
interactionEnabled: controller.isFriend && sleepDuration > 0,
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
);
|
|
...
|
...
|
@@ -252,9 +258,7 @@ class TodayActivityCard extends StatelessWidget { |
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
const TextSpan(text: '-'),
|
|
|
|
],
|
|
|
|
children: [const TextSpan(text: '-')],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
...
|
...
|
@@ -290,20 +294,18 @@ class TodayActivityCard extends StatelessWidget { |
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
const TextSpan(text: '-'),
|
|
|
|
],
|
|
|
|
children: [const TextSpan(text: '-')],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
double activityProgress =
|
|
|
|
(activity > 0 && (activityTarget?.move ?? 0) > 0)
|
|
|
|
? (activity / (activityTarget?.move ?? 0)) * 360
|
|
|
|
: -1;
|
|
|
|
? (activity / (activityTarget?.move ?? 0)) * 360
|
|
|
|
: -1;
|
|
|
|
double exerciseProgress =
|
|
|
|
(exercise > 0 && (activityTarget?.exercise ?? 0) > 0)
|
|
|
|
? (exercise / (activityTarget?.exercise ?? 0)) * 360
|
|
|
|
: -1;
|
|
|
|
? (exercise / (activityTarget?.exercise ?? 0)) * 360
|
|
|
|
: -1;
|
|
|
|
double standProgress = (stand > 0 && (activityTarget?.stand ?? 0) > 0)
|
|
|
|
? (stand / (activityTarget?.stand ?? 0)) * 360
|
|
|
|
: -1;
|
|
...
|
...
|
@@ -312,8 +314,8 @@ class TodayActivityCard extends StatelessWidget { |
|
|
|
: null;
|
|
|
|
double? exerciseRatio =
|
|
|
|
(exercise > 0 && (activityTarget?.exercise ?? 0) > 0)
|
|
|
|
? (exercise / (activityTarget?.exercise ?? 0))
|
|
|
|
: null;
|
|
|
|
? (exercise / (activityTarget?.exercise ?? 0))
|
|
|
|
: null;
|
|
|
|
double? standRatio = (stand > 0 && (activityTarget?.stand ?? 0) > 0)
|
|
|
|
? (stand / (activityTarget?.stand ?? 0))
|
|
|
|
: null;
|
|
...
|
...
|
@@ -405,7 +407,7 @@ class TodayActivityCard extends StatelessWidget { |
|
|
|
sweepAngles: [
|
|
|
|
activityProgress,
|
|
|
|
exerciseProgress,
|
|
|
|
standProgress
|
|
|
|
standProgress,
|
|
|
|
],
|
|
|
|
backgroundColors: [
|
|
|
|
context.colors.chartPink.withOpacity(0.4),
|
|
...
|
...
|
@@ -413,20 +415,17 @@ class TodayActivityCard extends StatelessWidget { |
|
|
|
context.colors.chartBlue.withOpacity(0.4),
|
|
|
|
],
|
|
|
|
gradientColors: [
|
|
|
|
[
|
|
|
|
context.colors.chartPink,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
context.colors.chartGreen,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
context.colors.chartBlue,
|
|
|
|
],
|
|
|
|
[context.colors.chartPink],
|
|
|
|
[context.colors.chartGreen],
|
|
|
|
[context.colors.chartBlue],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
interactionEnabled:
|
|
|
|
controller.isFriend &&
|
|
|
|
(activity > 0 || exercise > 0 || stand > 0),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
);
|
|
...
|
...
|
@@ -441,6 +440,7 @@ class _TodaySummaryCard extends StatelessWidget { |
|
|
|
required this.actionText,
|
|
|
|
required this.metrics,
|
|
|
|
required this.rightWidget,
|
|
|
|
this.interactionEnabled,
|
|
|
|
});
|
|
|
|
|
|
|
|
final String iconAsset;
|
|
...
|
...
|
@@ -450,6 +450,7 @@ class _TodaySummaryCard extends StatelessWidget { |
|
|
|
final List<Widget> metrics;
|
|
|
|
|
|
|
|
final Widget rightWidget;
|
|
|
|
final bool? interactionEnabled;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
...
|
...
|
@@ -466,12 +467,7 @@ class _TodaySummaryCard extends StatelessWidget { |
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
iconAsset,
|
|
|
|
width: 16,
|
|
|
|
height: 16,
|
|
|
|
color: iconColor,
|
|
|
|
),
|
|
|
|
Image.asset(iconAsset, width: 16, height: 16, color: iconColor),
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
Text(
|
|
|
|
title,
|
|
...
|
...
|
@@ -481,6 +477,10 @@ class _TodaySummaryCard extends StatelessWidget { |
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (interactionEnabled != null) ...[
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
FriendInteractionButton(enabled: interactionEnabled!),
|
|
|
|
],
|
|
|
|
const Spacer(),
|
|
|
|
Text(
|
|
|
|
actionText,
|
|
...
|
...
|
@@ -510,7 +510,7 @@ class _TodaySummaryCard extends StatelessWidget { |
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
rightWidget
|
|
|
|
rightWidget,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
...
|
...
|
|