Showing
4 changed files
with
68 additions
and
36 deletions
| @@ -54,6 +54,7 @@ class FriendsController extends GetxController { | @@ -54,6 +54,7 @@ class FriendsController extends GetxController { | ||
| 54 | void _markPageVisible() { | 54 | void _markPageVisible() { |
| 55 | if (_isPageVisible) return; | 55 | if (_isPageVisible) return; |
| 56 | _isPageVisible = true; | 56 | _isPageVisible = true; |
| 57 | + unawaited(refreshData()); | ||
| 57 | ta.track('enter_doublefeel_friend_page'); | 58 | ta.track('enter_doublefeel_friend_page'); |
| 58 | } | 59 | } |
| 59 | 60 |
| @@ -52,6 +52,17 @@ mixin HealthTrendControl on GetxController { | @@ -52,6 +52,17 @@ mixin HealthTrendControl on GetxController { | ||
| 52 | selectedDate.value = nextDate; | 52 | selectedDate.value = nextDate; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | + void resetQueries() { | ||
| 56 | + final today = ReportDateRangeConfig.clampDate(DateTime.now()); | ||
| 57 | + _periodsByType[0] = ReportPeriod.week; | ||
| 58 | + _datesByType[0] = ReportDateRangeConfig.lastWeekStart(); | ||
| 59 | + _periodsByType[1] = ReportPeriod.day; | ||
| 60 | + _datesByType[1] = today; | ||
| 61 | + _periodsByType[2] = ReportPeriod.day; | ||
| 62 | + _datesByType[2] = today; | ||
| 63 | + changeType(0); | ||
| 64 | + } | ||
| 65 | + | ||
| 55 | ReportPeriod periodForType(int typeIndex) { | 66 | ReportPeriod periodForType(int typeIndex) { |
| 56 | final normalizedIndex = normalizeTypeIndex(typeIndex); | 67 | final normalizedIndex = normalizeTypeIndex(typeIndex); |
| 57 | return normalizePeriod(normalizedIndex, _periodsByType[normalizedIndex]); | 68 | return normalizePeriod(normalizedIndex, _periodsByType[normalizedIndex]); |
| @@ -8,7 +8,6 @@ import '../../../../../core/result/app_result.dart'; | @@ -8,7 +8,6 @@ import '../../../../../core/result/app_result.dart'; | ||
| 8 | import '../../../../../data/models/friend/friend_models.dart'; | 8 | import '../../../../../data/models/friend/friend_models.dart'; |
| 9 | import '../../../health_trend/controllers/health_trend_analytics.dart'; | 9 | import '../../../health_trend/controllers/health_trend_analytics.dart'; |
| 10 | import '../../../health_trend/controllers/health_trend_control.dart'; | 10 | import '../../../health_trend/controllers/health_trend_control.dart'; |
| 11 | -import '../../../report_common/config/report_date_range_config.dart'; | ||
| 12 | import '../../../report_common/models/health_report_query.dart'; | 11 | import '../../../report_common/models/health_report_query.dart'; |
| 13 | import '../../../report_common/models/report_period.dart'; | 12 | import '../../../report_common/models/report_period.dart'; |
| 14 | import '../../widgets/trend/trend_friend_select_bottom_sheet.dart'; | 13 | import '../../widgets/trend/trend_friend_select_bottom_sheet.dart'; |
| @@ -151,7 +150,7 @@ class TrendController extends GetxController with HealthTrendControl { | @@ -151,7 +150,7 @@ class TrendController extends GetxController with HealthTrendControl { | ||
| 151 | return; | 150 | return; |
| 152 | } | 151 | } |
| 153 | if (resetQueryOnShow) { | 152 | if (resetQueryOnShow) { |
| 154 | - _resetToDefaultQuery(); | 153 | + resetQueries(); |
| 155 | } | 154 | } |
| 156 | _markPageVisible(); | 155 | _markPageVisible(); |
| 157 | } | 156 | } |
| @@ -167,11 +166,6 @@ class TrendController extends GetxController with HealthTrendControl { | @@ -167,11 +166,6 @@ class TrendController extends GetxController with HealthTrendControl { | ||
| 167 | _isPageVisible = false; | 166 | _isPageVisible = false; |
| 168 | } | 167 | } |
| 169 | 168 | ||
| 170 | - void _resetToDefaultQuery() { | ||
| 171 | - changeType(TrendType.hrv.tabIndex); | ||
| 172 | - changeQuery(ReportPeriod.week, ReportDateRangeConfig.lastWeekStart()); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | void _trackEnterPage() { | 169 | void _trackEnterPage() { |
| 176 | HealthTrendAnalytics.trackEnterPage( | 170 | HealthTrendAnalytics.trackEnterPage( |
| 177 | selectedTypeIndex.value, | 171 | selectedTypeIndex.value, |
| @@ -15,8 +15,6 @@ class SleepSummaryCard extends StatelessWidget { | @@ -15,8 +15,6 @@ class SleepSummaryCard extends StatelessWidget { | ||
| 15 | 15 | ||
| 16 | static const _brand = Color(0xFF845EEE); | 16 | static const _brand = Color(0xFF845EEE); |
| 17 | static const _blue = Color(0xFF7B9BFB); | 17 | static const _blue = Color(0xFF7B9BFB); |
| 18 | - static const _h2 = Color(0xFF78787D); | ||
| 19 | - static const _h3 = Color(0xFFB0B0B6); | ||
| 20 | 18 | ||
| 21 | @override | 19 | @override |
| 22 | Widget build(BuildContext context) { | 20 | Widget build(BuildContext context) { |
| @@ -46,33 +44,9 @@ class SleepSummaryCard extends StatelessWidget { | @@ -46,33 +44,9 @@ class SleepSummaryCard extends StatelessWidget { | ||
| 46 | titleColor: _blue, | 44 | titleColor: _blue, |
| 47 | showInfo: true, | 45 | showInfo: true, |
| 48 | onInfoTap: onQualityInfoTap, | 46 | onInfoTap: onQualityInfoTap, |
| 49 | - child: Row( | ||
| 50 | - crossAxisAlignment: CrossAxisAlignment.end, | ||
| 51 | - children: [ | ||
| 52 | - Text( | ||
| 53 | - quality.shortText, | ||
| 54 | - style: TextStyle( | ||
| 55 | - color: Color(quality.qualityColorValue), | ||
| 56 | - fontSize: 20, | ||
| 57 | - fontWeight: FontWeight.w600, | ||
| 58 | - height: 1.15, | ||
| 59 | - ), | ||
| 60 | - ), | ||
| 61 | - const SizedBox(width: 4), | ||
| 62 | - Padding( | ||
| 63 | - padding: const EdgeInsets.only(bottom: 1), | ||
| 64 | - child: Text( | ||
| 65 | - score == null | ||
| 66 | - ? context.l10n.reportUnitScore | ||
| 67 | - : '$score${context.l10n.reportUnitScore}', | ||
| 68 | - style: TextStyle( | ||
| 69 | - color: score == null ? _h3 : _h2, | ||
| 70 | - fontSize: 12, | ||
| 71 | - fontWeight: FontWeight.w500, | ||
| 72 | - ), | ||
| 73 | - ), | ||
| 74 | - ), | ||
| 75 | - ], | 47 | + child: _QualityValue( |
| 48 | + quality: quality, | ||
| 49 | + score: score, | ||
| 76 | ), | 50 | ), |
| 77 | ), | 51 | ), |
| 78 | ), | 52 | ), |
| @@ -169,6 +143,58 @@ class _DurationValue extends StatelessWidget { | @@ -169,6 +143,58 @@ class _DurationValue extends StatelessWidget { | ||
| 169 | } | 143 | } |
| 170 | } | 144 | } |
| 171 | 145 | ||
| 146 | +class _QualityValue extends StatelessWidget { | ||
| 147 | + const _QualityValue({ | ||
| 148 | + required this.quality, | ||
| 149 | + required this.score, | ||
| 150 | + }); | ||
| 151 | + | ||
| 152 | + final SleepQualityLevel quality; | ||
| 153 | + final int? score; | ||
| 154 | + | ||
| 155 | + static const _h2 = Color(0xFF78787D); | ||
| 156 | + static const _h3 = Color(0xFFB0B0B6); | ||
| 157 | + | ||
| 158 | + @override | ||
| 159 | + Widget build(BuildContext context) { | ||
| 160 | + final value = score; | ||
| 161 | + if (value == null) { | ||
| 162 | + return _NumberWithUnit( | ||
| 163 | + value: '-', | ||
| 164 | + unit: context.l10n.reportUnitScore, | ||
| 165 | + unitColor: _h3, | ||
| 166 | + ); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + return Row( | ||
| 170 | + crossAxisAlignment: CrossAxisAlignment.end, | ||
| 171 | + children: [ | ||
| 172 | + Text( | ||
| 173 | + quality.shortText, | ||
| 174 | + style: TextStyle( | ||
| 175 | + color: Color(quality.qualityColorValue), | ||
| 176 | + fontSize: 20, | ||
| 177 | + fontWeight: FontWeight.w600, | ||
| 178 | + height: 1.15, | ||
| 179 | + ), | ||
| 180 | + ), | ||
| 181 | + const SizedBox(width: 4), | ||
| 182 | + Padding( | ||
| 183 | + padding: const EdgeInsets.only(bottom: 1), | ||
| 184 | + child: Text( | ||
| 185 | + '$value${context.l10n.reportUnitScore}', | ||
| 186 | + style: const TextStyle( | ||
| 187 | + color: _h2, | ||
| 188 | + fontSize: 12, | ||
| 189 | + fontWeight: FontWeight.w500, | ||
| 190 | + ), | ||
| 191 | + ), | ||
| 192 | + ), | ||
| 193 | + ], | ||
| 194 | + ); | ||
| 195 | + } | ||
| 196 | +} | ||
| 197 | + | ||
| 172 | class _NumberWithUnit extends StatelessWidget { | 198 | class _NumberWithUnit extends StatelessWidget { |
| 173 | const _NumberWithUnit({ | 199 | const _NumberWithUnit({ |
| 174 | required this.value, | 200 | required this.value, |
-
Please register or login to post a comment