Commit 4967db0c762435f442f3c96b0bf6d5ebfb86abc5

Authored by 刘宏哲
1 parent 5c9f3b8b

feat(app): update ui

... ... @@ -54,6 +54,7 @@ class FriendsController extends GetxController {
void _markPageVisible() {
if (_isPageVisible) return;
_isPageVisible = true;
unawaited(refreshData());
ta.track('enter_doublefeel_friend_page');
}
... ...
... ... @@ -52,6 +52,17 @@ mixin HealthTrendControl on GetxController {
selectedDate.value = nextDate;
}
void resetQueries() {
final today = ReportDateRangeConfig.clampDate(DateTime.now());
_periodsByType[0] = ReportPeriod.week;
_datesByType[0] = ReportDateRangeConfig.lastWeekStart();
_periodsByType[1] = ReportPeriod.day;
_datesByType[1] = today;
_periodsByType[2] = ReportPeriod.day;
_datesByType[2] = today;
changeType(0);
}
ReportPeriod periodForType(int typeIndex) {
final normalizedIndex = normalizeTypeIndex(typeIndex);
return normalizePeriod(normalizedIndex, _periodsByType[normalizedIndex]);
... ...
... ... @@ -8,7 +8,6 @@ import '../../../../../core/result/app_result.dart';
import '../../../../../data/models/friend/friend_models.dart';
import '../../../health_trend/controllers/health_trend_analytics.dart';
import '../../../health_trend/controllers/health_trend_control.dart';
import '../../../report_common/config/report_date_range_config.dart';
import '../../../report_common/models/health_report_query.dart';
import '../../../report_common/models/report_period.dart';
import '../../widgets/trend/trend_friend_select_bottom_sheet.dart';
... ... @@ -151,7 +150,7 @@ class TrendController extends GetxController with HealthTrendControl {
return;
}
if (resetQueryOnShow) {
_resetToDefaultQuery();
resetQueries();
}
_markPageVisible();
}
... ... @@ -167,11 +166,6 @@ class TrendController extends GetxController with HealthTrendControl {
_isPageVisible = false;
}
void _resetToDefaultQuery() {
changeType(TrendType.hrv.tabIndex);
changeQuery(ReportPeriod.week, ReportDateRangeConfig.lastWeekStart());
}
void _trackEnterPage() {
HealthTrendAnalytics.trackEnterPage(
selectedTypeIndex.value,
... ...
... ... @@ -15,8 +15,6 @@ class SleepSummaryCard extends StatelessWidget {
static const _brand = Color(0xFF845EEE);
static const _blue = Color(0xFF7B9BFB);
static const _h2 = Color(0xFF78787D);
static const _h3 = Color(0xFFB0B0B6);
@override
Widget build(BuildContext context) {
... ... @@ -46,33 +44,9 @@ class SleepSummaryCard extends StatelessWidget {
titleColor: _blue,
showInfo: true,
onInfoTap: onQualityInfoTap,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
quality.shortText,
style: TextStyle(
color: Color(quality.qualityColorValue),
fontSize: 20,
fontWeight: FontWeight.w600,
height: 1.15,
),
),
const SizedBox(width: 4),
Padding(
padding: const EdgeInsets.only(bottom: 1),
child: Text(
score == null
? context.l10n.reportUnitScore
: '$score${context.l10n.reportUnitScore}',
style: TextStyle(
color: score == null ? _h3 : _h2,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
child: _QualityValue(
quality: quality,
score: score,
),
),
),
... ... @@ -169,6 +143,58 @@ class _DurationValue extends StatelessWidget {
}
}
class _QualityValue extends StatelessWidget {
const _QualityValue({
required this.quality,
required this.score,
});
final SleepQualityLevel quality;
final int? score;
static const _h2 = Color(0xFF78787D);
static const _h3 = Color(0xFFB0B0B6);
@override
Widget build(BuildContext context) {
final value = score;
if (value == null) {
return _NumberWithUnit(
value: '-',
unit: context.l10n.reportUnitScore,
unitColor: _h3,
);
}
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
quality.shortText,
style: TextStyle(
color: Color(quality.qualityColorValue),
fontSize: 20,
fontWeight: FontWeight.w600,
height: 1.15,
),
),
const SizedBox(width: 4),
Padding(
padding: const EdgeInsets.only(bottom: 1),
child: Text(
'$value${context.l10n.reportUnitScore}',
style: const TextStyle(
color: _h2,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
);
}
}
class _NumberWithUnit extends StatelessWidget {
const _NumberWithUnit({
required this.value,
... ...