Commit a377c57605a167b113487f5c22a3873247d31d00

Authored by 常守达
1 parent aeeca558

fea(login): 废弃json_serializable

PODS:
- Flutter (1.0.0)
- fluttertoast (0.0.2):
- Flutter
- image_cropper (0.0.4):
- Flutter
- TOCropViewController (~> 2.7.4)
... ... @@ -23,6 +25,7 @@ PODS:
DEPENDENCIES:
- Flutter (from `Flutter`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
... ... @@ -38,6 +41,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
Flutter:
:path: Flutter
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
image_cropper:
:path: ".symlinks/plugins/image_cropper/ios"
image_picker_ios:
... ... @@ -54,7 +59,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1
image_cropper: c4326ea50132b1e1564499e5d32a84f01fb03537
image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
... ...
... ... @@ -7,22 +7,7 @@ class HomeController extends GetxController {
/// 当前选中的底部 tab 索引
final selectedIndex = 0.obs;
/// 当前选中的日期(Today tab 使用)
final selectedDate = _dateOnly(DateTime.now()).obs;
void changeTab(int index) {
selectedIndex.value = index;
}
void changeDate(DateTime date) {
final normalizedDate = _dateOnly(date);
final currentDate = selectedDate.value;
if (currentDate == normalizedDate) return;
selectedDate.value = normalizedDate;
}
static DateTime _dateOnly(DateTime date) {
return DateTime(date.year, date.month, date.day);
}
}
... ...
... ... @@ -4,13 +4,14 @@ import 'package:doublefeel_flutter/core/logging/app_logger.dart';
import 'package:doublefeel_flutter/core/network/api/health_api.dart';
import 'package:doublefeel_flutter/core/network/api/user_api.dart';
import 'package:doublefeel_flutter/core/result/app_result.dart';
import 'package:doublefeel_flutter/core/error/app_error.dart';
import 'package:doublefeel_flutter/core/services/health_kit_upload_service.dart';
import 'package:doublefeel_flutter/core/services/user_state_service.dart';
import 'package:doublefeel_flutter/data/models/enums/app_enums.dart';
import 'package:doublefeel_flutter/data/models/health/health_models.dart';
import 'package:doublefeel_flutter/data/models/health/health_upload_models.dart';
import 'package:doublefeel_flutter/data/models/user/user_models.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
/// HRV 趋势数据点
... ... @@ -51,6 +52,12 @@ class TodayController extends GetxController {
UserStateService get userStateService => _userStateService;
late final DateTime firstSelectableDay;
late final DateTime lastSelectableDay;
final selectedDate = DateTime.now().obs;
final focusedDay = DateTime.now().obs;
final scrollOffset = 0.0.obs;
final isLoadingToday = false.obs;
final showHealthDataAuthCard = true.obs;
final stressSubtitle = 'Hi, 你今日的综合压力状态'.obs;
... ... @@ -105,22 +112,48 @@ class TodayController extends GetxController {
@override
void onInit() {
super.onInit();
unawaited(loadTodayData());
final today = DateUtils.dateOnly(DateTime.now());
firstSelectableDay = DateTime(today.year - 1);
lastSelectableDay = today;
selectedDate.value = today;
focusedDay.value = today;
ever<DateTime>(selectedDate, (date) {
unawaited(loadDataForDate(date));
});
unawaited(loadDataForDate(today));
}
Future<void> loadTodayData() => loadDataForDate(lastSelectableDay);
void changeDate(DateTime date, {DateTime? focused}) {
final normalizedDate = _clampDate(date);
selectedDate.value = normalizedDate;
focusedDay.value = _clampDate(focused ?? normalizedDate);
}
Future<void> loadTodayData() async {
if (isLoadingToday.value) return;
DateTime _clampDate(DateTime date) {
final normalizedDate = DateUtils.dateOnly(date);
if (normalizedDate.isBefore(firstSelectableDay)) return firstSelectableDay;
if (normalizedDate.isAfter(lastSelectableDay)) return lastSelectableDay;
return normalizedDate;
}
Future<void> loadDataForDate(DateTime date) async {
isLoadingToday.value = true;
try {
await Future.wait([
_refreshUserGreeting(),
// _refreshHealthAuthorizationState(),
_refreshTodayHealthData(),
_refreshHealthDataForDate(date),
]);
} catch (error, stackTrace) {
AppLogger.e('TodayController.loadTodayData failed', error, stackTrace);
AppLogger.e('TodayController.loadDataForDate failed', error, stackTrace);
} finally {
isLoadingToday.value = false;
if (selectedDate.value == date) {
isLoadingToday.value = false;
}
}
}
... ... @@ -153,17 +186,27 @@ class TodayController extends GetxController {
showHealthDataAuthCard.value = !(hasServerAuth || hasClientAuth);
}
Future<void> _refreshTodayHealthData() async {
final startDate = _todayDateKey();
Future<void> _refreshHealthDataForDate(DateTime date) async {
final startYear = date.year;
final startMonth = date.month;
final startDate = startYear * 10000 + startMonth * 100 + 1; // e.g. 20260601
const dateRangeType = 1;
final todayResultFuture = _healthApi.getTodayData(
isOther: false,
errorHandlingPolicy: null,
);
final latestHrvResultFuture = _healthApi.getLatestHrvData(
errorHandlingPolicy: null,
);
final isToday = DateUtils.isSameDay(date, lastSelectableDay);
final todayResultFuture = isToday
? _healthApi.getTodayData(
isOther: false,
errorHandlingPolicy: null,
)
: Future.value(AppFailure<TodayStatusData>(AppUnknownError('Not today')));
final latestHrvResultFuture = isToday
? _healthApi.getLatestHrvData(
errorHandlingPolicy: null,
)
: Future.value(AppFailure<LatestHrvData>(AppUnknownError('Not today')));
final hrvStatisticsResultFuture = _healthApi.getHrvStatistics(
isOther: false,
dateRangeType: dateRangeType,
... ... @@ -189,10 +232,18 @@ class TodayController extends GetxController {
final sleepStatisticsResult = await sleepStatisticsResultFuture;
final activityStatisticsResult = await activityStatisticsResultFuture;
if (selectedDate.value != date) return;
if (!isToday) {
_clearRealTimeData();
}
if (todayResult case AppSuccess<TodayStatusData>(data: final today)) {
_applyTodayData(today);
} else if (todayResult case AppFailure(error: final error)) {
AppLogger.w('HealthApi.getTodayData failed: $error');
if (isToday) {
AppLogger.w('HealthApi.getTodayData failed: $error');
}
}
if (latestHrvResult case AppSuccess<LatestHrvData>(data: final latestHrv)) {
... ... @@ -201,22 +252,42 @@ class TodayController extends GetxController {
if (hrvStatisticsResult
case AppSuccess<HrvStatisticsData>(data: final hrvStatistics)) {
_applyHrvStatistics(hrvStatistics);
_applyHrvStatistics(hrvStatistics, date);
}
if (sleepStatisticsResult
case AppSuccess<SleepStatisticsData>(data: final sleepStatistics)) {
_applySleepStatistics(sleepStatistics);
_applySleepStatistics(sleepStatistics, date);
}
if (activityStatisticsResult
case AppSuccess<ActivityBurnStatisticsData>(
data: final activityStatistics
)) {
_applyActivityStatistics(activityStatistics);
_applyActivityStatistics(activityStatistics, date);
}
}
void _clearRealTimeData() {
restingHeartRate.value = '--';
sleepAverageHeartRate.value = '--';
sleepHours.value = '--';
sleepMinutes.value = '--';
sleepQuality.value = '--';
sleepProgress.value = 0.0;
activityCalories.value = '--';
activityExerciseMinutes.value = '--';
activityStandHours.value = '--';
activityMoveProgress.value = 0.0;
activityExerciseProgress.value = 0.0;
activityStandProgress.value = 0.0;
hrvChartData.clear();
stressChartData.clear();
hrvAnnotations.clear();
avgHrv.value = '--';
stressLabel.value = '状态正常';
}
void _applyTodayData(TodayStatusData today) {
final recent = today.recentData;
if (recent?.heartRate != null) {
... ... @@ -268,10 +339,27 @@ class TodayController extends GetxController {
}
}
void _applyHrvStatistics(HrvStatisticsData data) {
if (avgHrv.value == '--' && data.avgHrv != null) {
avgHrv.value = _formatMetric(data.avgHrv);
void _applyHrvStatistics(HrvStatisticsData data, DateTime date) {
final dateKey = date.day;
final isToday = DateUtils.isSameDay(date, lastSelectableDay);
if (isToday) {
if (avgHrv.value == '--' && data.avgHrv != null) {
avgHrv.value = _formatMetric(data.avgHrv);
}
} else {
double? dailyHrv;
if (data.hrvTrendList != null) {
for (final trend in data.hrvTrendList!) {
if (trend.timeKey == dateKey) {
dailyHrv = trend.average;
break;
}
}
}
avgHrv.value = _formatMetric(dailyHrv);
}
if (data.avgRestingHeartRate != null) {
restingHeartRate.value = _formatMetric(data.avgRestingHeartRate);
}
... ... @@ -280,41 +368,102 @@ class TodayController extends GetxController {
}
}
void _applySleepStatistics(SleepStatisticsData data) {
if (sleepHours.value == '--' && data.avgSleepDuration != null) {
_applySleepDuration(data.avgSleepDuration);
void _applySleepStatistics(SleepStatisticsData data, DateTime date) {
final dateKey = date.day;
final isToday = DateUtils.isSameDay(date, lastSelectableDay);
if (isToday) {
if (sleepHours.value == '--' && data.avgSleepDuration != null) {
_applySleepDuration(data.avgSleepDuration);
}
} else {
int? dailySleep;
if (data.sleepTrendList != null) {
for (final trend in data.sleepTrendList!) {
if (trend.timeKey == dateKey) {
dailySleep = trend.average;
break;
}
}
}
_applySleepDuration(dailySleep);
}
final deepPercentage = data.deepPercentage;
if (deepPercentage != null) {
sleepQuality.value = _sleepQualityFromDeepPercentage(deepPercentage);
}
}
void _applyActivityStatistics(ActivityBurnStatisticsData data) {
void _applyActivityStatistics(ActivityBurnStatisticsData data, DateTime date) {
_activityMoveTarget = data.activityTargetInfo?.move ?? _activityMoveTarget;
_activityStandTarget =
data.activityTargetInfo?.stand ?? _activityStandTarget;
if (activityCalories.value == '--' && data.totalCaloriesBurned != null) {
activityCalories.value = _formatMetric(data.totalCaloriesBurned);
}
if (activityStandHours.value == '--' && data.totalStand != null) {
activityStandHours.value = _formatMetric(data.totalStand);
final dateKey = date.day;
final isToday = DateUtils.isSameDay(date, lastSelectableDay);
if (isToday) {
if (activityCalories.value == '--' && data.totalCaloriesBurned != null) {
activityCalories.value = _formatMetric(data.totalCaloriesBurned);
}
if (activityStandHours.value == '--' && data.totalStand != null) {
activityStandHours.value = _formatMetric(data.totalStand);
}
} else {
int? dailyMove;
if (data.caloriesBurnedTrendList != null) {
for (final trend in data.caloriesBurnedTrendList!) {
if (trend.timeKey == dateKey) {
dailyMove = trend.value;
break;
}
}
}
activityCalories.value = _formatMetric(dailyMove);
int? dailyExercise;
if (data.exerciseTimeTrendList != null) {
for (final trend in data.exerciseTimeTrendList!) {
if (trend.timeKey == dateKey) {
dailyExercise = trend.value;
break;
}
}
}
activityExerciseMinutes.value = _formatMetric(dailyExercise);
activityStandHours.value = '--';
}
final moveValue = _parseMetric(activityCalories.value);
final exerciseValue = _parseMetric(activityExerciseMinutes.value);
final standValue = _parseMetric(activityStandHours.value);
if (moveValue != null) {
activityMoveProgress.value = _progress(
moveValue,
(_activityMoveTarget ?? 400).toDouble(),
);
} else {
activityMoveProgress.value = 0.0;
}
if (exerciseValue != null) {
activityExerciseProgress.value = _progress(
exerciseValue,
30.0,
);
} else {
activityExerciseProgress.value = 0.0;
}
if (standValue != null) {
activityStandProgress.value = _progress(
standValue,
(_activityStandTarget ?? 12).toDouble(),
);
} else {
activityStandProgress.value = 0.0;
}
}
... ... @@ -474,9 +623,4 @@ class TodayController extends GetxController {
final m = (totalMinutes % 60).toString().padLeft(2, '0');
return '$h:$m';
}
int _todayDateKey() {
final now = DateTime.now();
return now.year * 10000 + now.month * 100 + now.day - 2;
}
}
... ...
... ... @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:table_calendar/table_calendar.dart';
import '../../controllers/home_controller.dart';
import '../../controllers/today_controller.dart';
import '../../widgets/today/today_health_data_auth_card.dart';
import '../../widgets/today/today_hrv_ad_banner.dart';
... ... @@ -14,14 +13,9 @@ import '../../widgets/today/today_sleep_activity_cards.dart';
import '../../widgets/today/premium_card.dart';
class TodayTab extends StatefulWidget {
class TodayTab extends GetView<TodayController> {
const TodayTab({super.key});
@override
State<TodayTab> createState() => _TodayTabState();
}
class _TodayTabState extends State<TodayTab> {
static const _bgColor = Color(0xFFF2F2F7);
static const _topBarHeight = 48.0;
static const _weekCalendarHeight = 58.0;
... ... @@ -29,46 +23,6 @@ class _TodayTabState extends State<TodayTab> {
static const _weekRowsHeight = 50.0;
static const _selectedDayWidth = 32.0;
final TodayController controller = Get.find<TodayController>();
final HomeController homeController = Get.find<HomeController>();
late final DateTime _firstSelectableDay;
late final DateTime _lastSelectableDay;
late final int _dayPageCount;
late final PageController _pageController;
late final Worker _selectedDateWorker;
late DateTime _focusedDay;
final ValueNotifier<double> _scrollOffset = ValueNotifier<double>(0);
@override
void initState() {
super.initState();
final today = DateUtils.dateOnly(DateTime.now());
_firstSelectableDay = DateTime(today.year - 1);
_lastSelectableDay = today;
_dayPageCount =
_lastSelectableDay.difference(_firstSelectableDay).inDays + 1;
final initialSelectedDay =
_clampSelectableDay(homeController.selectedDate.value);
_focusedDay = initialSelectedDay;
homeController.changeDate(initialSelectedDay);
_pageController = PageController(
initialPage: _pageIndexForDay(initialSelectedDay),
);
_selectedDateWorker = ever<DateTime>(
homeController.selectedDate,
_handleSelectedDateChanged,
);
}
@override
void dispose() {
_selectedDateWorker.dispose();
_pageController.dispose();
_scrollOffset.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final topPadding = MediaQuery.paddingOf(context).top;
... ... @@ -79,32 +33,30 @@ class _TodayTabState extends State<TodayTab> {
child: Stack(
children: [
NotificationListener<ScrollNotification>(
onNotification: _handleScrollNotification,
child: PageView.builder(
controller: _pageController,
itemCount: _dayPageCount,
onPageChanged: _onDayPageChanged,
itemBuilder: (context, index) {
return _buildDayScrollView(context, pinnedHeaderHeight);
},
),
onNotification: (notification) {
if (notification.metrics.axis == Axis.vertical) {
controller.scrollOffset.value =
notification.metrics.pixels.clamp(0.0, double.infinity);
}
return false;
},
child: _buildDayScrollView(context, pinnedHeaderHeight),
),
Positioned(
top: 0,
left: 0,
right: 0,
height: pinnedHeaderHeight,
child: ValueListenableBuilder<double>(
valueListenable: _scrollOffset,
builder: (context, offset, child) {
final opacity =
(offset / _topContentHeight).clamp(0.0, 1).toDouble();
return Container(
color: const Color(0xFFDDD2FF).withValues(alpha: opacity),
);
},
),
child: Obx(() {
final opacity =
(controller.scrollOffset.value / _topContentHeight)
.clamp(0.0, 1.0)
.toDouble();
return Container(
color: const Color(0xFFDDD2FF).withValues(alpha: opacity),
);
}),
),
Positioned(
top: topPadding,
... ... @@ -115,11 +67,14 @@ class _TodayTabState extends State<TodayTab> {
mainAxisSize: MainAxisSize.min,
children: [
_TopDateBar(
title: _dateTitle,
showBackToToday: !_isSelectedToday,
title: _dateTitle(controller.selectedDate.value),
showBackToToday: !isSameDay(
controller.selectedDate.value,
controller.lastSelectableDay,
),
onBackToToday: _backToToday,
),
_buildWeekCalendar(),
_buildWeekCalendar(context),
],
),
),
... ... @@ -134,7 +89,6 @@ class _TodayTabState extends State<TodayTab> {
double pinnedHeaderHeight,
) {
return CustomScrollView(
primary: false,
physics: const ClampingScrollPhysics(),
slivers: [
SliverToBoxAdapter(
... ... @@ -241,7 +195,7 @@ class _TodayTabState extends State<TodayTab> {
);
}
Widget _buildWeekCalendar() {
Widget _buildWeekCalendar(BuildContext context) {
return SizedBox(
height: _weekCalendarHeight,
child: Padding(
... ... @@ -257,17 +211,18 @@ class _TodayTabState extends State<TodayTab> {
headerVisible: false,
daysOfWeekHeight: _weekRowsHeight / 2,
rowHeight: _weekRowsHeight / 2,
focusedDay: _focusedDay,
firstDay: _firstSelectableDay,
lastDay: _lastSelectableDay,
currentDay: _lastSelectableDay,
focusedDay: controller.focusedDay.value,
firstDay: controller.firstSelectableDay,
lastDay: controller.lastSelectableDay,
currentDay: controller.lastSelectableDay,
startingDayOfWeek: StartingDayOfWeek.monday,
availableCalendarFormats: const {
CalendarFormat.week: '',
},
availableGestures: AvailableGestures.horizontalSwipe,
enabledDayPredicate: (day) => !_isAfterToday(day),
selectedDayPredicate: (day) => isSameDay(_selectedDay, day),
selectedDayPredicate: (day) =>
isSameDay(controller.selectedDate.value, day),
onDaySelected: _onDaySelected,
onPageChanged: _onCalendarPageChanged,
calendarStyle: const CalendarStyle(
... ... @@ -280,15 +235,15 @@ class _TodayTabState extends State<TodayTab> {
decoration: BoxDecoration(),
),
calendarBuilders: CalendarBuilders(
dowBuilder: (context, day) => _buildWeekdayCell(day),
dowBuilder: (context, day) => _buildWeekdayCell(context, day),
defaultBuilder: (context, day, focusedDay) =>
_buildDateCell(day),
_buildDateCell(context, day),
disabledBuilder: (context, day, focusedDay) =>
_buildDateCell(day),
_buildDateCell(context, day),
outsideBuilder: (context, day, focusedDay) =>
_buildDateCell(day),
_buildDateCell(context, day),
selectedBuilder: (context, day, focusedDay) =>
_buildDateCell(day, selected: true),
_buildDateCell(context, day, selected: true),
),
),
),
... ... @@ -316,18 +271,8 @@ class _TodayTabState extends State<TodayTab> {
);
}
bool _handleScrollNotification(ScrollNotification notification) {
if (notification.metrics.axis != Axis.vertical) return false;
final offset = notification.metrics.pixels.clamp(0.0, double.infinity);
if (_scrollOffset.value != offset) {
_scrollOffset.value = offset.toDouble();
}
return false;
}
Widget _buildWeekdayCell(DateTime day) {
final selected = isSameDay(_selectedDay, day);
Widget _buildWeekdayCell(BuildContext context, DateTime day) {
final selected = isSameDay(controller.selectedDate.value, day);
return Center(
child: Container(
... ... @@ -343,9 +288,9 @@ class _TodayTabState extends State<TodayTab> {
)
: null,
child: Text(
isSameDay(day, _lastSelectableDay) ? '今' : _weekdayText(day),
isSameDay(day, controller.lastSelectableDay) ? '今' : _weekdayText(day),
style: TextStyle(
color: _calendarTextColor(day, selected: selected),
color: _calendarTextColor(context, day, selected: selected),
fontSize: 12,
fontWeight: FontWeight.w500,
),
... ... @@ -354,7 +299,11 @@ class _TodayTabState extends State<TodayTab> {
);
}
Widget _buildDateCell(DateTime day, {bool selected = false}) {
Widget _buildDateCell(
BuildContext context,
DateTime day, {
bool selected = false,
}) {
return Center(
child: Container(
width: _selectedDayWidth,
... ... @@ -363,7 +312,7 @@ class _TodayTabState extends State<TodayTab> {
decoration: selected
? BoxDecoration(
color: context.colors.primary,
borderRadius: BorderRadius.vertical(
borderRadius: const BorderRadius.vertical(
bottom: Radius.circular(22),
),
)
... ... @@ -371,7 +320,7 @@ class _TodayTabState extends State<TodayTab> {
child: Text(
'${day.day}',
style: TextStyle(
color: _calendarTextColor(day, selected: selected),
color: _calendarTextColor(context, day, selected: selected),
fontSize: 12,
fontWeight: FontWeight.w500,
),
... ... @@ -380,89 +329,20 @@ class _TodayTabState extends State<TodayTab> {
);
}
void _handleSelectedDateChanged(DateTime selectedDate) {
final normalizedDay = _clampSelectableDay(selectedDate);
if (selectedDate != normalizedDay) {
homeController.changeDate(normalizedDay);
return;
}
if (mounted) {
setState(() {
_focusedDay = normalizedDay;
});
}
_syncPagerToSelectedDay(normalizedDay);
}
void _onDayPageChanged(int page) {
_selectDate(_dateForPage(page));
}
void _onDaySelected(DateTime selectedDay, DateTime focusedDay) {
_selectDate(selectedDay, focusedDay: focusedDay);
controller.changeDate(selectedDay, focused: focusedDay);
}
void _onCalendarPageChanged(DateTime focusedDay) {
final selectedWeekdayOffset = _selectedDay.weekday - DateTime.monday;
final nextSelectedDay = _weekStart(focusedDay).add(
Duration(days: selectedWeekdayOffset),
);
_selectDate(nextSelectedDay, focusedDay: focusedDay);
final selectedWeekdayOffset =
controller.selectedDate.value.weekday - DateTime.monday;
final nextSelectedDay =
_weekStart(focusedDay).add(Duration(days: selectedWeekdayOffset));
controller.changeDate(nextSelectedDay, focused: focusedDay);
}
void _backToToday() {
_selectDate(_lastSelectableDay);
}
void _selectDate(DateTime selectedDay, {DateTime? focusedDay}) {
final normalizedSelectedDay = _clampSelectableDay(selectedDay);
final normalizedFocusedDay = _clampSelectableDay(
focusedDay ?? normalizedSelectedDay,
);
setState(() {
_focusedDay = normalizedFocusedDay;
});
homeController.changeDate(normalizedSelectedDay);
}
void _syncPagerToSelectedDay(DateTime selectedDay) {
final targetPage = _pageIndexForDay(selectedDay);
if (!_pageController.hasClients) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
_syncPagerToSelectedDay(selectedDay);
});
return;
}
final currentPage =
_pageController.page?.round() ?? _pageController.initialPage;
if (currentPage == targetPage) return;
_pageController.animateToPage(
targetPage,
duration: const Duration(milliseconds: 220),
curve: Curves.easeOut,
);
}
DateTime _dateForPage(int page) {
return _firstSelectableDay.add(Duration(days: page));
}
int _pageIndexForDay(DateTime day) {
final dayIndex =
_clampSelectableDay(day).difference(_firstSelectableDay).inDays;
return dayIndex.clamp(0, _dayPageCount - 1).toInt();
}
DateTime _clampSelectableDay(DateTime day) {
final normalizedDay = DateUtils.dateOnly(day);
if (normalizedDay.isBefore(_firstSelectableDay)) return _firstSelectableDay;
if (normalizedDay.isAfter(_lastSelectableDay)) return _lastSelectableDay;
return normalizedDay;
controller.changeDate(controller.lastSelectableDay);
}
DateTime _weekStart(DateTime day) {
... ... @@ -470,29 +350,28 @@ class _TodayTabState extends State<TodayTab> {
return normalizedDay.subtract(Duration(days: normalizedDay.weekday - 1));
}
DateTime get _selectedDay =>
_clampSelectableDay(homeController.selectedDate.value);
String get _dateTitle {
final today = _lastSelectableDay;
if (isSameDay(_selectedDay, today)) return '今日';
if (isSameDay(_selectedDay, today.subtract(const Duration(days: 1)))) {
String _dateTitle(DateTime selectedDay) {
final today = controller.lastSelectableDay;
if (isSameDay(selectedDay, today)) return '今日';
if (isSameDay(selectedDay, today.subtract(const Duration(days: 1)))) {
return '昨日';
}
if (isSameDay(_selectedDay, today.add(const Duration(days: 1)))) {
if (isSameDay(selectedDay, today.add(const Duration(days: 1)))) {
return '明日';
}
return '${_selectedDay.month}${_selectedDay.day}日';
return '${selectedDay.month}${selectedDay.day}日';
}
bool get _isSelectedToday => isSameDay(_selectedDay, _lastSelectableDay);
bool _isAfterToday(DateTime day) {
final normalizedDay = DateUtils.dateOnly(day);
return normalizedDay.isAfter(_lastSelectableDay);
return normalizedDay.isAfter(controller.lastSelectableDay);
}
Color _calendarTextColor(DateTime day, {required bool selected}) {
Color _calendarTextColor(
BuildContext context,
DateTime day, {
required bool selected,
}) {
if (selected) return Colors.white;
return context.colors.textPrimary
.withValues(alpha: _isAfterToday(day) ? 0.2 : 0.6);
... ... @@ -533,7 +412,7 @@ class _TopDateBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
height: _TodayTabState._topBarHeight,
height: TodayTab._topBarHeight,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Row(
... ...
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../controllers/home_controller.dart';
import '../../controllers/today_controller.dart';
/// Figma: 横向 7 日日期条,当前选中日高亮品牌色圆角背景
/// 支持左右滑动切换周次(PageView)
class TodayDateStrip extends GetView<HomeController> {
class TodayDateStrip extends GetView<TodayController> {
const TodayDateStrip({super.key});
static const _brandColor = Color(0xFF845EEE);
... ...
import 'package:json_annotation/json_annotation.dart';
part 'config_models.g.dart';
@JsonSerializable()
class ConfigDataListResponse {
const ConfigDataListResponse({this.configDataList});
@JsonKey(name: 'config_list')
final List<ConfigData>? configDataList;
factory ConfigDataListResponse.fromJson(Map<String, dynamic> json) =>
_$ConfigDataListResponseFromJson(json);
Map<String, dynamic> toJson() => _$ConfigDataListResponseToJson(this);
factory ConfigDataListResponse.fromJson(Map<String, dynamic> json) {
return ConfigDataListResponse(
configDataList: (json['config_list'] as List<dynamic>?)
?.map((e) => ConfigData.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (configDataList != null) {
val['config_list'] = configDataList!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class ConfigData {
const ConfigData({
this.id,
... ... @@ -25,12 +30,24 @@ class ConfigData {
final int? id;
final String? scene;
@JsonKey(name: 'image_1')
final String? image1;
@JsonKey(name: 'text_1')
final String? text1;
factory ConfigData.fromJson(Map<String, dynamic> json) =>
_$ConfigDataFromJson(json);
Map<String, dynamic> toJson() => _$ConfigDataToJson(this);
factory ConfigData.fromJson(Map<String, dynamic> json) {
return ConfigData(
id: json['id'] as int?,
scene: json['scene'] as String?,
image1: json['image_1'] as String?,
text1: json['text_1'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (id != null) val['id'] = id;
if (scene != null) val['scene'] = scene;
if (image1 != null) val['image_1'] = image1;
if (text1 != null) val['text_1'] = text1;
return val;
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'config_models.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ConfigDataListResponse _$ConfigDataListResponseFromJson(
Map<String, dynamic> json) =>
ConfigDataListResponse(
configDataList: (json['config_list'] as List<dynamic>?)
?.map((e) => ConfigData.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$ConfigDataListResponseToJson(
ConfigDataListResponse instance) =>
<String, dynamic>{
if (instance.configDataList?.map((e) => e.toJson()).toList()
case final value?)
'config_list': value,
};
ConfigData _$ConfigDataFromJson(Map<String, dynamic> json) => ConfigData(
id: (json['id'] as num?)?.toInt(),
scene: json['scene'] as String?,
image1: json['image_1'] as String?,
text1: json['text_1'] as String?,
);
Map<String, dynamic> _$ConfigDataToJson(ConfigData instance) =>
<String, dynamic>{
if (instance.id case final value?) 'id': value,
if (instance.scene case final value?) 'scene': value,
if (instance.image1 case final value?) 'image_1': value,
if (instance.text1 case final value?) 'text_1': value,
};
import 'package:json_annotation/json_annotation.dart';
import '../enums/app_enums.dart';
part 'health_models.g.dart';
int? _parseInt(dynamic value) {
if (value == null) return null;
if (value is int) return value;
if (value is double) return value.toInt();
if (value is String) {
return int.tryParse(value);
}
return null;
}
double? _parseDouble(dynamic value) {
if (value == null) return null;
if (value is num) return value.toDouble();
if (value is String) {
if (value == 'NaN') return double.nan;
if (value == 'Infinity') return double.infinity;
if (value == '-Infinity') return double.negativeInfinity;
return double.tryParse(value);
}
return null;
}
@JsonSerializable()
class TodayStatusData {
const TodayStatusData({
this.recentData,
... ... @@ -14,23 +31,50 @@ class TodayStatusData {
this.sleepDuration,
});
@JsonKey(name: 'recent_data')
final TodayStatusRecentData? recentData;
@JsonKey(name: 'hrv_data_list')
final List<TodayHrvData>? hrvDataList;
@JsonKey(name: 'heart_rate_data_list')
final List<TodayHeartRateData>? heartRateDataList;
@JsonKey(name: 'oxygen_saturation_data_list')
final List<TodaySpo2Data>? spo2DataList;
@JsonKey(name: 'sleep_duration')
final int? sleepDuration;
factory TodayStatusData.fromJson(Map<String, dynamic> json) =>
_$TodayStatusDataFromJson(json);
Map<String, dynamic> toJson() => _$TodayStatusDataToJson(this);
factory TodayStatusData.fromJson(Map<String, dynamic> json) {
return TodayStatusData(
recentData: json['recent_data'] == null
? null
: TodayStatusRecentData.fromJson(
json['recent_data'] as Map<String, dynamic>),
hrvDataList: (json['hrv_data_list'] as List<dynamic>?)
?.map((e) => TodayHrvData.fromJson(e as Map<String, dynamic>))
.toList(),
heartRateDataList: (json['heart_rate_data_list'] as List<dynamic>?)
?.map((e) => TodayHeartRateData.fromJson(e as Map<String, dynamic>))
.toList(),
spo2DataList: (json['oxygen_saturation_data_list'] as List<dynamic>?)
?.map((e) => TodaySpo2Data.fromJson(e as Map<String, dynamic>))
.toList(),
sleepDuration: _parseInt(json['sleep_duration']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (recentData != null) val['recent_data'] = recentData!.toJson();
if (hrvDataList != null) {
val['hrv_data_list'] = hrvDataList!.map((e) => e.toJson()).toList();
}
if (heartRateDataList != null) {
val['heart_rate_data_list'] =
heartRateDataList!.map((e) => e.toJson()).toList();
}
if (spo2DataList != null) {
val['oxygen_saturation_data_list'] =
spo2DataList!.map((e) => e.toJson()).toList();
}
if (sleepDuration != null) val['sleep_duration'] = sleepDuration;
return val;
}
}
@JsonSerializable()
class TodayStatusRecentData {
const TodayStatusRecentData({
this.heartRate,
... ... @@ -41,27 +85,41 @@ class TodayStatusRecentData {
this.steps,
});
@JsonKey(name: 'heart_rate')
final int? heartRate;
@JsonKey(name: 'oxygen_saturation')
final double? spo2;
final int? move;
final int? exercise;
final int? stand;
final int? steps;
factory TodayStatusRecentData.fromJson(Map<String, dynamic> json) =>
_$TodayStatusRecentDataFromJson(json);
Map<String, dynamic> toJson() => _$TodayStatusRecentDataToJson(this);
factory TodayStatusRecentData.fromJson(Map<String, dynamic> json) {
return TodayStatusRecentData(
heartRate: _parseInt(json['heart_rate']),
spo2: _parseDouble(json['oxygen_saturation']),
move: _parseInt(json['move']),
exercise: _parseInt(json['exercise']),
stand: _parseInt(json['stand']),
steps: _parseInt(json['steps']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (heartRate != null) val['heart_rate'] = heartRate;
if (spo2 != null) val['oxygen_saturation'] = spo2;
if (move != null) val['move'] = move;
if (exercise != null) val['exercise'] = exercise;
if (stand != null) val['stand'] = stand;
if (steps != null) val['steps'] = steps;
return val;
}
}
@JsonSerializable()
class TodayHrvData {
const TodayHrvData({this.time, this.value, this.hrvBaseline});
final int? time;
final double? value;
@JsonKey(name: 'hrv_baseline')
final double? hrvBaseline;
HrvStatus? get hrvStatus {
... ... @@ -78,39 +136,68 @@ class TodayHrvData {
return HrvStatus.normal;
}
factory TodayHrvData.fromJson(Map<String, dynamic> json) =>
_$TodayHrvDataFromJson(json);
Map<String, dynamic> toJson() => _$TodayHrvDataToJson(this);
factory TodayHrvData.fromJson(Map<String, dynamic> json) {
return TodayHrvData(
time: _parseInt(json['time']),
value: _parseDouble(json['value']),
hrvBaseline: _parseDouble(json['hrv_baseline']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (time != null) val['time'] = time;
if (value != null) val['value'] = value;
if (hrvBaseline != null) val['hrv_baseline'] = hrvBaseline;
return val;
}
}
@JsonSerializable()
class TodayHeartRateData {
const TodayHeartRateData({this.index, this.minimum, this.maximum});
@JsonKey(name: 'bi_hour_index')
final int? index;
final int? minimum;
final int? maximum;
factory TodayHeartRateData.fromJson(Map<String, dynamic> json) =>
_$TodayHeartRateDataFromJson(json);
Map<String, dynamic> toJson() => _$TodayHeartRateDataToJson(this);
factory TodayHeartRateData.fromJson(Map<String, dynamic> json) {
return TodayHeartRateData(
index: _parseInt(json['bi_hour_index']),
minimum: _parseInt(json['minimum']),
maximum: _parseInt(json['maximum']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (index != null) val['bi_hour_index'] = index;
if (minimum != null) val['minimum'] = minimum;
if (maximum != null) val['maximum'] = maximum;
return val;
}
}
@JsonSerializable()
class TodaySpo2Data {
const TodaySpo2Data({this.index, this.average});
@JsonKey(name: 'bi_hour_index')
final int? index;
final double? average;
factory TodaySpo2Data.fromJson(Map<String, dynamic> json) =>
_$TodaySpo2DataFromJson(json);
Map<String, dynamic> toJson() => _$TodaySpo2DataToJson(this);
factory TodaySpo2Data.fromJson(Map<String, dynamic> json) {
return TodaySpo2Data(
index: _parseInt(json['bi_hour_index']),
average: _parseDouble(json['average']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (index != null) val['bi_hour_index'] = index;
if (average != null) val['average'] = average;
return val;
}
}
@JsonSerializable()
class PkCurrentMonthData {
const PkCurrentMonthData({
this.userWinAmount,
... ... @@ -119,21 +206,36 @@ class PkCurrentMonthData {
this.monthRecordList,
});
@JsonKey(name: 'user_win')
final int? userWinAmount;
@JsonKey(name: 'pair_user_win')
final int? partnerWinAmount;
@JsonKey(name: 'data_today')
final PkRecord? todayRecord;
@JsonKey(name: 'month_data_list')
final List<PkRecord>? monthRecordList;
factory PkCurrentMonthData.fromJson(Map<String, dynamic> json) =>
_$PkCurrentMonthDataFromJson(json);
Map<String, dynamic> toJson() => _$PkCurrentMonthDataToJson(this);
factory PkCurrentMonthData.fromJson(Map<String, dynamic> json) {
return PkCurrentMonthData(
userWinAmount: _parseInt(json['user_win']),
partnerWinAmount: _parseInt(json['pair_user_win']),
todayRecord: json['data_today'] == null
? null
: PkRecord.fromJson(json['data_today'] as Map<String, dynamic>),
monthRecordList: (json['month_data_list'] as List<dynamic>?)
?.map((e) => PkRecord.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (userWinAmount != null) val['user_win'] = userWinAmount;
if (partnerWinAmount != null) val['pair_user_win'] = partnerWinAmount;
if (todayRecord != null) val['data_today'] = todayRecord!.toJson();
if (monthRecordList != null) {
val['month_data_list'] = monthRecordList!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class PkRecord {
const PkRecord({
this.date,
... ... @@ -148,29 +250,44 @@ class PkRecord {
});
final int? date;
@JsonKey(name: 'user_score')
final int? userScore;
@JsonKey(name: 'user_move')
final int? userMove;
@JsonKey(name: 'user_stand')
final int? userStand;
@JsonKey(name: 'user_steps')
final int? userSteps;
@JsonKey(name: 'pair_user_score')
final int? partnerScore;
@JsonKey(name: 'pair_user_move')
final int? partnerMove;
@JsonKey(name: 'pair_user_stand')
final int? partnerStand;
@JsonKey(name: 'pair_user_steps')
final int? partnerSteps;
factory PkRecord.fromJson(Map<String, dynamic> json) =>
_$PkRecordFromJson(json);
Map<String, dynamic> toJson() => _$PkRecordToJson(this);
factory PkRecord.fromJson(Map<String, dynamic> json) {
return PkRecord(
date: _parseInt(json['date']),
userScore: _parseInt(json['user_score']),
userMove: _parseInt(json['user_move']),
userStand: _parseInt(json['user_stand']),
userSteps: _parseInt(json['user_steps']),
partnerScore: _parseInt(json['pair_user_score']),
partnerMove: _parseInt(json['pair_user_move']),
partnerStand: _parseInt(json['pair_user_stand']),
partnerSteps: _parseInt(json['pair_user_steps']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (date != null) val['date'] = date;
if (userScore != null) val['user_score'] = userScore;
if (userMove != null) val['user_move'] = userMove;
if (userStand != null) val['user_stand'] = userStand;
if (userSteps != null) val['user_steps'] = userSteps;
if (partnerScore != null) val['pair_user_score'] = partnerScore;
if (partnerMove != null) val['pair_user_move'] = partnerMove;
if (partnerStand != null) val['pair_user_stand'] = partnerStand;
if (partnerSteps != null) val['pair_user_steps'] = partnerSteps;
return val;
}
}
@JsonSerializable()
class SleepStatisticsData {
const SleepStatisticsData({
this.avgSleepDuration,
... ... @@ -182,53 +299,90 @@ class SleepStatisticsData {
this.asleepTimeDistributionList,
});
@JsonKey(name: 'avg_sleep_duration')
final int? avgSleepDuration;
@JsonKey(name: 'awake_percentage')
final double? awakePercentage;
@JsonKey(name: 'core_percentage')
final double? corePercentage;
@JsonKey(name: 'deep_percentage')
final double? deepPercentage;
@JsonKey(name: 'rem_percentage')
final double? remPercentage;
@JsonKey(name: 'sleep_trend_list')
final List<SleepTrend>? sleepTrendList;
@JsonKey(name: 'asleep_time_trend_list')
final List<AsleepTimeDistribution>? asleepTimeDistributionList;
factory SleepStatisticsData.fromJson(Map<String, dynamic> json) =>
_$SleepStatisticsDataFromJson(json);
Map<String, dynamic> toJson() => _$SleepStatisticsDataToJson(this);
factory SleepStatisticsData.fromJson(Map<String, dynamic> json) {
return SleepStatisticsData(
avgSleepDuration: _parseInt(json['avg_sleep_duration']),
awakePercentage: _parseDouble(json['awake_percentage']),
corePercentage: _parseDouble(json['core_percentage']),
deepPercentage: _parseDouble(json['deep_percentage']),
remPercentage: _parseDouble(json['rem_percentage']),
sleepTrendList: (json['sleep_trend_list'] as List<dynamic>?)
?.map((e) => SleepTrend.fromJson(e as Map<String, dynamic>))
.toList(),
asleepTimeDistributionList: (json['asleep_time_trend_list'] as List<dynamic>?)
?.map((e) => AsleepTimeDistribution.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (avgSleepDuration != null) val['avg_sleep_duration'] = avgSleepDuration;
if (awakePercentage != null) val['awake_percentage'] = awakePercentage;
if (corePercentage != null) val['core_percentage'] = corePercentage;
if (deepPercentage != null) val['deep_percentage'] = deepPercentage;
if (remPercentage != null) val['rem_percentage'] = remPercentage;
if (sleepTrendList != null) {
val['sleep_trend_list'] = sleepTrendList!.map((e) => e.toJson()).toList();
}
if (asleepTimeDistributionList != null) {
val['asleep_time_trend_list'] =
asleepTimeDistributionList!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class SleepTrend {
const SleepTrend({this.timeKey, this.average});
@JsonKey(name: 'time_key')
final int? timeKey;
final int? average;
factory SleepTrend.fromJson(Map<String, dynamic> json) =>
_$SleepTrendFromJson(json);
Map<String, dynamic> toJson() => _$SleepTrendToJson(this);
factory SleepTrend.fromJson(Map<String, dynamic> json) {
return SleepTrend(
timeKey: _parseInt(json['time_key']),
average: _parseInt(json['average']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (timeKey != null) val['time_key'] = timeKey;
if (average != null) val['average'] = average;
return val;
}
}
@JsonSerializable()
class AsleepTimeDistribution {
const AsleepTimeDistribution({this.timeKey, this.average});
@JsonKey(name: 'time_key')
final int? timeKey;
final String? average;
factory AsleepTimeDistribution.fromJson(Map<String, dynamic> json) =>
_$AsleepTimeDistributionFromJson(json);
Map<String, dynamic> toJson() => _$AsleepTimeDistributionToJson(this);
factory AsleepTimeDistribution.fromJson(Map<String, dynamic> json) {
return AsleepTimeDistribution(
timeKey: _parseInt(json['time_key']),
average: json['average'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (timeKey != null) val['time_key'] = timeKey;
if (average != null) val['average'] = average;
return val;
}
}
@JsonSerializable()
class ActivityBurnStatisticsData {
const ActivityBurnStatisticsData({
this.totalCaloriesBurned,
... ... @@ -242,69 +396,127 @@ class ActivityBurnStatisticsData {
this.activityTargetInfo,
});
@JsonKey(name: 'total_move')
final int? totalCaloriesBurned;
@JsonKey(name: 'avg_move')
final double? avgCaloriesBurned;
@JsonKey(name: 'max_move')
final CaloriesBurnedValue? maxCaloriesBurned;
@JsonKey(name: 'min_move')
final CaloriesBurnedValue? minCaloriesBurned;
@JsonKey(name: 'total_steps')
final int? totalSteps;
@JsonKey(name: 'total_stand')
final int? totalStand;
@JsonKey(name: 'move_trend_list')
final List<CaloriesBurnedTrend>? caloriesBurnedTrendList;
@JsonKey(name: 'excercise_trend_list')
final List<ExerciseTimeTrend>? exerciseTimeTrendList;
@JsonKey(name: 'activity_target_info')
final ActivityTargetInfo? activityTargetInfo;
factory ActivityBurnStatisticsData.fromJson(Map<String, dynamic> json) =>
_$ActivityBurnStatisticsDataFromJson(json);
Map<String, dynamic> toJson() => _$ActivityBurnStatisticsDataToJson(this);
factory ActivityBurnStatisticsData.fromJson(Map<String, dynamic> json) {
return ActivityBurnStatisticsData(
totalCaloriesBurned: _parseInt(json['total_move']),
avgCaloriesBurned: _parseDouble(json['avg_move']),
maxCaloriesBurned: json['max_move'] == null
? null
: CaloriesBurnedValue.fromJson(json['max_move'] as Map<String, dynamic>),
minCaloriesBurned: json['min_move'] == null
? null
: CaloriesBurnedValue.fromJson(json['min_move'] as Map<String, dynamic>),
totalSteps: _parseInt(json['total_steps']),
totalStand: _parseInt(json['total_stand']),
caloriesBurnedTrendList: (json['move_trend_list'] as List<dynamic>?)
?.map((e) => CaloriesBurnedTrend.fromJson(e as Map<String, dynamic>))
.toList(),
exerciseTimeTrendList: (json['excercise_trend_list'] as List<dynamic>?)
?.map((e) => ExerciseTimeTrend.fromJson(e as Map<String, dynamic>))
.toList(),
activityTargetInfo: json['activity_target_info'] == null
? null
: ActivityTargetInfo.fromJson(
json['activity_target_info'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (totalCaloriesBurned != null) val['total_move'] = totalCaloriesBurned;
if (avgCaloriesBurned != null) val['avg_move'] = avgCaloriesBurned;
if (maxCaloriesBurned != null) val['max_move'] = maxCaloriesBurned!.toJson();
if (minCaloriesBurned != null) val['min_move'] = minCaloriesBurned!.toJson();
if (totalSteps != null) val['total_steps'] = totalSteps;
if (totalStand != null) val['total_stand'] = totalStand;
if (caloriesBurnedTrendList != null) {
val['move_trend_list'] =
caloriesBurnedTrendList!.map((e) => e.toJson()).toList();
}
if (exerciseTimeTrendList != null) {
val['excercise_trend_list'] =
exerciseTimeTrendList!.map((e) => e.toJson()).toList();
}
if (activityTargetInfo != null) {
val['activity_target_info'] = activityTargetInfo!.toJson();
}
return val;
}
}
@JsonSerializable()
class CaloriesBurnedValue {
const CaloriesBurnedValue({this.date, this.value});
final int? date;
final int? value;
factory CaloriesBurnedValue.fromJson(Map<String, dynamic> json) =>
_$CaloriesBurnedValueFromJson(json);
Map<String, dynamic> toJson() => _$CaloriesBurnedValueToJson(this);
factory CaloriesBurnedValue.fromJson(Map<String, dynamic> json) {
return CaloriesBurnedValue(
date: _parseInt(json['date']),
value: _parseInt(json['value']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (date != null) val['date'] = date;
if (value != null) val['value'] = value;
return val;
}
}
@JsonSerializable()
class CaloriesBurnedTrend {
const CaloriesBurnedTrend({this.timeKey, this.value});
@JsonKey(name: 'time_key')
final int? timeKey;
final int? value;
factory CaloriesBurnedTrend.fromJson(Map<String, dynamic> json) =>
_$CaloriesBurnedTrendFromJson(json);
Map<String, dynamic> toJson() => _$CaloriesBurnedTrendToJson(this);
factory CaloriesBurnedTrend.fromJson(Map<String, dynamic> json) {
return CaloriesBurnedTrend(
timeKey: _parseInt(json['time_key']),
value: _parseInt(json['value']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (timeKey != null) val['time_key'] = timeKey;
if (value != null) val['value'] = value;
return val;
}
}
@JsonSerializable()
class ExerciseTimeTrend {
const ExerciseTimeTrend({this.timeKey, this.value});
@JsonKey(name: 'time_key')
final int? timeKey;
final int? value;
factory ExerciseTimeTrend.fromJson(Map<String, dynamic> json) =>
_$ExerciseTimeTrendFromJson(json);
Map<String, dynamic> toJson() => _$ExerciseTimeTrendToJson(this);
factory ExerciseTimeTrend.fromJson(Map<String, dynamic> json) {
return ExerciseTimeTrend(
timeKey: _parseInt(json['time_key']),
value: _parseInt(json['value']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (timeKey != null) val['time_key'] = timeKey;
if (value != null) val['value'] = value;
return val;
}
}
@JsonSerializable()
class ActivityTargetInfo {
const ActivityTargetInfo({this.move, this.step, this.stand});
... ... @@ -312,12 +524,23 @@ class ActivityTargetInfo {
final int? step;
final int? stand;
factory ActivityTargetInfo.fromJson(Map<String, dynamic> json) =>
_$ActivityTargetInfoFromJson(json);
Map<String, dynamic> toJson() => _$ActivityTargetInfoToJson(this);
factory ActivityTargetInfo.fromJson(Map<String, dynamic> json) {
return ActivityTargetInfo(
move: _parseInt(json['move']),
step: _parseInt(json['step']),
stand: _parseInt(json['stand']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (move != null) val['move'] = move;
if (step != null) val['step'] = step;
if (stand != null) val['stand'] = stand;
return val;
}
}
@JsonSerializable()
class HrvStatisticsData {
const HrvStatisticsData({
this.avgHrv,
... ... @@ -329,54 +552,99 @@ class HrvStatisticsData {
this.hrvDistributionList,
});
@JsonKey(name: 'avg_hrv')
final double? avgHrv;
@JsonKey(name: 'avg_hrv_baseline')
final double? avgHrvBaseline;
@JsonKey(name: 'avg_walking_heart_rate')
final double? avgWalkingHeartRate;
@JsonKey(name: 'avg_resting_heart_rate')
final double? avgRestingHeartRate;
@JsonKey(name: 'avg_sleeping_heart_rate')
final double? avgSleepingHeartRate;
@JsonKey(name: 'hrv_trend_list')
final List<HrvTrend>? hrvTrendList;
@JsonKey(name: 'hrv_distribution_list')
final List<HrvDistribution>? hrvDistributionList;
factory HrvStatisticsData.fromJson(Map<String, dynamic> json) =>
_$HrvStatisticsDataFromJson(json);
Map<String, dynamic> toJson() => _$HrvStatisticsDataToJson(this);
factory HrvStatisticsData.fromJson(Map<String, dynamic> json) {
return HrvStatisticsData(
avgHrv: _parseDouble(json['avg_hrv']),
avgHrvBaseline: _parseDouble(json['avg_hrv_baseline']),
avgWalkingHeartRate: _parseDouble(json['avg_walking_heart_rate']),
avgRestingHeartRate: _parseDouble(json['avg_resting_heart_rate']),
avgSleepingHeartRate: _parseDouble(json['avg_sleeping_heart_rate']),
hrvTrendList: (json['hrv_trend_list'] as List<dynamic>?)
?.map((e) => HrvTrend.fromJson(e as Map<String, dynamic>))
.toList(),
hrvDistributionList: (json['hrv_distribution_list'] as List<dynamic>?)
?.map((e) => HrvDistribution.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (avgHrv != null) val['avg_hrv'] = avgHrv;
if (avgHrvBaseline != null) val['avg_hrv_baseline'] = avgHrvBaseline;
if (avgWalkingHeartRate != null) {
val['avg_walking_heart_rate'] = avgWalkingHeartRate;
}
if (avgRestingHeartRate != null) {
val['avg_resting_heart_rate'] = avgRestingHeartRate;
}
if (avgSleepingHeartRate != null) {
val['avg_sleeping_heart_rate'] = avgSleepingHeartRate;
}
if (hrvTrendList != null) {
val['hrv_trend_list'] = hrvTrendList!.map((e) => e.toJson()).toList();
}
if (hrvDistributionList != null) {
val['hrv_distribution_list'] =
hrvDistributionList!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class HrvTrend {
const HrvTrend({this.timeKey, this.average});
@JsonKey(name: 'time_key')
final int? timeKey;
final double? average;
factory HrvTrend.fromJson(Map<String, dynamic> json) =>
_$HrvTrendFromJson(json);
Map<String, dynamic> toJson() => _$HrvTrendToJson(this);
factory HrvTrend.fromJson(Map<String, dynamic> json) {
return HrvTrend(
timeKey: _parseInt(json['time_key']),
average: _parseDouble(json['average']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (timeKey != null) val['time_key'] = timeKey;
if (average != null) val['average'] = average;
return val;
}
}
@JsonSerializable()
class HrvDistribution {
const HrvDistribution({this.timeKey, this.dayCounts});
@JsonKey(name: 'time_key')
final int? timeKey;
@JsonKey(name: 'day_counts')
final HrvDistributionDayCount? dayCounts;
factory HrvDistribution.fromJson(Map<String, dynamic> json) =>
_$HrvDistributionFromJson(json);
Map<String, dynamic> toJson() => _$HrvDistributionToJson(this);
factory HrvDistribution.fromJson(Map<String, dynamic> json) {
return HrvDistribution(
timeKey: _parseInt(json['time_key']),
dayCounts: json['day_counts'] == null
? null
: HrvDistributionDayCount.fromJson(
json['day_counts'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (timeKey != null) val['time_key'] = timeKey;
if (dayCounts != null) val['day_counts'] = dayCounts!.toJson();
return val;
}
}
@JsonSerializable()
class HrvDistributionDayCount {
const HrvDistributionDayCount({
this.stressful,
... ... @@ -388,7 +656,19 @@ class HrvDistributionDayCount {
final int? normal;
final int? energetic;
factory HrvDistributionDayCount.fromJson(Map<String, dynamic> json) =>
_$HrvDistributionDayCountFromJson(json);
Map<String, dynamic> toJson() => _$HrvDistributionDayCountToJson(this);
factory HrvDistributionDayCount.fromJson(Map<String, dynamic> json) {
return HrvDistributionDayCount(
stressful: _parseInt(json['stressful']),
normal: _parseInt(json['normal']),
energetic: _parseInt(json['energetic']),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (stressful != null) val['stressful'] = stressful;
if (normal != null) val['normal'] = normal;
if (energetic != null) val['energetic'] = energetic;
return val;
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'health_models.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
TodayStatusData _$TodayStatusDataFromJson(Map<String, dynamic> json) =>
TodayStatusData(
recentData: json['recent_data'] == null
? null
: TodayStatusRecentData.fromJson(
json['recent_data'] as Map<String, dynamic>),
hrvDataList: (json['hrv_data_list'] as List<dynamic>?)
?.map((e) => TodayHrvData.fromJson(e as Map<String, dynamic>))
.toList(),
heartRateDataList: (json['heart_rate_data_list'] as List<dynamic>?)
?.map((e) => TodayHeartRateData.fromJson(e as Map<String, dynamic>))
.toList(),
spo2DataList: (json['oxygen_saturation_data_list'] as List<dynamic>?)
?.map((e) => TodaySpo2Data.fromJson(e as Map<String, dynamic>))
.toList(),
sleepDuration: (json['sleep_duration'] as num?)?.toInt(),
);
Map<String, dynamic> _$TodayStatusDataToJson(TodayStatusData instance) =>
<String, dynamic>{
if (instance.recentData?.toJson() case final value?) 'recent_data': value,
if (instance.hrvDataList?.map((e) => e.toJson()).toList()
case final value?)
'hrv_data_list': value,
if (instance.heartRateDataList?.map((e) => e.toJson()).toList()
case final value?)
'heart_rate_data_list': value,
if (instance.spo2DataList?.map((e) => e.toJson()).toList()
case final value?)
'oxygen_saturation_data_list': value,
if (instance.sleepDuration case final value?) 'sleep_duration': value,
};
TodayStatusRecentData _$TodayStatusRecentDataFromJson(
Map<String, dynamic> json) =>
TodayStatusRecentData(
heartRate: (json['heart_rate'] as num?)?.toInt(),
spo2: (json['oxygen_saturation'] as num?)?.toDouble(),
move: (json['move'] as num?)?.toInt(),
exercise: (json['exercise'] as num?)?.toInt(),
stand: (json['stand'] as num?)?.toInt(),
steps: (json['steps'] as num?)?.toInt(),
);
Map<String, dynamic> _$TodayStatusRecentDataToJson(
TodayStatusRecentData instance) =>
<String, dynamic>{
if (instance.heartRate case final value?) 'heart_rate': value,
if (instance.spo2 case final value?) 'oxygen_saturation': value,
if (instance.move case final value?) 'move': value,
if (instance.exercise case final value?) 'exercise': value,
if (instance.stand case final value?) 'stand': value,
if (instance.steps case final value?) 'steps': value,
};
TodayHrvData _$TodayHrvDataFromJson(Map<String, dynamic> json) => TodayHrvData(
time: (json['time'] as num?)?.toInt(),
value: (json['value'] as num?)?.toDouble(),
hrvBaseline: (json['hrv_baseline'] as num?)?.toDouble(),
);
Map<String, dynamic> _$TodayHrvDataToJson(TodayHrvData instance) =>
<String, dynamic>{
if (instance.time case final value?) 'time': value,
if (instance.value case final value?) 'value': value,
if (instance.hrvBaseline case final value?) 'hrv_baseline': value,
};
TodayHeartRateData _$TodayHeartRateDataFromJson(Map<String, dynamic> json) =>
TodayHeartRateData(
index: (json['bi_hour_index'] as num?)?.toInt(),
minimum: (json['minimum'] as num?)?.toInt(),
maximum: (json['maximum'] as num?)?.toInt(),
);
Map<String, dynamic> _$TodayHeartRateDataToJson(TodayHeartRateData instance) =>
<String, dynamic>{
if (instance.index case final value?) 'bi_hour_index': value,
if (instance.minimum case final value?) 'minimum': value,
if (instance.maximum case final value?) 'maximum': value,
};
TodaySpo2Data _$TodaySpo2DataFromJson(Map<String, dynamic> json) =>
TodaySpo2Data(
index: (json['bi_hour_index'] as num?)?.toInt(),
average: (json['average'] as num?)?.toDouble(),
);
Map<String, dynamic> _$TodaySpo2DataToJson(TodaySpo2Data instance) =>
<String, dynamic>{
if (instance.index case final value?) 'bi_hour_index': value,
if (instance.average case final value?) 'average': value,
};
PkCurrentMonthData _$PkCurrentMonthDataFromJson(Map<String, dynamic> json) =>
PkCurrentMonthData(
userWinAmount: (json['user_win'] as num?)?.toInt(),
partnerWinAmount: (json['pair_user_win'] as num?)?.toInt(),
todayRecord: json['data_today'] == null
? null
: PkRecord.fromJson(json['data_today'] as Map<String, dynamic>),
monthRecordList: (json['month_data_list'] as List<dynamic>?)
?.map((e) => PkRecord.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$PkCurrentMonthDataToJson(PkCurrentMonthData instance) =>
<String, dynamic>{
if (instance.userWinAmount case final value?) 'user_win': value,
if (instance.partnerWinAmount case final value?) 'pair_user_win': value,
if (instance.todayRecord?.toJson() case final value?) 'data_today': value,
if (instance.monthRecordList?.map((e) => e.toJson()).toList()
case final value?)
'month_data_list': value,
};
PkRecord _$PkRecordFromJson(Map<String, dynamic> json) => PkRecord(
date: (json['date'] as num?)?.toInt(),
userScore: (json['user_score'] as num?)?.toInt(),
userMove: (json['user_move'] as num?)?.toInt(),
userStand: (json['user_stand'] as num?)?.toInt(),
userSteps: (json['user_steps'] as num?)?.toInt(),
partnerScore: (json['pair_user_score'] as num?)?.toInt(),
partnerMove: (json['pair_user_move'] as num?)?.toInt(),
partnerStand: (json['pair_user_stand'] as num?)?.toInt(),
partnerSteps: (json['pair_user_steps'] as num?)?.toInt(),
);
Map<String, dynamic> _$PkRecordToJson(PkRecord instance) => <String, dynamic>{
if (instance.date case final value?) 'date': value,
if (instance.userScore case final value?) 'user_score': value,
if (instance.userMove case final value?) 'user_move': value,
if (instance.userStand case final value?) 'user_stand': value,
if (instance.userSteps case final value?) 'user_steps': value,
if (instance.partnerScore case final value?) 'pair_user_score': value,
if (instance.partnerMove case final value?) 'pair_user_move': value,
if (instance.partnerStand case final value?) 'pair_user_stand': value,
if (instance.partnerSteps case final value?) 'pair_user_steps': value,
};
SleepStatisticsData _$SleepStatisticsDataFromJson(Map<String, dynamic> json) =>
SleepStatisticsData(
avgSleepDuration: (json['avg_sleep_duration'] as num?)?.toInt(),
awakePercentage: (json['awake_percentage'] as num?)?.toDouble(),
corePercentage: (json['core_percentage'] as num?)?.toDouble(),
deepPercentage: (json['deep_percentage'] as num?)?.toDouble(),
remPercentage: (json['rem_percentage'] as num?)?.toDouble(),
sleepTrendList: (json['sleep_trend_list'] as List<dynamic>?)
?.map((e) => SleepTrend.fromJson(e as Map<String, dynamic>))
.toList(),
asleepTimeDistributionList: (json['asleep_time_trend_list']
as List<dynamic>?)
?.map(
(e) => AsleepTimeDistribution.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$SleepStatisticsDataToJson(
SleepStatisticsData instance) =>
<String, dynamic>{
if (instance.avgSleepDuration case final value?)
'avg_sleep_duration': value,
if (instance.awakePercentage case final value?) 'awake_percentage': value,
if (instance.corePercentage case final value?) 'core_percentage': value,
if (instance.deepPercentage case final value?) 'deep_percentage': value,
if (instance.remPercentage case final value?) 'rem_percentage': value,
if (instance.sleepTrendList?.map((e) => e.toJson()).toList()
case final value?)
'sleep_trend_list': value,
if (instance.asleepTimeDistributionList?.map((e) => e.toJson()).toList()
case final value?)
'asleep_time_trend_list': value,
};
SleepTrend _$SleepTrendFromJson(Map<String, dynamic> json) => SleepTrend(
timeKey: (json['time_key'] as num?)?.toInt(),
average: (json['average'] as num?)?.toInt(),
);
Map<String, dynamic> _$SleepTrendToJson(SleepTrend instance) =>
<String, dynamic>{
if (instance.timeKey case final value?) 'time_key': value,
if (instance.average case final value?) 'average': value,
};
AsleepTimeDistribution _$AsleepTimeDistributionFromJson(
Map<String, dynamic> json) =>
AsleepTimeDistribution(
timeKey: (json['time_key'] as num?)?.toInt(),
average: json['average'] as String?,
);
Map<String, dynamic> _$AsleepTimeDistributionToJson(
AsleepTimeDistribution instance) =>
<String, dynamic>{
if (instance.timeKey case final value?) 'time_key': value,
if (instance.average case final value?) 'average': value,
};
ActivityBurnStatisticsData _$ActivityBurnStatisticsDataFromJson(
Map<String, dynamic> json) =>
ActivityBurnStatisticsData(
totalCaloriesBurned: (json['total_move'] as num?)?.toInt(),
avgCaloriesBurned: (json['avg_move'] as num?)?.toDouble(),
maxCaloriesBurned: json['max_move'] == null
? null
: CaloriesBurnedValue.fromJson(
json['max_move'] as Map<String, dynamic>),
minCaloriesBurned: json['min_move'] == null
? null
: CaloriesBurnedValue.fromJson(
json['min_move'] as Map<String, dynamic>),
totalSteps: (json['total_steps'] as num?)?.toInt(),
totalStand: (json['total_stand'] as num?)?.toInt(),
caloriesBurnedTrendList: (json['move_trend_list'] as List<dynamic>?)
?.map((e) => CaloriesBurnedTrend.fromJson(e as Map<String, dynamic>))
.toList(),
exerciseTimeTrendList: (json['excercise_trend_list'] as List<dynamic>?)
?.map((e) => ExerciseTimeTrend.fromJson(e as Map<String, dynamic>))
.toList(),
activityTargetInfo: json['activity_target_info'] == null
? null
: ActivityTargetInfo.fromJson(
json['activity_target_info'] as Map<String, dynamic>),
);
Map<String, dynamic> _$ActivityBurnStatisticsDataToJson(
ActivityBurnStatisticsData instance) =>
<String, dynamic>{
if (instance.totalCaloriesBurned case final value?) 'total_move': value,
if (instance.avgCaloriesBurned case final value?) 'avg_move': value,
if (instance.maxCaloriesBurned?.toJson() case final value?)
'max_move': value,
if (instance.minCaloriesBurned?.toJson() case final value?)
'min_move': value,
if (instance.totalSteps case final value?) 'total_steps': value,
if (instance.totalStand case final value?) 'total_stand': value,
if (instance.caloriesBurnedTrendList?.map((e) => e.toJson()).toList()
case final value?)
'move_trend_list': value,
if (instance.exerciseTimeTrendList?.map((e) => e.toJson()).toList()
case final value?)
'excercise_trend_list': value,
if (instance.activityTargetInfo?.toJson() case final value?)
'activity_target_info': value,
};
CaloriesBurnedValue _$CaloriesBurnedValueFromJson(Map<String, dynamic> json) =>
CaloriesBurnedValue(
date: (json['date'] as num?)?.toInt(),
value: (json['value'] as num?)?.toInt(),
);
Map<String, dynamic> _$CaloriesBurnedValueToJson(
CaloriesBurnedValue instance) =>
<String, dynamic>{
if (instance.date case final value?) 'date': value,
if (instance.value case final value?) 'value': value,
};
CaloriesBurnedTrend _$CaloriesBurnedTrendFromJson(Map<String, dynamic> json) =>
CaloriesBurnedTrend(
timeKey: (json['time_key'] as num?)?.toInt(),
value: (json['value'] as num?)?.toInt(),
);
Map<String, dynamic> _$CaloriesBurnedTrendToJson(
CaloriesBurnedTrend instance) =>
<String, dynamic>{
if (instance.timeKey case final value?) 'time_key': value,
if (instance.value case final value?) 'value': value,
};
ExerciseTimeTrend _$ExerciseTimeTrendFromJson(Map<String, dynamic> json) =>
ExerciseTimeTrend(
timeKey: (json['time_key'] as num?)?.toInt(),
value: (json['value'] as num?)?.toInt(),
);
Map<String, dynamic> _$ExerciseTimeTrendToJson(ExerciseTimeTrend instance) =>
<String, dynamic>{
if (instance.timeKey case final value?) 'time_key': value,
if (instance.value case final value?) 'value': value,
};
ActivityTargetInfo _$ActivityTargetInfoFromJson(Map<String, dynamic> json) =>
ActivityTargetInfo(
move: (json['move'] as num?)?.toInt(),
step: (json['step'] as num?)?.toInt(),
stand: (json['stand'] as num?)?.toInt(),
);
Map<String, dynamic> _$ActivityTargetInfoToJson(ActivityTargetInfo instance) =>
<String, dynamic>{
if (instance.move case final value?) 'move': value,
if (instance.step case final value?) 'step': value,
if (instance.stand case final value?) 'stand': value,
};
HrvStatisticsData _$HrvStatisticsDataFromJson(Map<String, dynamic> json) =>
HrvStatisticsData(
avgHrv: (json['avg_hrv'] as num?)?.toDouble(),
avgHrvBaseline: (json['avg_hrv_baseline'] as num?)?.toDouble(),
avgWalkingHeartRate: (json['avg_walking_heart_rate'] as num?)?.toDouble(),
avgRestingHeartRate: (json['avg_resting_heart_rate'] as num?)?.toDouble(),
avgSleepingHeartRate:
(json['avg_sleeping_heart_rate'] as num?)?.toDouble(),
hrvTrendList: (json['hrv_trend_list'] as List<dynamic>?)
?.map((e) => HrvTrend.fromJson(e as Map<String, dynamic>))
.toList(),
hrvDistributionList: (json['hrv_distribution_list'] as List<dynamic>?)
?.map((e) => HrvDistribution.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$HrvStatisticsDataToJson(HrvStatisticsData instance) =>
<String, dynamic>{
if (instance.avgHrv case final value?) 'avg_hrv': value,
if (instance.avgHrvBaseline case final value?) 'avg_hrv_baseline': value,
if (instance.avgWalkingHeartRate case final value?)
'avg_walking_heart_rate': value,
if (instance.avgRestingHeartRate case final value?)
'avg_resting_heart_rate': value,
if (instance.avgSleepingHeartRate case final value?)
'avg_sleeping_heart_rate': value,
if (instance.hrvTrendList?.map((e) => e.toJson()).toList()
case final value?)
'hrv_trend_list': value,
if (instance.hrvDistributionList?.map((e) => e.toJson()).toList()
case final value?)
'hrv_distribution_list': value,
};
HrvTrend _$HrvTrendFromJson(Map<String, dynamic> json) => HrvTrend(
timeKey: (json['time_key'] as num?)?.toInt(),
average: (json['average'] as num?)?.toDouble(),
);
Map<String, dynamic> _$HrvTrendToJson(HrvTrend instance) => <String, dynamic>{
if (instance.timeKey case final value?) 'time_key': value,
if (instance.average case final value?) 'average': value,
};
HrvDistribution _$HrvDistributionFromJson(Map<String, dynamic> json) =>
HrvDistribution(
timeKey: (json['time_key'] as num?)?.toInt(),
dayCounts: json['day_counts'] == null
? null
: HrvDistributionDayCount.fromJson(
json['day_counts'] as Map<String, dynamic>),
);
Map<String, dynamic> _$HrvDistributionToJson(HrvDistribution instance) =>
<String, dynamic>{
if (instance.timeKey case final value?) 'time_key': value,
if (instance.dayCounts?.toJson() case final value?) 'day_counts': value,
};
HrvDistributionDayCount _$HrvDistributionDayCountFromJson(
Map<String, dynamic> json) =>
HrvDistributionDayCount(
stressful: (json['stressful'] as num?)?.toInt(),
normal: (json['normal'] as num?)?.toInt(),
energetic: (json['energetic'] as num?)?.toInt(),
);
Map<String, dynamic> _$HrvDistributionDayCountToJson(
HrvDistributionDayCount instance) =>
<String, dynamic>{
if (instance.stressful case final value?) 'stressful': value,
if (instance.normal case final value?) 'normal': value,
if (instance.energetic case final value?) 'energetic': value,
};
import 'package:json_annotation/json_annotation.dart';
import '../json/converters.dart';
part 'health_upload_models.g.dart';
sealed class HealthDataUploadValue {
const HealthDataUploadValue();
}
... ... @@ -18,7 +14,6 @@ final class HealthDataUploadDoubleValue extends HealthDataUploadValue {
final double value;
}
@JsonSerializable()
class HealthDataUploadItem {
const HealthDataUploadItem({
required this.dataType,
... ... @@ -26,30 +21,47 @@ class HealthDataUploadItem {
required this.time,
});
@JsonKey(name: 'data_type')
final int dataType;
@HealthDataUploadValueConverter()
final HealthDataUploadValue value;
final int time;
factory HealthDataUploadItem.fromJson(Map<String, dynamic> json) =>
_$HealthDataUploadItemFromJson(json);
Map<String, dynamic> toJson() => _$HealthDataUploadItemToJson(this);
factory HealthDataUploadItem.fromJson(Map<String, dynamic> json) {
return HealthDataUploadItem(
dataType: json['data_type'] as int,
value: const HealthDataUploadValueConverter().fromJson(json['value']),
time: json['time'] as int,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'data_type': dataType,
'value': const HealthDataUploadValueConverter().toJson(value),
'time': time,
};
}
}
@JsonSerializable()
class HealthDataUploadItemList {
const HealthDataUploadItemList({required this.itemList});
@JsonKey(name: 'data_list')
final List<HealthDataUploadItem> itemList;
factory HealthDataUploadItemList.fromJson(Map<String, dynamic> json) =>
_$HealthDataUploadItemListFromJson(json);
Map<String, dynamic> toJson() => _$HealthDataUploadItemListToJson(this);
factory HealthDataUploadItemList.fromJson(Map<String, dynamic> json) {
return HealthDataUploadItemList(
itemList: (json['data_list'] as List<dynamic>)
.map((e) => HealthDataUploadItem.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'data_list': itemList.map((e) => e.toJson()).toList(),
};
}
}
@JsonSerializable()
class SleepHealthDataUploadItem {
const SleepHealthDataUploadItem({
required this.dataType,
... ... @@ -57,97 +69,151 @@ class SleepHealthDataUploadItem {
required this.toTime,
});
@JsonKey(name: 'data_type')
final int dataType;
@JsonKey(name: 'from_time')
final int fromTime;
@JsonKey(name: 'to_time')
final int toTime;
factory SleepHealthDataUploadItem.fromJson(Map<String, dynamic> json) =>
_$SleepHealthDataUploadItemFromJson(json);
Map<String, dynamic> toJson() => _$SleepHealthDataUploadItemToJson(this);
factory SleepHealthDataUploadItem.fromJson(Map<String, dynamic> json) {
return SleepHealthDataUploadItem(
dataType: json['data_type'] as int,
fromTime: json['from_time'] as int,
toTime: json['to_time'] as int,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'data_type': dataType,
'from_time': fromTime,
'to_time': toTime,
};
}
}
@JsonSerializable()
class SleepStateHealthDataUploadItemList {
const SleepStateHealthDataUploadItemList({required this.itemList});
@JsonKey(name: 'data_list')
final List<SleepHealthDataUploadItem> itemList;
factory SleepStateHealthDataUploadItemList.fromJson(
Map<String, dynamic> json,
) =>
_$SleepStateHealthDataUploadItemListFromJson(json);
Map<String, dynamic> toJson() =>
_$SleepStateHealthDataUploadItemListToJson(this);
) {
return SleepStateHealthDataUploadItemList(
itemList: (json['data_list'] as List<dynamic>)
.map((e) =>
SleepHealthDataUploadItem.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'data_list': itemList.map((e) => e.toJson()).toList(),
};
}
}
@JsonSerializable()
class HealthDataLatestUploadRecord {
const HealthDataLatestUploadRecord({this.dataType, this.latestUploadTime});
@JsonKey(name: 'data_type')
final int? dataType;
@JsonKey(name: 'latest_data_time')
final int? latestUploadTime;
factory HealthDataLatestUploadRecord.fromJson(Map<String, dynamic> json) =>
_$HealthDataLatestUploadRecordFromJson(json);
Map<String, dynamic> toJson() => _$HealthDataLatestUploadRecordToJson(this);
factory HealthDataLatestUploadRecord.fromJson(Map<String, dynamic> json) {
return HealthDataLatestUploadRecord(
dataType: json['data_type'] as int?,
latestUploadTime: json['latest_data_time'] as int?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (dataType != null) val['data_type'] = dataType;
if (latestUploadTime != null) val['latest_data_time'] = latestUploadTime;
return val;
}
}
@JsonSerializable()
class HealthDataLatestUploadRecordList {
const HealthDataLatestUploadRecordList({this.uploadInfoList});
@JsonKey(name: 'latest_data_time_list')
final List<HealthDataLatestUploadRecord>? uploadInfoList;
factory HealthDataLatestUploadRecordList.fromJson(
Map<String, dynamic> json,
) =>
_$HealthDataLatestUploadRecordListFromJson(json);
Map<String, dynamic> toJson() =>
_$HealthDataLatestUploadRecordListToJson(this);
) {
return HealthDataLatestUploadRecordList(
uploadInfoList: (json['latest_data_time_list'] as List<dynamic>?)
?.map((e) =>
HealthDataLatestUploadRecord.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (uploadInfoList != null) {
val['latest_data_time_list'] =
uploadInfoList!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class HealthAuthRequest {
const HealthAuthRequest({required this.code});
final String code;
factory HealthAuthRequest.fromJson(Map<String, dynamic> json) =>
_$HealthAuthRequestFromJson(json);
Map<String, dynamic> toJson() => _$HealthAuthRequestToJson(this);
factory HealthAuthRequest.fromJson(Map<String, dynamic> json) {
return HealthAuthRequest(
code: json['code'] as String,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'code': code,
};
}
}
@JsonSerializable()
class HealthAuthResponse {
const HealthAuthResponse({this.scope});
final String? scope;
factory HealthAuthResponse.fromJson(Map<String, dynamic> json) =>
_$HealthAuthResponseFromJson(json);
Map<String, dynamic> toJson() => _$HealthAuthResponseToJson(this);
factory HealthAuthResponse.fromJson(Map<String, dynamic> json) {
return HealthAuthResponse(
scope: json['scope'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (scope != null) val['scope'] = scope;
return val;
}
}
@JsonSerializable()
class PulseTypeRequest {
const PulseTypeRequest({required this.pulseType});
@JsonKey(name: 'pulse_type')
final int pulseType;
factory PulseTypeRequest.fromJson(Map<String, dynamic> json) =>
_$PulseTypeRequestFromJson(json);
Map<String, dynamic> toJson() => _$PulseTypeRequestToJson(this);
factory PulseTypeRequest.fromJson(Map<String, dynamic> json) {
return PulseTypeRequest(
pulseType: json['pulse_type'] as int,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'pulse_type': pulseType,
};
}
}
@JsonSerializable()
class PulseTypeResponse {
const PulseTypeResponse({
this.id,
... ... @@ -157,19 +223,29 @@ class PulseTypeResponse {
});
final int? id;
@JsonKey(name: 'user_id')
final int? userId;
@JsonKey(name: 'pulse_type')
final int? pulseType;
@JsonKey(name: 'create_time')
final int? createTime;
factory PulseTypeResponse.fromJson(Map<String, dynamic> json) =>
_$PulseTypeResponseFromJson(json);
Map<String, dynamic> toJson() => _$PulseTypeResponseToJson(this);
factory PulseTypeResponse.fromJson(Map<String, dynamic> json) {
return PulseTypeResponse(
id: json['id'] as int?,
userId: json['user_id'] as int?,
pulseType: json['pulse_type'] as int?,
createTime: json['create_time'] as int?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (id != null) val['id'] = id;
if (userId != null) val['user_id'] = userId;
if (pulseType != null) val['pulse_type'] = pulseType;
if (createTime != null) val['create_time'] = createTime;
return val;
}
}
@JsonSerializable()
class LatestHrvData {
const LatestHrvData({
this.userHrv,
... ... @@ -178,16 +254,28 @@ class LatestHrvData {
this.partnerHrvBaseline,
});
@JsonKey(name: 'user_hrv')
final double? userHrv;
@JsonKey(name: 'user_hrv_baseline')
final double? userHrvBaseline;
@JsonKey(name: 'pair_user_hrv')
final double? partnerHrv;
@JsonKey(name: 'pair_hrv_baseline')
final double? partnerHrvBaseline;
factory LatestHrvData.fromJson(Map<String, dynamic> json) =>
_$LatestHrvDataFromJson(json);
Map<String, dynamic> toJson() => _$LatestHrvDataToJson(this);
factory LatestHrvData.fromJson(Map<String, dynamic> json) {
return LatestHrvData(
userHrv: (json['user_hrv'] as num?)?.toDouble(),
userHrvBaseline: (json['user_hrv_baseline'] as num?)?.toDouble(),
partnerHrv: (json['pair_user_hrv'] as num?)?.toDouble(),
partnerHrvBaseline: (json['pair_hrv_baseline'] as num?)?.toDouble(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (userHrv != null) val['user_hrv'] = userHrv;
if (userHrvBaseline != null) val['user_hrv_baseline'] = userHrvBaseline;
if (partnerHrv != null) val['pair_user_hrv'] = partnerHrv;
if (partnerHrvBaseline != null) {
val['pair_hrv_baseline'] = partnerHrvBaseline;
}
return val;
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'health_upload_models.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
HealthDataUploadItem _$HealthDataUploadItemFromJson(
Map<String, dynamic> json) =>
HealthDataUploadItem(
dataType: (json['data_type'] as num).toInt(),
value: const HealthDataUploadValueConverter().fromJson(json['value']),
time: (json['time'] as num).toInt(),
);
Map<String, dynamic> _$HealthDataUploadItemToJson(
HealthDataUploadItem instance) =>
<String, dynamic>{
'data_type': instance.dataType,
if (const HealthDataUploadValueConverter().toJson(instance.value)
case final value?)
'value': value,
'time': instance.time,
};
HealthDataUploadItemList _$HealthDataUploadItemListFromJson(
Map<String, dynamic> json) =>
HealthDataUploadItemList(
itemList: (json['data_list'] as List<dynamic>)
.map((e) => HealthDataUploadItem.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$HealthDataUploadItemListToJson(
HealthDataUploadItemList instance) =>
<String, dynamic>{
'data_list': instance.itemList.map((e) => e.toJson()).toList(),
};
SleepHealthDataUploadItem _$SleepHealthDataUploadItemFromJson(
Map<String, dynamic> json) =>
SleepHealthDataUploadItem(
dataType: (json['data_type'] as num).toInt(),
fromTime: (json['from_time'] as num).toInt(),
toTime: (json['to_time'] as num).toInt(),
);
Map<String, dynamic> _$SleepHealthDataUploadItemToJson(
SleepHealthDataUploadItem instance) =>
<String, dynamic>{
'data_type': instance.dataType,
'from_time': instance.fromTime,
'to_time': instance.toTime,
};
SleepStateHealthDataUploadItemList _$SleepStateHealthDataUploadItemListFromJson(
Map<String, dynamic> json) =>
SleepStateHealthDataUploadItemList(
itemList: (json['data_list'] as List<dynamic>)
.map((e) =>
SleepHealthDataUploadItem.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$SleepStateHealthDataUploadItemListToJson(
SleepStateHealthDataUploadItemList instance) =>
<String, dynamic>{
'data_list': instance.itemList.map((e) => e.toJson()).toList(),
};
HealthDataLatestUploadRecord _$HealthDataLatestUploadRecordFromJson(
Map<String, dynamic> json) =>
HealthDataLatestUploadRecord(
dataType: (json['data_type'] as num?)?.toInt(),
latestUploadTime: (json['latest_data_time'] as num?)?.toInt(),
);
Map<String, dynamic> _$HealthDataLatestUploadRecordToJson(
HealthDataLatestUploadRecord instance) =>
<String, dynamic>{
if (instance.dataType case final value?) 'data_type': value,
if (instance.latestUploadTime case final value?)
'latest_data_time': value,
};
HealthDataLatestUploadRecordList _$HealthDataLatestUploadRecordListFromJson(
Map<String, dynamic> json) =>
HealthDataLatestUploadRecordList(
uploadInfoList: (json['latest_data_time_list'] as List<dynamic>?)
?.map((e) =>
HealthDataLatestUploadRecord.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$HealthDataLatestUploadRecordListToJson(
HealthDataLatestUploadRecordList instance) =>
<String, dynamic>{
if (instance.uploadInfoList?.map((e) => e.toJson()).toList()
case final value?)
'latest_data_time_list': value,
};
HealthAuthRequest _$HealthAuthRequestFromJson(Map<String, dynamic> json) =>
HealthAuthRequest(
code: json['code'] as String,
);
Map<String, dynamic> _$HealthAuthRequestToJson(HealthAuthRequest instance) =>
<String, dynamic>{
'code': instance.code,
};
HealthAuthResponse _$HealthAuthResponseFromJson(Map<String, dynamic> json) =>
HealthAuthResponse(
scope: json['scope'] as String?,
);
Map<String, dynamic> _$HealthAuthResponseToJson(HealthAuthResponse instance) =>
<String, dynamic>{
if (instance.scope case final value?) 'scope': value,
};
PulseTypeRequest _$PulseTypeRequestFromJson(Map<String, dynamic> json) =>
PulseTypeRequest(
pulseType: (json['pulse_type'] as num).toInt(),
);
Map<String, dynamic> _$PulseTypeRequestToJson(PulseTypeRequest instance) =>
<String, dynamic>{
'pulse_type': instance.pulseType,
};
PulseTypeResponse _$PulseTypeResponseFromJson(Map<String, dynamic> json) =>
PulseTypeResponse(
id: (json['id'] as num?)?.toInt(),
userId: (json['user_id'] as num?)?.toInt(),
pulseType: (json['pulse_type'] as num?)?.toInt(),
createTime: (json['create_time'] as num?)?.toInt(),
);
Map<String, dynamic> _$PulseTypeResponseToJson(PulseTypeResponse instance) =>
<String, dynamic>{
if (instance.id case final value?) 'id': value,
if (instance.userId case final value?) 'user_id': value,
if (instance.pulseType case final value?) 'pulse_type': value,
if (instance.createTime case final value?) 'create_time': value,
};
LatestHrvData _$LatestHrvDataFromJson(Map<String, dynamic> json) =>
LatestHrvData(
userHrv: (json['user_hrv'] as num?)?.toDouble(),
userHrvBaseline: (json['user_hrv_baseline'] as num?)?.toDouble(),
partnerHrv: (json['pair_user_hrv'] as num?)?.toDouble(),
partnerHrvBaseline: (json['pair_hrv_baseline'] as num?)?.toDouble(),
);
Map<String, dynamic> _$LatestHrvDataToJson(LatestHrvData instance) =>
<String, dynamic>{
if (instance.userHrv case final value?) 'user_hrv': value,
if (instance.userHrvBaseline case final value?)
'user_hrv_baseline': value,
if (instance.partnerHrv case final value?) 'pair_user_hrv': value,
if (instance.partnerHrvBaseline case final value?)
'pair_hrv_baseline': value,
};
import 'package:json_annotation/json_annotation.dart';
part 'interaction_models.g.dart';
@JsonSerializable()
class InteractionData {
const InteractionData({
this.interactionType,
... ... @@ -10,30 +5,52 @@ class InteractionData {
this.action,
});
@JsonKey(name: 'interaction_type')
final int? interactionType;
@JsonKey(name: 'action_type')
final int? actionType;
@JsonKey(name: 'action_variables')
final InteractionDataAction? action;
factory InteractionData.fromJson(Map<String, dynamic> json) =>
_$InteractionDataFromJson(json);
Map<String, dynamic> toJson() => _$InteractionDataToJson(this);
factory InteractionData.fromJson(Map<String, dynamic> json) {
return InteractionData(
interactionType: json['interaction_type'] as int?,
actionType: json['action_type'] as int?,
action: json['action_variables'] == null
? null
: InteractionDataAction.fromJson(
json['action_variables'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (interactionType != null) val['interaction_type'] = interactionType;
if (actionType != null) val['action_type'] = actionType;
if (action != null) val['action_variables'] = action!.toJson();
return val;
}
}
@JsonSerializable()
class InteractionRecordResponse {
const InteractionRecordResponse({this.records});
final List<InteractionRecord>? records;
factory InteractionRecordResponse.fromJson(Map<String, dynamic> json) =>
_$InteractionRecordResponseFromJson(json);
Map<String, dynamic> toJson() => _$InteractionRecordResponseToJson(this);
factory InteractionRecordResponse.fromJson(Map<String, dynamic> json) {
return InteractionRecordResponse(
records: (json['records'] as List<dynamic>?)
?.map((e) => InteractionRecord.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (records != null) {
val['records'] = records!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class InteractionRecord {
const InteractionRecord({
this.id,
... ... @@ -47,26 +64,44 @@ class InteractionRecord {
});
final int? id;
@JsonKey(name: 'create_time')
final int? createTime;
@JsonKey(name: 'user_id')
final int? userId;
@JsonKey(name: 'pair_id')
final int? pairId;
@JsonKey(name: 'interaction_type')
final int? interactionType;
@JsonKey(name: 'action_type')
final int? actionType;
@JsonKey(name: 'action_variables')
final InteractionDataAction? action;
final String? text;
factory InteractionRecord.fromJson(Map<String, dynamic> json) =>
_$InteractionRecordFromJson(json);
Map<String, dynamic> toJson() => _$InteractionRecordToJson(this);
factory InteractionRecord.fromJson(Map<String, dynamic> json) {
return InteractionRecord(
id: json['id'] as int?,
createTime: json['create_time'] as int?,
userId: json['user_id'] as int?,
pairId: json['pair_id'] as int?,
interactionType: json['interaction_type'] as int?,
actionType: json['action_type'] as int?,
action: json['action_variables'] == null
? null
: InteractionDataAction.fromJson(
json['action_variables'] as Map<String, dynamic>),
text: json['text'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (id != null) val['id'] = id;
if (createTime != null) val['create_time'] = createTime;
if (userId != null) val['user_id'] = userId;
if (pairId != null) val['pair_id'] = pairId;
if (interactionType != null) val['interaction_type'] = interactionType;
if (actionType != null) val['action_type'] = actionType;
if (action != null) val['action_variables'] = action!.toJson();
if (text != null) val['text'] = text;
return val;
}
}
@JsonSerializable()
class InteractionDataAction {
const InteractionDataAction({
this.objectTarget,
... ... @@ -78,21 +113,35 @@ class InteractionDataAction {
this.action,
});
@JsonKey(name: 'object')
final int? objectTarget;
@JsonKey(name: 'data_status')
final String? status;
@JsonKey(name: 'data_type')
final String? type;
@JsonKey(name: 'data_date')
final String? date;
@JsonKey(name: 'data_value')
final String? value;
@JsonKey(name: 'data_unit')
final String? unit;
final String? action;
factory InteractionDataAction.fromJson(Map<String, dynamic> json) =>
_$InteractionDataActionFromJson(json);
Map<String, dynamic> toJson() => _$InteractionDataActionToJson(this);
factory InteractionDataAction.fromJson(Map<String, dynamic> json) {
return InteractionDataAction(
objectTarget: json['object'] as int?,
status: json['data_status'] as String?,
type: json['data_type'] as String?,
date: json['data_date'] as String?,
value: json['data_value'] as String?,
unit: json['data_unit'] as String?,
action: json['action'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (objectTarget != null) val['object'] = objectTarget;
if (status != null) val['data_status'] = status;
if (type != null) val['data_type'] = type;
if (date != null) val['data_date'] = date;
if (value != null) val['data_value'] = value;
if (unit != null) val['data_unit'] = unit;
if (action != null) val['action'] = action;
return val;
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'interaction_models.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
InteractionData _$InteractionDataFromJson(Map<String, dynamic> json) =>
InteractionData(
interactionType: (json['interaction_type'] as num?)?.toInt(),
actionType: (json['action_type'] as num?)?.toInt(),
action: json['action_variables'] == null
? null
: InteractionDataAction.fromJson(
json['action_variables'] as Map<String, dynamic>),
);
Map<String, dynamic> _$InteractionDataToJson(InteractionData instance) =>
<String, dynamic>{
if (instance.interactionType case final value?) 'interaction_type': value,
if (instance.actionType case final value?) 'action_type': value,
if (instance.action?.toJson() case final value?)
'action_variables': value,
};
InteractionRecordResponse _$InteractionRecordResponseFromJson(
Map<String, dynamic> json) =>
InteractionRecordResponse(
records: (json['records'] as List<dynamic>?)
?.map((e) => InteractionRecord.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$InteractionRecordResponseToJson(
InteractionRecordResponse instance) =>
<String, dynamic>{
if (instance.records?.map((e) => e.toJson()).toList() case final value?)
'records': value,
};
InteractionRecord _$InteractionRecordFromJson(Map<String, dynamic> json) =>
InteractionRecord(
id: (json['id'] as num?)?.toInt(),
createTime: (json['create_time'] as num?)?.toInt(),
userId: (json['user_id'] as num?)?.toInt(),
pairId: (json['pair_id'] as num?)?.toInt(),
interactionType: (json['interaction_type'] as num?)?.toInt(),
actionType: (json['action_type'] as num?)?.toInt(),
action: json['action_variables'] == null
? null
: InteractionDataAction.fromJson(
json['action_variables'] as Map<String, dynamic>),
text: json['text'] as String?,
);
Map<String, dynamic> _$InteractionRecordToJson(InteractionRecord instance) =>
<String, dynamic>{
if (instance.id case final value?) 'id': value,
if (instance.createTime case final value?) 'create_time': value,
if (instance.userId case final value?) 'user_id': value,
if (instance.pairId case final value?) 'pair_id': value,
if (instance.interactionType case final value?) 'interaction_type': value,
if (instance.actionType case final value?) 'action_type': value,
if (instance.action?.toJson() case final value?)
'action_variables': value,
if (instance.text case final value?) 'text': value,
};
InteractionDataAction _$InteractionDataActionFromJson(
Map<String, dynamic> json) =>
InteractionDataAction(
objectTarget: (json['object'] as num?)?.toInt(),
status: json['data_status'] as String?,
type: json['data_type'] as String?,
date: json['data_date'] as String?,
value: json['data_value'] as String?,
unit: json['data_unit'] as String?,
action: json['action'] as String?,
);
Map<String, dynamic> _$InteractionDataActionToJson(
InteractionDataAction instance) =>
<String, dynamic>{
if (instance.objectTarget case final value?) 'object': value,
if (instance.status case final value?) 'data_status': value,
if (instance.type case final value?) 'data_type': value,
if (instance.date case final value?) 'data_date': value,
if (instance.value case final value?) 'data_value': value,
if (instance.unit case final value?) 'data_unit': value,
if (instance.action case final value?) 'action': value,
};
import 'package:json_annotation/json_annotation.dart';
import '../health/health_upload_models.dart';
class HealthDataUploadValueConverter
implements JsonConverter<HealthDataUploadValue, Object?> {
class HealthDataUploadValueConverter {
const HealthDataUploadValueConverter();
@override
HealthDataUploadValue fromJson(Object? json) {
if (json is int) {
return HealthDataUploadIntValue(json);
... ... @@ -22,7 +18,6 @@ class HealthDataUploadValueConverter
throw FormatException('Invalid HealthDataUploadValue: $json');
}
@override
Object toJson(HealthDataUploadValue object) => switch (object) {
HealthDataUploadIntValue(:final value) => value,
HealthDataUploadDoubleValue(:final value) => value,
... ...
import 'package:json_annotation/json_annotation.dart';
import '../user/user_models.dart';
import '../vip/vip_info.dart';
part 'user_preferences.g.dart';
/// Local session snapshot.
@JsonSerializable()
class UserPreferences {
const UserPreferences({
this.meUserInfo,
... ... @@ -16,22 +11,44 @@ class UserPreferences {
this.vipInfo,
});
@JsonKey(name: 'me_user_info')
final UserInfoResponse? meUserInfo;
@JsonKey(name: 'partner_user_info')
final UserInfoResponse? partnerUserInfo;
@JsonKey(name: 'access_token')
final String accessToken;
@JsonKey(name: 'rongcloud_token')
final String rongcloudToken;
@JsonKey(name: 'vip_info')
final UserPreferencesVipInfo? vipInfo;
static const empty = UserPreferences();
factory UserPreferences.fromJson(Map<String, dynamic> json) =>
_$UserPreferencesFromJson(json);
Map<String, dynamic> toJson() => _$UserPreferencesToJson(this);
factory UserPreferences.fromJson(Map<String, dynamic> json) {
return UserPreferences(
meUserInfo: json['me_user_info'] == null
? null
: UserInfoResponse.fromJson(
json['me_user_info'] as Map<String, dynamic>),
partnerUserInfo: json['partner_user_info'] == null
? null
: UserInfoResponse.fromJson(
json['partner_user_info'] as Map<String, dynamic>),
accessToken: (json['access_token'] as String?) ?? '',
rongcloudToken: (json['rongcloud_token'] as String?) ?? '',
vipInfo: json['vip_info'] == null
? null
: UserPreferencesVipInfo.fromJson(
json['vip_info'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (meUserInfo != null) val['me_user_info'] = meUserInfo!.toJson();
if (partnerUserInfo != null) {
val['partner_user_info'] = partnerUserInfo!.toJson();
}
val['access_token'] = accessToken;
val['rongcloud_token'] = rongcloudToken;
if (vipInfo != null) val['vip_info'] = vipInfo!.toJson();
return val;
}
UserPreferences copyWith({
UserInfoResponse? meUserInfo,
... ... @@ -52,7 +69,6 @@ class UserPreferences {
}
}
@JsonSerializable()
class UserPreferencesVipInfo {
const UserPreferencesVipInfo({
this.isVip = false,
... ... @@ -62,20 +78,31 @@ class UserPreferencesVipInfo {
this.vipEndDate = 0,
});
@JsonKey(name: 'is_vip')
final bool isVip;
@JsonKey(name: 'is_forever_vip')
final bool isForeverVip;
@JsonKey(name: 'is_share')
final bool isShare;
@JsonKey(name: 'vip_start_date')
final int vipStartDate;
@JsonKey(name: 'vip_end_date')
final int vipEndDate;
factory UserPreferencesVipInfo.fromJson(Map<String, dynamic> json) =>
_$UserPreferencesVipInfoFromJson(json);
Map<String, dynamic> toJson() => _$UserPreferencesVipInfoToJson(this);
factory UserPreferencesVipInfo.fromJson(Map<String, dynamic> json) {
return UserPreferencesVipInfo(
isVip: (json['is_vip'] as bool?) ?? false,
isForeverVip: (json['is_forever_vip'] as bool?) ?? false,
isShare: (json['is_share'] as bool?) ?? false,
vipStartDate: (json['vip_start_date'] as num?)?.toInt() ?? 0,
vipEndDate: (json['vip_end_date'] as num?)?.toInt() ?? 0,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'is_vip': isVip,
'is_forever_vip': isForeverVip,
'is_share': isShare,
'vip_start_date': vipStartDate,
'vip_end_date': vipEndDate,
};
}
factory UserPreferencesVipInfo.fromVipInfo(VipInfo info) {
return UserPreferencesVipInfo(
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_preferences.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UserPreferences _$UserPreferencesFromJson(Map<String, dynamic> json) =>
UserPreferences(
meUserInfo: json['me_user_info'] == null
? null
: UserInfoResponse.fromJson(
json['me_user_info'] as Map<String, dynamic>),
partnerUserInfo: json['partner_user_info'] == null
? null
: UserInfoResponse.fromJson(
json['partner_user_info'] as Map<String, dynamic>),
accessToken: json['access_token'] as String? ?? '',
rongcloudToken: json['rongcloud_token'] as String? ?? '',
vipInfo: json['vip_info'] == null
? null
: UserPreferencesVipInfo.fromJson(
json['vip_info'] as Map<String, dynamic>),
);
Map<String, dynamic> _$UserPreferencesToJson(UserPreferences instance) =>
<String, dynamic>{
if (instance.meUserInfo?.toJson() case final value?)
'me_user_info': value,
if (instance.partnerUserInfo?.toJson() case final value?)
'partner_user_info': value,
'access_token': instance.accessToken,
'rongcloud_token': instance.rongcloudToken,
if (instance.vipInfo?.toJson() case final value?) 'vip_info': value,
};
UserPreferencesVipInfo _$UserPreferencesVipInfoFromJson(
Map<String, dynamic> json) =>
UserPreferencesVipInfo(
isVip: json['is_vip'] as bool? ?? false,
isForeverVip: json['is_forever_vip'] as bool? ?? false,
isShare: json['is_share'] as bool? ?? false,
vipStartDate: (json['vip_start_date'] as num?)?.toInt() ?? 0,
vipEndDate: (json['vip_end_date'] as num?)?.toInt() ?? 0,
);
Map<String, dynamic> _$UserPreferencesVipInfoToJson(
UserPreferencesVipInfo instance) =>
<String, dynamic>{
'is_vip': instance.isVip,
'is_forever_vip': instance.isForeverVip,
'is_share': instance.isShare,
'vip_start_date': instance.vipStartDate,
'vip_end_date': instance.vipEndDate,
};
import 'package:json_annotation/json_annotation.dart';
part 'obs_models.g.dart';
@JsonSerializable()
class ObsTokenRequest {
const ObsTokenRequest({
this.source = 'doublefeel',
... ... @@ -12,17 +7,29 @@ class ObsTokenRequest {
});
final String source;
@JsonKey(name: 'file_type')
final String fileType;
final int count;
final String scene;
factory ObsTokenRequest.fromJson(Map<String, dynamic> json) =>
_$ObsTokenRequestFromJson(json);
Map<String, dynamic> toJson() => _$ObsTokenRequestToJson(this);
factory ObsTokenRequest.fromJson(Map<String, dynamic> json) {
return ObsTokenRequest(
source: (json['source'] as String?) ?? 'doublefeel',
fileType: json['file_type'] as String,
count: json['count'] as int,
scene: json['scene'] as String,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'source': source,
'file_type': fileType,
'count': count,
'scene': scene,
};
}
}
@JsonSerializable()
class ObsTokenResponse {
const ObsTokenResponse({
this.keys,
... ... @@ -35,16 +42,32 @@ class ObsTokenResponse {
final List<String>? keys;
final ObsToken? token;
final String? host;
@JsonKey(name: 'endpoint')
final String? endPoint;
final String? bucket;
factory ObsTokenResponse.fromJson(Map<String, dynamic> json) =>
_$ObsTokenResponseFromJson(json);
Map<String, dynamic> toJson() => _$ObsTokenResponseToJson(this);
factory ObsTokenResponse.fromJson(Map<String, dynamic> json) {
return ObsTokenResponse(
keys: (json['keys'] as List<dynamic>?)?.map((e) => e as String).toList(),
token: json['token'] == null
? null
: ObsToken.fromJson(json['token'] as Map<String, dynamic>),
host: json['host'] as String?,
endPoint: json['endpoint'] as String?,
bucket: json['bucket'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (keys != null) val['keys'] = keys;
if (token != null) val['token'] = token!.toJson();
if (host != null) val['host'] = host;
if (endPoint != null) val['endpoint'] = endPoint;
if (bucket != null) val['bucket'] = bucket;
return val;
}
}
@JsonSerializable()
class ObsToken {
const ObsToken({
this.accessKey,
... ... @@ -53,15 +76,26 @@ class ObsToken {
this.expiration,
});
@JsonKey(name: 'access_key')
final String? accessKey;
@JsonKey(name: 'secret_key')
final String? secretKey;
@JsonKey(name: 'security_token')
final String? securityToken;
final String? expiration;
factory ObsToken.fromJson(Map<String, dynamic> json) =>
_$ObsTokenFromJson(json);
Map<String, dynamic> toJson() => _$ObsTokenToJson(this);
factory ObsToken.fromJson(Map<String, dynamic> json) {
return ObsToken(
accessKey: json['access_key'] as String?,
secretKey: json['secret_key'] as String?,
securityToken: json['security_token'] as String?,
expiration: json['expiration'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (accessKey != null) val['access_key'] = accessKey;
if (secretKey != null) val['secret_key'] = secretKey;
if (securityToken != null) val['security_token'] = securityToken;
if (expiration != null) val['expiration'] = expiration;
return val;
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'obs_models.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ObsTokenRequest _$ObsTokenRequestFromJson(Map<String, dynamic> json) =>
ObsTokenRequest(
source: json['source'] as String? ?? 'doublefeel',
fileType: json['file_type'] as String,
count: (json['count'] as num).toInt(),
scene: json['scene'] as String,
);
Map<String, dynamic> _$ObsTokenRequestToJson(ObsTokenRequest instance) =>
<String, dynamic>{
'source': instance.source,
'file_type': instance.fileType,
'count': instance.count,
'scene': instance.scene,
};
ObsTokenResponse _$ObsTokenResponseFromJson(Map<String, dynamic> json) =>
ObsTokenResponse(
keys: (json['keys'] as List<dynamic>?)?.map((e) => e as String).toList(),
token: json['token'] == null
? null
: ObsToken.fromJson(json['token'] as Map<String, dynamic>),
host: json['host'] as String?,
endPoint: json['endpoint'] as String?,
bucket: json['bucket'] as String?,
);
Map<String, dynamic> _$ObsTokenResponseToJson(ObsTokenResponse instance) =>
<String, dynamic>{
if (instance.keys case final value?) 'keys': value,
if (instance.token?.toJson() case final value?) 'token': value,
if (instance.host case final value?) 'host': value,
if (instance.endPoint case final value?) 'endpoint': value,
if (instance.bucket case final value?) 'bucket': value,
};
ObsToken _$ObsTokenFromJson(Map<String, dynamic> json) => ObsToken(
accessKey: json['access_key'] as String?,
secretKey: json['secret_key'] as String?,
securityToken: json['security_token'] as String?,
expiration: json['expiration'] as String?,
);
Map<String, dynamic> _$ObsTokenToJson(ObsToken instance) => <String, dynamic>{
if (instance.accessKey case final value?) 'access_key': value,
if (instance.secretKey case final value?) 'secret_key': value,
if (instance.securityToken case final value?) 'security_token': value,
if (instance.expiration case final value?) 'expiration': value,
};
import 'package:json_annotation/json_annotation.dart';
part 'pay_models.g.dart';
@JsonSerializable()
class PayProductListResponse {
const PayProductListResponse({this.productList});
@JsonKey(name: 'product_list')
final List<PayProduct>? productList;
factory PayProductListResponse.fromJson(Map<String, dynamic> json) =>
_$PayProductListResponseFromJson(json);
Map<String, dynamic> toJson() => _$PayProductListResponseToJson(this);
factory PayProductListResponse.fromJson(Map<String, dynamic> json) {
return PayProductListResponse(
productList: (json['product_list'] as List<dynamic>?)
?.map((e) => PayProduct.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (productList != null) {
val['product_list'] = productList!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class PayProduct {
const PayProduct({
this.id,
... ... @@ -33,21 +38,42 @@ class PayProduct {
final String? profile;
final PayProductContent? content;
final int? price;
@JsonKey(name: 'serve_period')
final int? servePeriod;
@JsonKey(name: 'discount_price')
final int? discountPrice;
@JsonKey(name: 'discount_start_time')
final int? discountStartTime;
@JsonKey(name: 'discount_end_time')
final int? discountEndTime;
factory PayProduct.fromJson(Map<String, dynamic> json) =>
_$PayProductFromJson(json);
Map<String, dynamic> toJson() => _$PayProductToJson(this);
factory PayProduct.fromJson(Map<String, dynamic> json) {
return PayProduct(
id: json['id'] as int?,
name: json['name'] as String?,
profile: json['profile'] as String?,
content: json['content'] == null
? null
: PayProductContent.fromJson(json['content'] as Map<String, dynamic>),
price: json['price'] as int?,
servePeriod: json['serve_period'] as int?,
discountPrice: json['discount_price'] as int?,
discountStartTime: json['discount_start_time'] as int?,
discountEndTime: json['discount_end_time'] as int?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (id != null) val['id'] = id;
if (name != null) val['name'] = name;
if (profile != null) val['profile'] = profile;
if (content != null) val['content'] = content!.toJson();
if (price != null) val['price'] = price;
if (servePeriod != null) val['serve_period'] = servePeriod;
if (discountPrice != null) val['discount_price'] = discountPrice;
if (discountStartTime != null) val['discount_start_time'] = discountStartTime;
if (discountEndTime != null) val['discount_end_time'] = discountEndTime;
return val;
}
}
@JsonSerializable()
class PayProductContent {
const PayProductContent({
this.type,
... ... @@ -59,20 +85,35 @@ class PayProductContent {
});
final int? type;
@JsonKey(name: 'vip_days')
final int? vipDays;
final String? label;
final String? description;
@JsonKey(name: 'is_forever')
final int? isForever;
final int? share;
factory PayProductContent.fromJson(Map<String, dynamic> json) =>
_$PayProductContentFromJson(json);
Map<String, dynamic> toJson() => _$PayProductContentToJson(this);
factory PayProductContent.fromJson(Map<String, dynamic> json) {
return PayProductContent(
type: json['type'] as int?,
vipDays: json['vip_days'] as int?,
label: json['label'] as String?,
description: json['description'] as String?,
isForever: json['is_forever'] as int?,
share: json['share'] as int?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (type != null) val['type'] = type;
if (vipDays != null) val['vip_days'] = vipDays;
if (label != null) val['label'] = label;
if (description != null) val['description'] = description;
if (isForever != null) val['is_forever'] = isForever;
if (share != null) val['share'] = share;
return val;
}
}
@JsonSerializable()
class CreatePayOrderRequest {
const CreatePayOrderRequest({
required this.productId,
... ... @@ -80,46 +121,67 @@ class CreatePayOrderRequest {
this.paymentChannel = 2,
});
@JsonKey(name: 'product_id')
final int productId;
@JsonKey(name: 'product_channel')
final int productChannel;
@JsonKey(name: 'payment_channel')
final int paymentChannel;
factory CreatePayOrderRequest.fromJson(Map<String, dynamic> json) =>
_$CreatePayOrderRequestFromJson(json);
Map<String, dynamic> toJson() => _$CreatePayOrderRequestToJson(this);
factory CreatePayOrderRequest.fromJson(Map<String, dynamic> json) {
return CreatePayOrderRequest(
productId: json['product_id'] as int,
productChannel: (json['product_channel'] as int?) ?? 1,
paymentChannel: (json['payment_channel'] as int?) ?? 2,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'product_id': productId,
'product_channel': productChannel,
'payment_channel': paymentChannel,
};
}
}
@JsonSerializable()
class CreatePayOrderResponse {
const CreatePayOrderResponse({this.prepayData});
@JsonKey(name: 'prepay_data')
final String? prepayData;
factory CreatePayOrderResponse.fromJson(Map<String, dynamic> json) =>
_$CreatePayOrderResponseFromJson(json);
Map<String, dynamic> toJson() => _$CreatePayOrderResponseToJson(this);
factory CreatePayOrderResponse.fromJson(Map<String, dynamic> json) {
return CreatePayOrderResponse(
prepayData: json['prepay_data'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (prepayData != null) val['prepay_data'] = prepayData;
return val;
}
}
@JsonSerializable()
class SubscriptionProductListResponse {
const SubscriptionProductListResponse({this.productList});
@JsonKey(name: 'subscription_list')
final List<SubscriptionProduct>? productList;
factory SubscriptionProductListResponse.fromJson(
Map<String, dynamic> json,
) =>
_$SubscriptionProductListResponseFromJson(json);
Map<String, dynamic> toJson() =>
_$SubscriptionProductListResponseToJson(this);
factory SubscriptionProductListResponse.fromJson(Map<String, dynamic> json) {
return SubscriptionProductListResponse(
productList: (json['subscription_list'] as List<dynamic>?)
?.map((e) => SubscriptionProduct.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (productList != null) {
val['subscription_list'] = productList!.map((e) => e.toJson()).toList();
}
return val;
}
}
@JsonSerializable()
class SubscriptionProduct {
const SubscriptionProduct({
this.agreementNo,
... ... @@ -129,41 +191,68 @@ class SubscriptionProduct {
this.productInfo,
});
@JsonKey(name: 'agreement_no')
final String? agreementNo;
@JsonKey(name: 'last_execute_timestamp')
final int? startTime;
@JsonKey(name: 'next_execute_timestamp')
final int? endTime;
@JsonKey(name: 'single_amount')
final int? nextPayPrice;
@JsonKey(name: 'product_info')
final SubscriptionProductInfo? productInfo;
factory SubscriptionProduct.fromJson(Map<String, dynamic> json) =>
_$SubscriptionProductFromJson(json);
Map<String, dynamic> toJson() => _$SubscriptionProductToJson(this);
factory SubscriptionProduct.fromJson(Map<String, dynamic> json) {
return SubscriptionProduct(
agreementNo: json['agreement_no'] as String?,
startTime: json['last_execute_timestamp'] as int?,
endTime: json['next_execute_timestamp'] as int?,
nextPayPrice: json['single_amount'] as int?,
productInfo: json['product_info'] == null
? null
: SubscriptionProductInfo.fromJson(
json['product_info'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (agreementNo != null) val['agreement_no'] = agreementNo;
if (startTime != null) val['last_execute_timestamp'] = startTime;
if (endTime != null) val['next_execute_timestamp'] = endTime;
if (nextPayPrice != null) val['single_amount'] = nextPayPrice;
if (productInfo != null) val['product_info'] = productInfo!.toJson();
return val;
}
}
@JsonSerializable()
class SubscriptionProductInfo {
const SubscriptionProductInfo({this.name});
final String? name;
factory SubscriptionProductInfo.fromJson(Map<String, dynamic> json) =>
_$SubscriptionProductInfoFromJson(json);
Map<String, dynamic> toJson() => _$SubscriptionProductInfoToJson(this);
factory SubscriptionProductInfo.fromJson(Map<String, dynamic> json) {
return SubscriptionProductInfo(
name: json['name'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (name != null) val['name'] = name;
return val;
}
}
@JsonSerializable()
class SubscriptionCancelRequest {
const SubscriptionCancelRequest({required this.agreementNo});
@JsonKey(name: 'agreement_no')
final String agreementNo;
factory SubscriptionCancelRequest.fromJson(Map<String, dynamic> json) =>
_$SubscriptionCancelRequestFromJson(json);
Map<String, dynamic> toJson() => _$SubscriptionCancelRequestToJson(this);
factory SubscriptionCancelRequest.fromJson(Map<String, dynamic> json) {
return SubscriptionCancelRequest(
agreementNo: json['agreement_no'] as String,
);
}
Map<String, dynamic> toJson() {
return <String, dynamic>{
'agreement_no': agreementNo,
};
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'pay_models.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
PayProductListResponse _$PayProductListResponseFromJson(
Map<String, dynamic> json) =>
PayProductListResponse(
productList: (json['product_list'] as List<dynamic>?)
?.map((e) => PayProduct.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$PayProductListResponseToJson(
PayProductListResponse instance) =>
<String, dynamic>{
if (instance.productList?.map((e) => e.toJson()).toList()
case final value?)
'product_list': value,
};
PayProduct _$PayProductFromJson(Map<String, dynamic> json) => PayProduct(
id: (json['id'] as num?)?.toInt(),
name: json['name'] as String?,
profile: json['profile'] as String?,
content: json['content'] == null
? null
: PayProductContent.fromJson(json['content'] as Map<String, dynamic>),
price: (json['price'] as num?)?.toInt(),
servePeriod: (json['serve_period'] as num?)?.toInt(),
discountPrice: (json['discount_price'] as num?)?.toInt(),
discountStartTime: (json['discount_start_time'] as num?)?.toInt(),
discountEndTime: (json['discount_end_time'] as num?)?.toInt(),
);
Map<String, dynamic> _$PayProductToJson(PayProduct instance) =>
<String, dynamic>{
if (instance.id case final value?) 'id': value,
if (instance.name case final value?) 'name': value,
if (instance.profile case final value?) 'profile': value,
if (instance.content?.toJson() case final value?) 'content': value,
if (instance.price case final value?) 'price': value,
if (instance.servePeriod case final value?) 'serve_period': value,
if (instance.discountPrice case final value?) 'discount_price': value,
if (instance.discountStartTime case final value?)
'discount_start_time': value,
if (instance.discountEndTime case final value?)
'discount_end_time': value,
};
PayProductContent _$PayProductContentFromJson(Map<String, dynamic> json) =>
PayProductContent(
type: (json['type'] as num?)?.toInt(),
vipDays: (json['vip_days'] as num?)?.toInt(),
label: json['label'] as String?,
description: json['description'] as String?,
isForever: (json['is_forever'] as num?)?.toInt(),
share: (json['share'] as num?)?.toInt(),
);
Map<String, dynamic> _$PayProductContentToJson(PayProductContent instance) =>
<String, dynamic>{
if (instance.type case final value?) 'type': value,
if (instance.vipDays case final value?) 'vip_days': value,
if (instance.label case final value?) 'label': value,
if (instance.description case final value?) 'description': value,
if (instance.isForever case final value?) 'is_forever': value,
if (instance.share case final value?) 'share': value,
};
CreatePayOrderRequest _$CreatePayOrderRequestFromJson(
Map<String, dynamic> json) =>
CreatePayOrderRequest(
productId: (json['product_id'] as num).toInt(),
productChannel: (json['product_channel'] as num?)?.toInt() ?? 1,
paymentChannel: (json['payment_channel'] as num?)?.toInt() ?? 2,
);
Map<String, dynamic> _$CreatePayOrderRequestToJson(
CreatePayOrderRequest instance) =>
<String, dynamic>{
'product_id': instance.productId,
'product_channel': instance.productChannel,
'payment_channel': instance.paymentChannel,
};
CreatePayOrderResponse _$CreatePayOrderResponseFromJson(
Map<String, dynamic> json) =>
CreatePayOrderResponse(
prepayData: json['prepay_data'] as String?,
);
Map<String, dynamic> _$CreatePayOrderResponseToJson(
CreatePayOrderResponse instance) =>
<String, dynamic>{
if (instance.prepayData case final value?) 'prepay_data': value,
};
SubscriptionProductListResponse _$SubscriptionProductListResponseFromJson(
Map<String, dynamic> json) =>
SubscriptionProductListResponse(
productList: (json['subscription_list'] as List<dynamic>?)
?.map((e) => SubscriptionProduct.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$SubscriptionProductListResponseToJson(
SubscriptionProductListResponse instance) =>
<String, dynamic>{
if (instance.productList?.map((e) => e.toJson()).toList()
case final value?)
'subscription_list': value,
};
SubscriptionProduct _$SubscriptionProductFromJson(Map<String, dynamic> json) =>
SubscriptionProduct(
agreementNo: json['agreement_no'] as String?,
startTime: (json['last_execute_timestamp'] as num?)?.toInt(),
endTime: (json['next_execute_timestamp'] as num?)?.toInt(),
nextPayPrice: (json['single_amount'] as num?)?.toInt(),
productInfo: json['product_info'] == null
? null
: SubscriptionProductInfo.fromJson(
json['product_info'] as Map<String, dynamic>),
);
Map<String, dynamic> _$SubscriptionProductToJson(
SubscriptionProduct instance) =>
<String, dynamic>{
if (instance.agreementNo case final value?) 'agreement_no': value,
if (instance.startTime case final value?) 'last_execute_timestamp': value,
if (instance.endTime case final value?) 'next_execute_timestamp': value,
if (instance.nextPayPrice case final value?) 'single_amount': value,
if (instance.productInfo?.toJson() case final value?)
'product_info': value,
};
SubscriptionProductInfo _$SubscriptionProductInfoFromJson(
Map<String, dynamic> json) =>
SubscriptionProductInfo(
name: json['name'] as String?,
);
Map<String, dynamic> _$SubscriptionProductInfoToJson(
SubscriptionProductInfo instance) =>
<String, dynamic>{
if (instance.name case final value?) 'name': value,
};
SubscriptionCancelRequest _$SubscriptionCancelRequestFromJson(
Map<String, dynamic> json) =>
SubscriptionCancelRequest(
agreementNo: json['agreement_no'] as String,
);
Map<String, dynamic> _$SubscriptionCancelRequestToJson(
SubscriptionCancelRequest instance) =>
<String, dynamic>{
'agreement_no': instance.agreementNo,
};
import 'package:json_annotation/json_annotation.dart';
part 'user_models.g.dart';
// ─── Requests(手写 toJson,无 fromJson)────────────────────────────────────
class LoginRequest {
... ... @@ -97,54 +93,79 @@ class UserInfoUpdateRequest {
}
}
// ─── Responses(json_annotation 代码生成)──────────────────────────────────
// ─── Responses(手动反序列化)──────────────────────────────────
@JsonSerializable()
class UserAccessToken {
const UserAccessToken({this.accessToken, this.expireTime});
@JsonKey(name: 'access_token')
final String? accessToken;
@JsonKey(name: 'expire_time')
final int? expireTime;
factory UserAccessToken.fromJson(Map<String, dynamic> json) =>
_$UserAccessTokenFromJson(json);
Map<String, dynamic> toJson() => _$UserAccessTokenToJson(this);
factory UserAccessToken.fromJson(Map<String, dynamic> json) {
return UserAccessToken(
accessToken: json['access_token'] as String?,
expireTime: json['expire_time'] as int?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (accessToken != null) val['access_token'] = accessToken;
if (expireTime != null) val['expire_time'] = expireTime;
return val;
}
}
@JsonSerializable()
class LoginResponse {
const LoginResponse({this.isNewUser, this.accessTokenInfo, this.id});
@JsonKey(name: 'is_new_user')
final bool? isNewUser;
@JsonKey(name: 'token_info')
final UserAccessToken? accessTokenInfo;
final int? id;
String get accessToken => accessTokenInfo?.accessToken ?? '';
factory LoginResponse.fromJson(Map<String, dynamic> json) =>
_$LoginResponseFromJson(json);
Map<String, dynamic> toJson() => _$LoginResponseToJson(this);
factory LoginResponse.fromJson(Map<String, dynamic> json) {
return LoginResponse(
isNewUser: json['is_new_user'] as bool?,
accessTokenInfo: json['token_info'] == null
? null
: UserAccessToken.fromJson(json['token_info'] as Map<String, dynamic>),
id: json['id'] as int?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (isNewUser != null) val['is_new_user'] = isNewUser;
if (accessTokenInfo != null) val['token_info'] = accessTokenInfo!.toJson();
if (id != null) val['id'] = id;
return val;
}
}
@JsonSerializable()
class RegisterResponse {
const RegisterResponse({this.accessTokenInfo});
@JsonKey(name: 'token_info')
final UserAccessToken? accessTokenInfo;
String get accessToken => accessTokenInfo?.accessToken ?? '';
factory RegisterResponse.fromJson(Map<String, dynamic> json) =>
_$RegisterResponseFromJson(json);
Map<String, dynamic> toJson() => _$RegisterResponseToJson(this);
factory RegisterResponse.fromJson(Map<String, dynamic> json) {
return RegisterResponse(
accessTokenInfo: json['token_info'] == null
? null
: UserAccessToken.fromJson(json['token_info'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (accessTokenInfo != null) val['token_info'] = accessTokenInfo!.toJson();
return val;
}
}
@JsonSerializable()
class UserInfoResponse {
const UserInfoResponse({
this.id,
... ... @@ -161,48 +182,92 @@ class UserInfoResponse {
});
final int? id;
@JsonKey(name: 'pair_code')
final String? pairCode;
@JsonKey(name: 'pair_id')
final int? pairId;
final String? telephone;
final String? nickname;
final String? avatar;
final int? persona;
final int? status;
@JsonKey(name: 'last_login_time')
final int? lastLoginTime;
@JsonKey(name: 'create_time')
final int? createTime;
@JsonKey(name: 'is_bot')
final int? isBot;
factory UserInfoResponse.fromJson(Map<String, dynamic> json) =>
_$UserInfoResponseFromJson(json);
Map<String, dynamic> toJson() => _$UserInfoResponseToJson(this);
factory UserInfoResponse.fromJson(Map<String, dynamic> json) {
return UserInfoResponse(
id: json['id'] as int?,
pairCode: json['pair_code'] as String?,
pairId: json['pair_id'] as int?,
telephone: json['telephone'] as String?,
nickname: json['nickname'] as String?,
avatar: json['avatar'] as String?,
persona: json['persona'] as int?,
status: json['status'] as int?,
lastLoginTime: json['last_login_time'] as int?,
createTime: json['create_time'] as int?,
isBot: json['is_bot'] as int?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (id != null) val['id'] = id;
if (pairCode != null) val['pair_code'] = pairCode;
if (pairId != null) val['pair_id'] = pairId;
if (telephone != null) val['telephone'] = telephone;
if (nickname != null) val['nickname'] = nickname;
if (avatar != null) val['avatar'] = avatar;
if (persona != null) val['persona'] = persona;
if (status != null) val['status'] = status;
if (lastLoginTime != null) val['last_login_time'] = lastLoginTime;
if (createTime != null) val['create_time'] = createTime;
if (isBot != null) val['is_bot'] = isBot;
return val;
}
}
@JsonSerializable()
class BoundUserInfoResponse {
const BoundUserInfoResponse({this.userInfo, this.partnerUserInfo});
@JsonKey(name: 'user_info')
final UserInfoResponse? userInfo;
@JsonKey(name: 'pair_user_info')
final UserInfoResponse? partnerUserInfo;
factory BoundUserInfoResponse.fromJson(Map<String, dynamic> json) =>
_$BoundUserInfoResponseFromJson(json);
Map<String, dynamic> toJson() => _$BoundUserInfoResponseToJson(this);
factory BoundUserInfoResponse.fromJson(Map<String, dynamic> json) {
return BoundUserInfoResponse(
userInfo: json['user_info'] == null
? null
: UserInfoResponse.fromJson(json['user_info'] as Map<String, dynamic>),
partnerUserInfo: json['pair_user_info'] == null
? null
: UserInfoResponse.fromJson(
json['pair_user_info'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (userInfo != null) val['user_info'] = userInfo!.toJson();
if (partnerUserInfo != null) {
val['pair_user_info'] = partnerUserInfo!.toJson();
}
return val;
}
}
@JsonSerializable()
class RongcloudTokenResponse {
const RongcloudTokenResponse({this.token});
final String? token;
factory RongcloudTokenResponse.fromJson(Map<String, dynamic> json) =>
_$RongcloudTokenResponseFromJson(json);
Map<String, dynamic> toJson() => _$RongcloudTokenResponseToJson(this);
factory RongcloudTokenResponse.fromJson(Map<String, dynamic> json) {
return RongcloudTokenResponse(
token: json['token'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (token != null) val['token'] = token;
return val;
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_models.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UserAccessToken _$UserAccessTokenFromJson(Map<String, dynamic> json) =>
UserAccessToken(
accessToken: json['access_token'] as String?,
expireTime: (json['expire_time'] as num?)?.toInt(),
);
Map<String, dynamic> _$UserAccessTokenToJson(UserAccessToken instance) =>
<String, dynamic>{
if (instance.accessToken case final value?) 'access_token': value,
if (instance.expireTime case final value?) 'expire_time': value,
};
LoginResponse _$LoginResponseFromJson(Map<String, dynamic> json) =>
LoginResponse(
isNewUser: json['is_new_user'] as bool?,
accessTokenInfo: json['token_info'] == null
? null
: UserAccessToken.fromJson(
json['token_info'] as Map<String, dynamic>),
id: (json['id'] as num?)?.toInt(),
);
Map<String, dynamic> _$LoginResponseToJson(LoginResponse instance) =>
<String, dynamic>{
if (instance.isNewUser case final value?) 'is_new_user': value,
if (instance.accessTokenInfo?.toJson() case final value?)
'token_info': value,
if (instance.id case final value?) 'id': value,
};
RegisterResponse _$RegisterResponseFromJson(Map<String, dynamic> json) =>
RegisterResponse(
accessTokenInfo: json['token_info'] == null
? null
: UserAccessToken.fromJson(
json['token_info'] as Map<String, dynamic>),
);
Map<String, dynamic> _$RegisterResponseToJson(RegisterResponse instance) =>
<String, dynamic>{
if (instance.accessTokenInfo?.toJson() case final value?)
'token_info': value,
};
UserInfoResponse _$UserInfoResponseFromJson(Map<String, dynamic> json) =>
UserInfoResponse(
id: (json['id'] as num?)?.toInt(),
pairCode: json['pair_code'] as String?,
pairId: (json['pair_id'] as num?)?.toInt(),
telephone: json['telephone'] as String?,
nickname: json['nickname'] as String?,
avatar: json['avatar'] as String?,
persona: (json['persona'] as num?)?.toInt(),
status: (json['status'] as num?)?.toInt(),
lastLoginTime: (json['last_login_time'] as num?)?.toInt(),
createTime: (json['create_time'] as num?)?.toInt(),
isBot: (json['is_bot'] as num?)?.toInt(),
);
Map<String, dynamic> _$UserInfoResponseToJson(UserInfoResponse instance) =>
<String, dynamic>{
if (instance.id case final value?) 'id': value,
if (instance.pairCode case final value?) 'pair_code': value,
if (instance.pairId case final value?) 'pair_id': value,
if (instance.telephone case final value?) 'telephone': value,
if (instance.nickname case final value?) 'nickname': value,
if (instance.avatar case final value?) 'avatar': value,
if (instance.persona case final value?) 'persona': value,
if (instance.status case final value?) 'status': value,
if (instance.lastLoginTime case final value?) 'last_login_time': value,
if (instance.createTime case final value?) 'create_time': value,
if (instance.isBot case final value?) 'is_bot': value,
};
BoundUserInfoResponse _$BoundUserInfoResponseFromJson(
Map<String, dynamic> json) =>
BoundUserInfoResponse(
userInfo: json['user_info'] == null
? null
: UserInfoResponse.fromJson(
json['user_info'] as Map<String, dynamic>),
partnerUserInfo: json['pair_user_info'] == null
? null
: UserInfoResponse.fromJson(
json['pair_user_info'] as Map<String, dynamic>),
);
Map<String, dynamic> _$BoundUserInfoResponseToJson(
BoundUserInfoResponse instance) =>
<String, dynamic>{
if (instance.userInfo?.toJson() case final value?) 'user_info': value,
if (instance.partnerUserInfo?.toJson() case final value?)
'pair_user_info': value,
};
RongcloudTokenResponse _$RongcloudTokenResponseFromJson(
Map<String, dynamic> json) =>
RongcloudTokenResponse(
token: json['token'] as String?,
);
Map<String, dynamic> _$RongcloudTokenResponseToJson(
RongcloudTokenResponse instance) =>
<String, dynamic>{
if (instance.token case final value?) 'token': value,
};
import 'package:json_annotation/json_annotation.dart';
part 'vip_info.g.dart';
@JsonSerializable()
class VipInfo {
const VipInfo({
this.isVip,
... ... @@ -12,18 +7,29 @@ class VipInfo {
this.vipEndDate,
});
@JsonKey(name: 'is_vip')
final bool? isVip;
@JsonKey(name: 'vip_is_forever')
final bool? isForeverVip;
@JsonKey(name: 'is_share')
final bool? isShare;
@JsonKey(name: 'vip_start_date')
final int? vipStartDate;
@JsonKey(name: 'vip_end_date')
final int? vipEndDate;
factory VipInfo.fromJson(Map<String, dynamic> json) =>
_$VipInfoFromJson(json);
Map<String, dynamic> toJson() => _$VipInfoToJson(this);
factory VipInfo.fromJson(Map<String, dynamic> json) {
return VipInfo(
isVip: json['is_vip'] as bool?,
isForeverVip: json['vip_is_forever'] as bool?,
isShare: json['is_share'] as bool?,
vipStartDate: (json['vip_start_date'] as num?)?.toInt(),
vipEndDate: (json['vip_end_date'] as num?)?.toInt(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (isVip != null) val['is_vip'] = isVip;
if (isForeverVip != null) val['vip_is_forever'] = isForeverVip;
if (isShare != null) val['is_share'] = isShare;
if (vipStartDate != null) val['vip_start_date'] = vipStartDate;
if (vipEndDate != null) val['vip_end_date'] = vipEndDate;
return val;
}
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'vip_info.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
VipInfo _$VipInfoFromJson(Map<String, dynamic> json) => VipInfo(
isVip: json['is_vip'] as bool?,
isForeverVip: json['vip_is_forever'] as bool?,
isShare: json['is_share'] as bool?,
vipStartDate: (json['vip_start_date'] as num?)?.toInt(),
vipEndDate: (json['vip_end_date'] as num?)?.toInt(),
);
Map<String, dynamic> _$VipInfoToJson(VipInfo instance) => <String, dynamic>{
if (instance.isVip case final value?) 'is_vip': value,
if (instance.isForeverVip case final value?) 'vip_is_forever': value,
if (instance.isShare case final value?) 'is_share': value,
if (instance.vipStartDate case final value?) 'vip_start_date': value,
if (instance.vipEndDate case final value?) 'vip_end_date': value,
};
... ... @@ -62,7 +62,8 @@ import 'app_localizations_zh.dart';
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
final String localeName;
... ... @@ -70,7 +71,8 @@ abstract class AppLocalizations {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
/// A list of this localizations delegate along with the default localizations
/// delegates.
... ... @@ -82,7 +84,8 @@ abstract class AppLocalizations {
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
... ... @@ -525,7 +528,8 @@ abstract class AppLocalizations {
///
/// In zh, this message translates to:
/// **'你们现在可以查看彼此的 HRV、压力与睡眠变化,并在对方疲惫时及时送上关心。'**
String get youCanNowViewEachOtherSHrvStressLevelsAndSleepPatternsAndReachOutToCheckInWhenTheOtherPersonSeemsTired;
String
get youCanNowViewEachOtherSHrvStressLevelsAndSleepPatternsAndReachOutToCheckInWhenTheOtherPersonSeemsTired;
/// No description provided for @bindPartnerTitle.
///
... ... @@ -756,7 +760,8 @@ abstract class AppLocalizations {
String get todayHealthDataAuthAction;
}
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
@override
... ... @@ -765,25 +770,25 @@ class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations>
}
@override
bool isSupported(Locale locale) => <String>['en', 'zh'].contains(locale.languageCode);
bool isSupported(Locale locale) =>
<String>['en', 'zh'].contains(locale.languageCode);
@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en': return AppLocalizationsEn();
case 'zh': return AppLocalizationsZh();
case 'en':
return AppLocalizationsEn();
case 'zh':
return AppLocalizationsZh();
}
throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.'
);
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
}
... ...
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
... ... @@ -67,10 +69,12 @@ class AppLocalizationsEn extends AppLocalizations {
String get settings => 'Settings';
@override
String get onboardingIntroTitle => 'DoubleFeel is a health companion app built for Apple Watch';
String get onboardingIntroTitle =>
'DoubleFeel is a health companion app built for Apple Watch';
@override
String get onboardingIntroBody => 'We hope to help you\n<em>notice changes in your mind and body, and help the people who love you</em> see when you are <em>tired or need support</em>';
String get onboardingIntroBody =>
'We hope to help you\n<em>notice changes in your mind and body, and help the people who love you</em> see when you are <em>tired or need support</em>';
@override
String get onboardingStateQuestion => 'Which of these often happens to you?';
... ... @@ -82,16 +86,19 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingStateTired => 'I get tired easily';
@override
String get onboardingStatePoorRest => 'I wake up but still do not feel rested';
String get onboardingStatePoorRest =>
'I wake up but still do not feel rested';
@override
String get onboardingStateNeedStimulants => 'I rely on cigarettes, alcohol, coffee, or other stimulants to stay alert';
String get onboardingStateNeedStimulants =>
'I rely on cigarettes, alcohol, coffee, or other stimulants to stay alert';
@override
String get onboardingStateNone => 'None of the above';
@override
String get onboardingStressGoalQuestion => 'What do you want to learn by understanding stress?';
String get onboardingStressGoalQuestion =>
'What do you want to learn by understanding stress?';
@override
String get onboardingStressGoalSource => 'Understand where stress comes from';
... ... @@ -100,7 +107,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingStressGoalReminder => 'Get reminded when stress appears';
@override
String get onboardingStressGoalLovedOnes => 'Let people who care about me know my stress state';
String get onboardingStressGoalLovedOnes =>
'Let people who care about me know my stress state';
@override
String get onboardingStressGoalRelax => 'Understand stress and feel lighter';
... ... @@ -109,7 +117,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingStressGoalBodyTalk => 'Communicate better with my body';
@override
String get onboardingReliefQuestion => 'Which methods do you think can ease stress?';
String get onboardingReliefQuestion =>
'Which methods do you think can ease stress?';
@override
String get onboardingReliefSleep => 'Regular sleep';
... ... @@ -133,7 +142,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingKeyDataTitle => 'Did you know?';
@override
String get onboardingKeyDataSubtitle => 'Everyone has a magical and important body metric that can help us:';
String get onboardingKeyDataSubtitle =>
'Everyone has a magical and important body metric that can help us:';
@override
String get onboardingKeyDataStress => 'Monitor stress';
... ... @@ -148,7 +158,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingKeyDataHabits => 'Build healthy habits';
@override
String get onboardingKeyDataLovedOnes => 'Help important people care about your state in time';
String get onboardingKeyDataLovedOnes =>
'Help important people care about your state in time';
@override
String get onboardingTellMeWhatItIs => 'Tell me what it is!';
... ... @@ -157,16 +168,19 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingHrvTitle => 'It is HRV, heart rate variability';
@override
String get onboardingHrvSubtitle => 'It helps us measure overall stress and health';
String get onboardingHrvSubtitle =>
'It helps us measure overall stress and health';
@override
String get onboardingHrvDescription => 'Heart rate variability (HRV) is the tiny variation in time between heartbeats. It reflects autonomic nervous system activity and how the body responds to stress.';
String get onboardingHrvDescription =>
'Heart rate variability (HRV) is the tiny variation in time between heartbeats. It reflects autonomic nervous system activity and how the body responds to stress.';
@override
String get onboardingTellMeMore => 'Tell me more';
@override
String get onboardingResearchTitle => 'Many studies show that HRV changes are closely related to how our body and mind feel';
String get onboardingResearchTitle =>
'Many studies show that HRV changes are closely related to how our body and mind feel';
@override
String get onboardingResearchFatigue => 'Physical fatigue';
... ... @@ -184,25 +198,30 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingHealthPermissionTitle => 'Allow health data access';
@override
String get onboardingHealthPermissionBody => 'DoubleFeel needs connected wearable health data to send reminders, count stress moments, and provide suggestions.';
String get onboardingHealthPermissionBody =>
'DoubleFeel needs connected wearable health data to send reminders, count stress moments, and provide suggestions.';
@override
String get onboardingHealthPermissionPrivacy => 'Your health data is stored locally. We do not upload any related data.';
String get onboardingHealthPermissionPrivacy =>
'Your health data is stored locally. We do not upload any related data.';
@override
String get onboardingNotificationTitle => 'Turn on notifications';
@override
String get onboardingNotificationSubtitle => 'Learn about every body change in time';
String get onboardingNotificationSubtitle =>
'Learn about every body change in time';
@override
String get onboardingNotificationBody => 'After Apple Watch data updates, we can remind you in time and help you act to improve your stress state.';
String get onboardingNotificationBody =>
'After Apple Watch data updates, we can remind you in time and help you act to improve your stress state.';
@override
String get onboardingMemberTitle => 'Get an annual membership offer';
@override
String get onboardingMemberBody => 'Start your pressure alert and health companion journey, so love and care are always present.';
String get onboardingMemberBody =>
'Start your pressure alert and health companion journey, so love and care are always present.';
@override
String get onboardingMemberOriginalPrice => 'Original ¥72.00/year';
... ... @@ -217,13 +236,16 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingMemberAllOptions => 'View all purchase options';
@override
String get healthCompanionIsNowAvailable => 'Health Companion is now available';
String get healthCompanionIsNowAvailable =>
'Health Companion is now available';
@override
String get youCanNowViewEachOtherSHrvStressLevelsAndSleepPatternsAndReachOutToCheckInWhenTheOtherPersonSeemsTired => 'You can now view each other\'s HRV, stress levels, and sleep patterns, and reach out to check in when the other person seems tired.';
String get youCanNowViewEachOtherSHrvStressLevelsAndSleepPatternsAndReachOutToCheckInWhenTheOtherPersonSeemsTired =>
'You can now view each other\'s HRV, stress levels, and sleep patterns, and reach out to check in when the other person seems tired.';
@override
String get bindPartnerTitle => 'Add a Close Contact\nOne more person to care about your health';
String get bindPartnerTitle =>
'Add a Close Contact\nOne more person to care about your health';
@override
String get bindPartnerMyId => 'My ID';
... ... @@ -262,7 +284,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingResearchGoodSleep => 'Good Sleep';
@override
String get loginSlogan => 'Start your pressure alert and health companion journey\nso love and care are always present';
String get loginSlogan =>
'Start your pressure alert and health companion journey\nso love and care are always present';
@override
String get loginWithPhone => 'Sign in with Phone';
... ... @@ -312,13 +335,15 @@ class AppLocalizationsEn extends AppLocalizations {
String get phoneLoginCodeHint => 'Enter verification code';
@override
String get phoneLoginAutoRegisterHint => 'Unregistered numbers will be registered automatically';
String get phoneLoginAutoRegisterHint =>
'Unregistered numbers will be registered automatically';
@override
String get phoneLoginLoggingIn => 'Signing in...';
@override
String get loginAgreeToTermsToast => 'Please read and agree to the Terms of Service and Privacy Policy first';
String get loginAgreeToTermsToast =>
'Please read and agree to the Terms of Service and Privacy Policy first';
@override
String get phoneLoginInvalidPhone => 'Invalid phone number';
... ... @@ -330,10 +355,12 @@ class AppLocalizationsEn extends AppLocalizations {
String get phoneLoginInvalidCode => 'Invalid verification code';
@override
String get todayHealthDataAuthTitle => 'Unable to access heart rate health data';
String get todayHealthDataAuthTitle =>
'Unable to access heart rate health data';
@override
String get todayHealthDataAuthDescription => 'DoubleFeel needs permission to access your health data to provide stress reminders, real-time stress statistics, and health suggestions. Otherwise, some app features may not work properly. Your health data is stored locally only and will not be uploaded to any server.';
String get todayHealthDataAuthDescription =>
'DoubleFeel needs permission to access your health data to provide stress reminders, real-time stress statistics, and health suggestions. Otherwise, some app features may not work properly. Your health data is stored locally only and will not be uploaded to any server.';
@override
String get todayHealthDataAuthAction => 'Authorize health data access';
... ...
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
... ... @@ -70,7 +72,8 @@ class AppLocalizationsZh extends AppLocalizations {
String get onboardingIntroTitle => 'DoubleFeel 是专为 Apple Watch 打造的健康陪伴app';
@override
String get onboardingIntroBody => '我们希望可以帮助你\n<em>关注自己的身心变化,也让爱你的人</em>及时发现你的<em>疲惫与需要</em>';
String get onboardingIntroBody =>
'我们希望可以帮助你\n<em>关注自己的身心变化,也让爱你的人</em>及时发现你的<em>疲惫与需要</em>';
@override
String get onboardingStateQuestion => '请问以下哪些描述,经常发生在你身上?';
... ... @@ -160,7 +163,8 @@ class AppLocalizationsZh extends AppLocalizations {
String get onboardingHrvSubtitle => '它能帮助我们衡量整体的压力和健康状态';
@override
String get onboardingHrvDescription => '心率变异性(HRV, Heart Rate Variability)即心跳之间间隔时间的微小变化,反映了自主神经系统活动和身体对压力的反应能力';
String get onboardingHrvDescription =>
'心率变异性(HRV, Heart Rate Variability)即心跳之间间隔时间的微小变化,反映了自主神经系统活动和身体对压力的反应能力';
@override
String get onboardingTellMeMore => '展开说说';
... ... @@ -184,10 +188,12 @@ class AppLocalizationsZh extends AppLocalizations {
String get onboardingHealthPermissionTitle => '允许访问健康数据';
@override
String get onboardingHealthPermissionBody => 'DoubleFeel需要连接健康穿戴设备数据,以提醒、统计压力时刻、提供建议。';
String get onboardingHealthPermissionBody =>
'DoubleFeel需要连接健康穿戴设备数据,以提醒、统计压力时刻、提供建议。';
@override
String get onboardingHealthPermissionPrivacy => '请放心,你的健康数据只会存储在本地,我们不上传任何相关数据。';
String get onboardingHealthPermissionPrivacy =>
'请放心,你的健康数据只会存储在本地,我们不上传任何相关数据。';
@override
String get onboardingNotificationTitle => '开启通知';
... ... @@ -196,7 +202,8 @@ class AppLocalizationsZh extends AppLocalizations {
String get onboardingNotificationSubtitle => '及时了解身体每一次异动';
@override
String get onboardingNotificationBody => 'AppleWatch数据更新后会及时提醒你,帮助你及时行动,改善压力状态';
String get onboardingNotificationBody =>
'AppleWatch数据更新后会及时提醒你,帮助你及时行动,改善压力状态';
@override
String get onboardingMemberTitle => '获得年度会员优惠';
... ... @@ -220,7 +227,9 @@ class AppLocalizationsZh extends AppLocalizations {
String get healthCompanionIsNowAvailable => '健康陪伴已开启';
@override
String get youCanNowViewEachOtherSHrvStressLevelsAndSleepPatternsAndReachOutToCheckInWhenTheOtherPersonSeemsTired => '你们现在可以查看彼此的 HRV、压力与睡眠变化,并在对方疲惫时及时送上关心。';
String
get youCanNowViewEachOtherSHrvStressLevelsAndSleepPatternsAndReachOutToCheckInWhenTheOtherPersonSeemsTired =>
'你们现在可以查看彼此的 HRV、压力与睡眠变化,并在对方疲惫时及时送上关心。';
@override
String get bindPartnerTitle => '添加亲密联系人\n多一个人关注你的健康';
... ... @@ -333,7 +342,8 @@ class AppLocalizationsZh extends AppLocalizations {
String get todayHealthDataAuthTitle => '无法获取心率健康数据';
@override
String get todayHealthDataAuthDescription => 'DoubleFeel 需要授权访问你的健康数据,才能提供压力提醒、实时压力统计和健康建议;否则应用功能可能无法正常使用。请放心,你的健康数据仅存储在本地,不会上传到任何服务器。';
String get todayHealthDataAuthDescription =>
'DoubleFeel 需要授权访问你的健康数据,才能提供压力提醒、实时压力统计和健康建议;否则应用功能可能无法正常使用。请放心,你的健康数据仅存储在本地,不会上传到任何服务器。';
@override
String get todayHealthDataAuthAction => '授权访问健康数据';
... ...
... ... @@ -133,10 +133,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.4.0"
checked_yaml:
dependency: transitive
description:
... ... @@ -149,10 +149,10 @@ packages:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.1.2"
code_builder:
dependency: transitive
description:
... ... @@ -165,10 +165,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
url: "https://pub.dev"
source: hosted
version: "1.19.0"
version: "1.19.1"
convert:
dependency: transitive
description:
... ... @@ -237,10 +237,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
version: "1.3.3"
ffi:
dependency: transitive
description:
... ... @@ -426,7 +426,7 @@ packages:
dependency: transitive
description:
path: image_cropper_for_web
ref: "br_v9.1.0_ohos"
ref: "65c2c99891882ea59732959a672f3d5993a837bb"
resolved-ref: "65c2c99891882ea59732959a672f3d5993a837bb"
url: "https://gitcode.com/openharmony-sig/fluttertpc_image_cropper.git"
source: git
... ... @@ -435,7 +435,7 @@ packages:
dependency: transitive
description:
path: image_cropper_platform_interface
ref: "br_v9.1.0_ohos"
ref: "65c2c99891882ea59732959a672f3d5993a837bb"
resolved-ref: "65c2c99891882ea59732959a672f3d5993a837bb"
url: "https://gitcode.com/openharmony-sig/fluttertpc_image_cropper.git"
source: git
... ... @@ -517,10 +517,10 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.dev"
source: hosted
version: "0.19.0"
version: "0.20.2"
io:
dependency: transitive
description:
... ... @@ -538,45 +538,37 @@ packages:
source: hosted
version: "0.7.1"
json_annotation:
dependency: "direct main"
dependency: transitive
description:
name: json_annotation
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
url: "https://pub.dev"
source: hosted
version: "4.9.0"
json_serializable:
dependency: "direct dev"
description:
name: json_serializable
sha256: c50ef5fc083d5b5e12eef489503ba3bf5ccc899e487d691584699b4bdefeea8c
url: "https://pub.dev"
source: hosted
version: "6.9.5"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev"
source: hosted
version: "10.0.7"
version: "11.0.2"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.8"
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
lints:
dependency: transitive
description:
... ... @@ -605,10 +597,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
... ... @@ -621,10 +613,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.17.0"
mime:
dependency: transitive
description:
... ... @@ -653,10 +645,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.9.1"
path_provider:
dependency: transitive
description:
... ... @@ -922,22 +914,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
source_gen:
dependency: transitive
description:
name: source_gen
sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
source_helper:
dependency: transitive
description:
name: source_helper
sha256: a447acb083d3a5ef17f983dd36201aeea33fedadb3228fa831f2f0c92f0f3aca
url: "https://pub.dev"
source: hosted
version: "1.3.7"
source_span:
dependency: transitive
description:
... ... @@ -990,18 +966,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.12.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.4"
stream_transform:
dependency: transitive
description:
... ... @@ -1030,10 +1006,10 @@ packages:
dependency: "direct main"
description:
name: table_calendar
sha256: b2896b7c86adf3a4d9c911d860120fe3dbe03c85db43b22fd61f14ee78cdbb63
sha256: "0c0c6219878b363a2d5f40c7afb159d845f253d061dc3c822aa0d5fe0f721982"
url: "https://pub.dev"
source: hosted
version: "3.1.3"
version: "3.2.0"
term_glyph:
dependency: transitive
description:
... ... @@ -1046,10 +1022,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev"
source: hosted
version: "0.7.3"
version: "0.7.7"
timing:
dependency: transitive
description:
... ... @@ -1078,10 +1054,10 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
vm_service:
dependency: transitive
description:
... ... @@ -1135,8 +1111,8 @@ packages:
dependency: transitive
description:
path: "packages/webview_flutter/webview_flutter_android"
ref: "br_webview_flutter-v4.13.0_ohos"
resolved-ref: "8d70938aa190eb7d7cd4d66f0d16fddb3c2d03ba"
ref: de942e79c9057b32ad31106508bd87c0d60aef83
resolved-ref: de942e79c9057b32ad31106508bd87c0d60aef83
url: "https://gitcode.com/openharmony-tpc/flutter_packages.git"
source: git
version: "4.7.0"
... ... @@ -1144,8 +1120,8 @@ packages:
dependency: transitive
description:
path: "packages/webview_flutter/webview_flutter_ohos"
ref: "br_webview_flutter-v4.13.0_ohos"
resolved-ref: "8d70938aa190eb7d7cd4d66f0d16fddb3c2d03ba"
ref: de942e79c9057b32ad31106508bd87c0d60aef83
resolved-ref: de942e79c9057b32ad31106508bd87c0d60aef83
url: "https://gitcode.com/openharmony-tpc/flutter_packages.git"
source: git
version: "4.7.0"
... ... @@ -1153,8 +1129,8 @@ packages:
dependency: transitive
description:
path: "packages/webview_flutter/webview_flutter_platform_interface"
ref: "br_webview_flutter-v4.13.0_ohos"
resolved-ref: "8d70938aa190eb7d7cd4d66f0d16fddb3c2d03ba"
ref: de942e79c9057b32ad31106508bd87c0d60aef83
resolved-ref: de942e79c9057b32ad31106508bd87c0d60aef83
url: "https://gitcode.com/openharmony-tpc/flutter_packages.git"
source: git
version: "2.13.1"
... ... @@ -1162,8 +1138,8 @@ packages:
dependency: transitive
description:
path: "packages/webview_flutter/webview_flutter_wkwebview"
ref: "br_webview_flutter-v4.13.0_ohos"
resolved-ref: "8d70938aa190eb7d7cd4d66f0d16fddb3c2d03ba"
ref: de942e79c9057b32ad31106508bd87c0d60aef83
resolved-ref: de942e79c9057b32ad31106508bd87c0d60aef83
url: "https://gitcode.com/openharmony-tpc/flutter_packages.git"
source: git
version: "3.22.0"
... ... @@ -1184,5 +1160,5 @@ packages:
source: hosted
version: "3.1.3"
sdks:
dart: ">=3.6.2 <4.0.0"
dart: ">=3.8.0-0 <4.0.0"
flutter: ">=3.27.0"
... ...
... ... @@ -13,7 +13,6 @@ dependencies:
get: ^4.7.2
dio: ^5.7.0
pretty_dio_logger: ^1.4.0
json_annotation: ^4.9.0
cached_network_image: ^3.4.1
fl_chart: ^0.70.2
logger: ^2.6.2
... ... @@ -43,7 +42,7 @@ dependencies:
url: https://gitcode.com/openharmony-sig/flutter_permission_handler.git
path: permission_handler_ohos
ref: br_permission_handler_v11.3.1_ohos
intl: ^0.19.0
intl: ^0.20.2
flutter_localizations:
sdk: flutter
table_calendar: ^3.1.3
... ... @@ -54,7 +53,6 @@ dev_dependencies:
sdk: flutter
flutter_lints: ^5.0.0
build_runner: ^2.4.15
json_serializable: ^6.9.5
pigeon:
git:
url: https://gitcode.com/openharmony-sig/flutter_packages.git
... ...