Showing
5 changed files
with
37 additions
and
28 deletions
| @@ -88,13 +88,13 @@ class TodayController extends GetMaterialController { | @@ -88,13 +88,13 @@ class TodayController extends GetMaterialController { | ||
| 88 | Rx<DateTime> firstSelectableDay = DateTime( | 88 | Rx<DateTime> firstSelectableDay = DateTime( |
| 89 | DateTime.now().year, DateTime.now().month - 6, DateTime.now().day) | 89 | DateTime.now().year, DateTime.now().month - 6, DateTime.now().day) |
| 90 | .obs; | 90 | .obs; |
| 91 | - late final DateTime lastSelectableDay; | 91 | + Rx<DateTime> lastSelectableDay = DateUtils.dateOnly(DateTime.now()).obs; |
| 92 | final selectedDate = DateTime.now().obs; | 92 | final selectedDate = DateTime.now().obs; |
| 93 | final focusedDay = DateTime.now().obs; | 93 | final focusedDay = DateTime.now().obs; |
| 94 | final scrollOffset = 0.0.obs; | 94 | final scrollOffset = 0.0.obs; |
| 95 | final scrollController = ScrollController(); | 95 | final scrollController = ScrollController(); |
| 96 | 96 | ||
| 97 | - final isLoadingToday = false.obs; | 97 | + final isLoadingToday = true.obs; |
| 98 | final showHealthDataAuthCardStatus = 1.obs; | 98 | final showHealthDataAuthCardStatus = 1.obs; |
| 99 | final stressSubtitle = ''.obs; | 99 | final stressSubtitle = ''.obs; |
| 100 | bool _isFirstLoad = true; | 100 | bool _isFirstLoad = true; |
| @@ -145,7 +145,6 @@ class TodayController extends GetMaterialController { | @@ -145,7 +145,6 @@ class TodayController extends GetMaterialController { | ||
| 145 | firstSelectableDay.value = DateUtils.dateOnly( | 145 | firstSelectableDay.value = DateUtils.dateOnly( |
| 146 | DateTime(today.year, today.month - 6, today.day), | 146 | DateTime(today.year, today.month - 6, today.day), |
| 147 | ); | 147 | ); |
| 148 | - lastSelectableDay = today; | ||
| 149 | selectedDate.value = today; | 148 | selectedDate.value = today; |
| 150 | focusedDay.value = today; | 149 | focusedDay.value = today; |
| 151 | 150 | ||
| @@ -214,11 +213,11 @@ class TodayController extends GetMaterialController { | @@ -214,11 +213,11 @@ class TodayController extends GetMaterialController { | ||
| 214 | 213 | ||
| 215 | void changeDate(DateTime date, {DateTime? focused}) { | 214 | void changeDate(DateTime date, {DateTime? focused}) { |
| 216 | final normalizedDate = _clampDate(date); | 215 | final normalizedDate = _clampDate(date); |
| 217 | - if (!DateUtils.isSameDay(date, lastSelectableDay) && | ||
| 218 | - !_userStateService.isVip) { | ||
| 219 | - toPremiumPage('今日-查看非当日数据'); | ||
| 220 | - return; | ||
| 221 | - } | 216 | + // if (!DateUtils.isSameDay(date, lastSelectableDay.value) && |
| 217 | + // !_userStateService.isVip) { | ||
| 218 | + // toPremiumPage('今日-查看非当日数据'); | ||
| 219 | + // return; | ||
| 220 | + // } | ||
| 222 | selectedDate.value = normalizedDate; | 221 | selectedDate.value = normalizedDate; |
| 223 | focusedDay.value = _clampDate(focused ?? normalizedDate); | 222 | focusedDay.value = _clampDate(focused ?? normalizedDate); |
| 224 | } | 223 | } |
| @@ -227,7 +226,8 @@ class TodayController extends GetMaterialController { | @@ -227,7 +226,8 @@ class TodayController extends GetMaterialController { | ||
| 227 | final normalizedDate = DateUtils.dateOnly(date); | 226 | final normalizedDate = DateUtils.dateOnly(date); |
| 228 | if (normalizedDate.isBefore(firstSelectableDay.value)) | 227 | if (normalizedDate.isBefore(firstSelectableDay.value)) |
| 229 | return firstSelectableDay.value; | 228 | return firstSelectableDay.value; |
| 230 | - if (normalizedDate.isAfter(lastSelectableDay)) return lastSelectableDay; | 229 | + if (normalizedDate.isAfter(lastSelectableDay.value)) |
| 230 | + return lastSelectableDay.value; | ||
| 231 | return normalizedDate; | 231 | return normalizedDate; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| @@ -337,8 +337,8 @@ class TodayController extends GetMaterialController { | @@ -337,8 +337,8 @@ class TodayController extends GetMaterialController { | ||
| 337 | Future<void> checkHealthDataAuthCardVisible( | 337 | Future<void> checkHealthDataAuthCardVisible( |
| 338 | [HealthAuthorization? preResult]) async { | 338 | [HealthAuthorization? preResult]) async { |
| 339 | final firstTime = DateUtils.dateOnly( | 339 | final firstTime = DateUtils.dateOnly( |
| 340 | - DateTime(lastSelectableDay.year, lastSelectableDay.month - 6, | ||
| 341 | - lastSelectableDay.day), | 340 | + DateTime(lastSelectableDay.value.year, lastSelectableDay.value.month - 6, |
| 341 | + lastSelectableDay.value.day), | ||
| 342 | ); | 342 | ); |
| 343 | if (isFriend) { | 343 | if (isFriend) { |
| 344 | showHealthDataAuthCardStatus.value = 1; | 344 | showHealthDataAuthCardStatus.value = 1; |
| @@ -396,7 +396,7 @@ class TodayController extends GetMaterialController { | @@ -396,7 +396,7 @@ class TodayController extends GetMaterialController { | ||
| 396 | _clearRealTimeData(); | 396 | _clearRealTimeData(); |
| 397 | final intDate = int.parse(DateFormat('yyyyMMdd').format(date)); | 397 | final intDate = int.parse(DateFormat('yyyyMMdd').format(date)); |
| 398 | 398 | ||
| 399 | - final isToday = DateUtils.isSameDay(date, lastSelectableDay); | 399 | + final isToday = DateUtils.isSameDay(date, lastSelectableDay.value); |
| 400 | stressSubtitle.value = (isFriend ? 'Ta' : '') + | 400 | stressSubtitle.value = (isFriend ? 'Ta' : '') + |
| 401 | (isToday ? l10n.overallStressLevelToday : l10n.stressLevelsOnThatDay); | 401 | (isToday ? l10n.overallStressLevelToday : l10n.stressLevelsOnThatDay); |
| 402 | switch (await _healthApi.getV2HealthData(friendUserId, intDate)) { | 402 | switch (await _healthApi.getV2HealthData(friendUserId, intDate)) { |
| @@ -449,6 +449,7 @@ class TodayController extends GetMaterialController { | @@ -449,6 +449,7 @@ class TodayController extends GetMaterialController { | ||
| 449 | hrvAnnotations.clear(); | 449 | hrvAnnotations.clear(); |
| 450 | 450 | ||
| 451 | v2HealthData.value = null; | 451 | v2HealthData.value = null; |
| 452 | + v2StressScore.value = null; | ||
| 452 | } | 453 | } |
| 453 | 454 | ||
| 454 | toTrendHrvPage() { | 455 | toTrendHrvPage() { |
| @@ -637,6 +638,7 @@ class TodayController extends GetMaterialController { | @@ -637,6 +638,7 @@ class TodayController extends GetMaterialController { | ||
| 637 | super.didChangeAppLifecycleState(state); | 638 | super.didChangeAppLifecycleState(state); |
| 638 | 639 | ||
| 639 | if (state == AppLifecycleState.resumed) { | 640 | if (state == AppLifecycleState.resumed) { |
| 641 | + lastSelectableDay.value = DateUtils.dateOnly(DateTime.now()); | ||
| 640 | checkAddFriendVisible(); | 642 | checkAddFriendVisible(); |
| 641 | checkHrvAdBannerVisible(); | 643 | checkHrvAdBannerVisible(); |
| 642 | checkHealthDataAuthCardVisible(); | 644 | checkHealthDataAuthCardVisible(); |
| @@ -649,6 +651,8 @@ class TodayController extends GetMaterialController { | @@ -649,6 +651,8 @@ class TodayController extends GetMaterialController { | ||
| 649 | _isFirstLoad = false; | 651 | _isFirstLoad = false; |
| 650 | return; | 652 | return; |
| 651 | } | 653 | } |
| 654 | + lastSelectableDay.value = DateUtils.dateOnly(DateTime.now()); | ||
| 655 | + | ||
| 652 | checkAddFriendVisible(); | 656 | checkAddFriendVisible(); |
| 653 | checkHrvAdBannerVisible(); | 657 | checkHrvAdBannerVisible(); |
| 654 | checkHealthDataAuthCardVisible(); | 658 | checkHealthDataAuthCardVisible(); |
| @@ -101,7 +101,7 @@ class TodayTabBody extends StatelessWidget { | @@ -101,7 +101,7 @@ class TodayTabBody extends StatelessWidget { | ||
| 101 | context, controller.selectedDate.value), | 101 | context, controller.selectedDate.value), |
| 102 | showBackToToday: !isSameDay( | 102 | showBackToToday: !isSameDay( |
| 103 | controller.selectedDate.value, | 103 | controller.selectedDate.value, |
| 104 | - controller.lastSelectableDay, | 104 | + controller.lastSelectableDay.value, |
| 105 | ), | 105 | ), |
| 106 | onBackToToday: _backToToday, | 106 | onBackToToday: _backToToday, |
| 107 | onTapPremiumCard: () { | 107 | onTapPremiumCard: () { |
| @@ -231,7 +231,8 @@ class TodayTabBody extends StatelessWidget { | @@ -231,7 +231,8 @@ class TodayTabBody extends StatelessWidget { | ||
| 231 | const SizedBox(height: 12), | 231 | const SizedBox(height: 12), |
| 232 | _LatestHrvCard(controller: controller), | 232 | _LatestHrvCard(controller: controller), |
| 233 | if (!controller.isFriend) measureHRVButton(context), | 233 | if (!controller.isFriend) measureHRVButton(context), |
| 234 | - Padding( | 234 | + Container( |
| 235 | + alignment: Alignment.centerLeft, | ||
| 235 | padding: const EdgeInsets.symmetric(vertical: 12), | 236 | padding: const EdgeInsets.symmetric(vertical: 12), |
| 236 | child: Text( | 237 | child: Text( |
| 237 | (controller.isFriend | 238 | (controller.isFriend |
| @@ -243,6 +244,7 @@ class TodayTabBody extends StatelessWidget { | @@ -243,6 +244,7 @@ class TodayTabBody extends StatelessWidget { | ||
| 243 | fontSize: 16, | 244 | fontSize: 16, |
| 244 | fontWeight: FontWeight.w600, | 245 | fontWeight: FontWeight.w600, |
| 245 | ), | 246 | ), |
| 247 | + textAlign: TextAlign.start, | ||
| 246 | ), | 248 | ), |
| 247 | ), | 249 | ), |
| 248 | TodaySleepCard(controller: controller), | 250 | TodaySleepCard(controller: controller), |
| @@ -309,15 +311,16 @@ class TodayTabBody extends StatelessWidget { | @@ -309,15 +311,16 @@ class TodayTabBody extends StatelessWidget { | ||
| 309 | child: SizedBox( | 311 | child: SizedBox( |
| 310 | height: _weekRowsHeight, | 312 | height: _weekRowsHeight, |
| 311 | child: TableCalendar( | 313 | child: TableCalendar( |
| 312 | - key: ValueKey(controller.firstSelectableDay.value), | 314 | + key: ValueKey( |
| 315 | + '${controller.firstSelectableDay.value}-${controller.lastSelectableDay.value}'), | ||
| 313 | calendarFormat: CalendarFormat.week, | 316 | calendarFormat: CalendarFormat.week, |
| 314 | headerVisible: false, | 317 | headerVisible: false, |
| 315 | daysOfWeekHeight: _weekRowsHeight / 2, | 318 | daysOfWeekHeight: _weekRowsHeight / 2, |
| 316 | rowHeight: _weekRowsHeight / 2, | 319 | rowHeight: _weekRowsHeight / 2, |
| 317 | focusedDay: controller.focusedDay.value, | 320 | focusedDay: controller.focusedDay.value, |
| 318 | firstDay: controller.firstSelectableDay.value, | 321 | firstDay: controller.firstSelectableDay.value, |
| 319 | - lastDay: controller.lastSelectableDay, | ||
| 320 | - currentDay: controller.lastSelectableDay, | 322 | + lastDay: controller.lastSelectableDay.value, |
| 323 | + currentDay: controller.lastSelectableDay.value, | ||
| 321 | locale: Localizations.localeOf(context).toString(), | 324 | locale: Localizations.localeOf(context).toString(), |
| 322 | startingDayOfWeek: _startingDayOfWeek(context), | 325 | startingDayOfWeek: _startingDayOfWeek(context), |
| 323 | availableCalendarFormats: const { | 326 | availableCalendarFormats: const { |
| @@ -371,7 +374,7 @@ class TodayTabBody extends StatelessWidget { | @@ -371,7 +374,7 @@ class TodayTabBody extends StatelessWidget { | ||
| 371 | period: ReportPeriod.day, | 374 | period: ReportPeriod.day, |
| 372 | selectedDate: controller.selectedDate.value, | 375 | selectedDate: controller.selectedDate.value, |
| 373 | weekStart: controller.selectedDate.value, | 376 | weekStart: controller.selectedDate.value, |
| 374 | - maxDate: controller.lastSelectableDay, | 377 | + maxDate: controller.lastSelectableDay.value, |
| 375 | minDate: controller.firstSelectableDay.value, | 378 | minDate: controller.firstSelectableDay.value, |
| 376 | ); | 379 | ); |
| 377 | if (picked != null) { | 380 | if (picked != null) { |
| @@ -415,7 +418,7 @@ class TodayTabBody extends StatelessWidget { | @@ -415,7 +418,7 @@ class TodayTabBody extends StatelessWidget { | ||
| 415 | ) | 418 | ) |
| 416 | : null, | 419 | : null, |
| 417 | child: Text( | 420 | child: Text( |
| 418 | - isSameDay(day, controller.lastSelectableDay) | 421 | + isSameDay(day, controller.lastSelectableDay.value) |
| 419 | ? l10n.todayOnWeeklyCalendar | 422 | ? l10n.todayOnWeeklyCalendar |
| 420 | : _weekdayText(context, day), | 423 | : _weekdayText(context, day), |
| 421 | style: TextStyle( | 424 | style: TextStyle( |
| @@ -470,11 +473,11 @@ class TodayTabBody extends StatelessWidget { | @@ -470,11 +473,11 @@ class TodayTabBody extends StatelessWidget { | ||
| 470 | } | 473 | } |
| 471 | 474 | ||
| 472 | void _backToToday() { | 475 | void _backToToday() { |
| 473 | - controller.changeDate(controller.lastSelectableDay); | 476 | + controller.changeDate(controller.lastSelectableDay.value); |
| 474 | } | 477 | } |
| 475 | 478 | ||
| 476 | String _dateTitle(BuildContext context, DateTime selectedDay) { | 479 | String _dateTitle(BuildContext context, DateTime selectedDay) { |
| 477 | - final today = controller.lastSelectableDay; | 480 | + final today = controller.lastSelectableDay.value; |
| 478 | if (isSameDay(selectedDay, today)) return context.l10n.today; | 481 | if (isSameDay(selectedDay, today)) return context.l10n.today; |
| 479 | if (isSameDay(selectedDay, today.subtract(const Duration(days: 1)))) { | 482 | if (isSameDay(selectedDay, today.subtract(const Duration(days: 1)))) { |
| 480 | return context.l10n.yesterday; | 483 | return context.l10n.yesterday; |
| @@ -492,7 +495,7 @@ class TodayTabBody extends StatelessWidget { | @@ -492,7 +495,7 @@ class TodayTabBody extends StatelessWidget { | ||
| 492 | 495 | ||
| 493 | bool _isAfterToday(DateTime day) { | 496 | bool _isAfterToday(DateTime day) { |
| 494 | final normalizedDay = DateUtils.dateOnly(day); | 497 | final normalizedDay = DateUtils.dateOnly(day); |
| 495 | - return normalizedDay.isAfter(controller.lastSelectableDay); | 498 | + return normalizedDay.isAfter(controller.lastSelectableDay.value); |
| 496 | } | 499 | } |
| 497 | 500 | ||
| 498 | Color _calendarTextColor( | 501 | Color _calendarTextColor( |
| @@ -562,7 +565,7 @@ class _LatestHrvCard extends StatelessWidget { | @@ -562,7 +565,7 @@ class _LatestHrvCard extends StatelessWidget { | ||
| 562 | crossAxisAlignment: CrossAxisAlignment.start, | 565 | crossAxisAlignment: CrossAxisAlignment.start, |
| 563 | children: [ | 566 | children: [ |
| 564 | Text( | 567 | Text( |
| 565 | - '${l10n.mostRecent}($latestDataTimeText)', | 568 | + '${l10n.mostRecent}($latestDataTimeText)', |
| 566 | style: TextStyle( | 569 | style: TextStyle( |
| 567 | color: colors.textSecondary, | 570 | color: colors.textSecondary, |
| 568 | fontSize: 12, | 571 | fontSize: 12, |
| @@ -582,7 +585,7 @@ class _LatestHrvCard extends StatelessWidget { | @@ -582,7 +585,7 @@ class _LatestHrvCard extends StatelessWidget { | ||
| 582 | ), | 585 | ), |
| 583 | const SizedBox(width: 8), | 586 | const SizedBox(width: 8), |
| 584 | Text( | 587 | Text( |
| 585 | - '${latestHrv}ms · $stateStr', | 588 | + '${latestHrv}ms·$stateStr', |
| 586 | style: TextStyle( | 589 | style: TextStyle( |
| 587 | color: colors.textPrimary, | 590 | color: colors.textPrimary, |
| 588 | fontSize: 18, | 591 | fontSize: 18, |
| @@ -143,7 +143,7 @@ class TodayHrvChartCard extends StatelessWidget { | @@ -143,7 +143,7 @@ class TodayHrvChartCard extends StatelessWidget { | ||
| 143 | 143 | ||
| 144 | Widget _buildHeader(BuildContext context) { | 144 | Widget _buildHeader(BuildContext context) { |
| 145 | var sameDay = DateUtils.isSameDay( | 145 | var sameDay = DateUtils.isSameDay( |
| 146 | - controller.selectedDate.value, controller.lastSelectableDay); | 146 | + controller.selectedDate.value, controller.lastSelectableDay.value); |
| 147 | 147 | ||
| 148 | return Row( | 148 | return Row( |
| 149 | children: [ | 149 | children: [ |
| @@ -212,7 +212,7 @@ class TodayHrvChartCard extends StatelessWidget { | @@ -212,7 +212,7 @@ class TodayHrvChartCard extends StatelessWidget { | ||
| 212 | /// 例如当前 13:58 → 下一刻度 18:00 → 返回 18 * 3600 = 64800 | 212 | /// 例如当前 13:58 → 下一刻度 18:00 → 返回 18 * 3600 = 64800 |
| 213 | double _maxChartSeconds() { | 213 | double _maxChartSeconds() { |
| 214 | if (!DateUtils.isSameDay( | 214 | if (!DateUtils.isSameDay( |
| 215 | - controller.selectedDate.value, controller.lastSelectableDay)) { | 215 | + controller.selectedDate.value, controller.lastSelectableDay.value)) { |
| 216 | return 24 * 3600.0; | 216 | return 24 * 3600.0; |
| 217 | } | 217 | } |
| 218 | final now = DateTime.now(); | 218 | final now = DateTime.now(); |
| @@ -21,7 +21,7 @@ class TodayHrvNumberCard extends StatelessWidget { | @@ -21,7 +21,7 @@ class TodayHrvNumberCard extends StatelessWidget { | ||
| 21 | ), | 21 | ), |
| 22 | child: Obx(() { | 22 | child: Obx(() { |
| 23 | var sameDay = DateUtils.isSameDay( | 23 | var sameDay = DateUtils.isSameDay( |
| 24 | - controller.selectedDate.value, controller.lastSelectableDay); | 24 | + controller.selectedDate.value, controller.lastSelectableDay.value); |
| 25 | 25 | ||
| 26 | var otherHrv = (sameDay | 26 | var otherHrv = (sameDay |
| 27 | ? context.l10n.todaySAverageHrv | 27 | ? context.l10n.todaySAverageHrv |
| @@ -238,6 +238,8 @@ class V2StressScore { | @@ -238,6 +238,8 @@ class V2StressScore { | ||
| 238 | 238 | ||
| 239 | String stateString() { | 239 | String stateString() { |
| 240 | switch (state) { | 240 | switch (state) { |
| 241 | + case 0: | ||
| 242 | + return l10n.waitingForData; | ||
| 241 | case 1: | 243 | case 1: |
| 242 | return l10n.pressureOverload; | 244 | return l10n.pressureOverload; |
| 243 | case 2: | 245 | case 2: |
| @@ -247,7 +249,7 @@ class V2StressScore { | @@ -247,7 +249,7 @@ class V2StressScore { | ||
| 247 | case 4: | 249 | case 4: |
| 248 | return l10n.inExcellentCondition; | 250 | return l10n.inExcellentCondition; |
| 249 | } | 251 | } |
| 250 | - return l10n.waitingForData; | 252 | + return ''; |
| 251 | } | 253 | } |
| 252 | 254 | ||
| 253 | String stateBg() { | 255 | String stateBg() { |
-
Please register or login to post a comment