|
...
|
...
|
@@ -96,7 +96,7 @@ class TodayController extends GetMaterialController { |
|
|
|
final scrollOffset = 0.0.obs;
|
|
|
|
final scrollController = ScrollController();
|
|
|
|
|
|
|
|
final isLoadingToday = true.obs;
|
|
|
|
final isLoadingToday = false.obs;
|
|
|
|
final showHealthDataAuthCardStatus = 1.obs;
|
|
|
|
final stressSubtitle = ''.obs;
|
|
|
|
bool _isFirstLoad = true;
|
|
...
|
...
|
@@ -249,8 +249,11 @@ class TodayController extends GetMaterialController { |
|
|
|
return normalizedDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> loadDataForDate(DateTime date) async {
|
|
|
|
isLoadingToday.value = true;
|
|
|
|
Future<void> loadDataForDate(DateTime date,
|
|
|
|
{bool isPullToRefresh = false}) async {
|
|
|
|
if (isPullToRefresh) {
|
|
|
|
isLoadingToday.value = true;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
await Future.wait([
|
|
|
|
_refreshHealthDataForDate(date),
|
|
...
|
...
|
@@ -329,7 +332,7 @@ class TodayController extends GetMaterialController { |
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> checkHealthDataAuthCardVisible(
|
|
|
|
[HealthAuthorization? preResult]) async {
|
|
|
|
{bool isPullToRefresh = false}) async {
|
|
|
|
final firstTime = DateUtils.dateOnly(
|
|
|
|
DateTime(lastSelectableDay.value.year, lastSelectableDay.value.month - 6,
|
|
|
|
lastSelectableDay.value.day),
|
|
...
|
...
|
@@ -339,8 +342,7 @@ class TodayController extends GetMaterialController { |
|
|
|
firstSelectableDay.value = firstTime;
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
final result =
|
|
|
|
preResult ?? await _hostApi.checkHealthAppAuthorization();
|
|
|
|
final result = await _hostApi.checkHealthAppAuthorization();
|
|
|
|
ta.setSuperProperties(
|
|
|
|
{'health_data_permission': result.status.clamp(0, 1)});
|
|
|
|
if (result.status == 1) {
|
|
...
|
...
|
@@ -348,9 +350,11 @@ class TodayController extends GetMaterialController { |
|
|
|
uploaded: () async {
|
|
|
|
showHealthDataAuthCardStatus.value = result.status;
|
|
|
|
},
|
|
|
|
isPullToRefresh: isPullToRefresh,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
unawaited(loadDataForDate(selectedDate.value));
|
|
|
|
unawaited(loadDataForDate(selectedDate.value,
|
|
|
|
isPullToRefresh: isPullToRefresh));
|
|
|
|
showHealthDataAuthCardStatus.value = result.status;
|
|
|
|
}
|
|
|
|
} catch (error, stackTrace) {
|
|
...
|
...
|
@@ -382,12 +386,14 @@ class TodayController extends GetMaterialController { |
|
|
|
showHealthDataAuthCardStatus.value = !hasUploaded ? -1 : result.status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void _calculateHealthDataWithoutLoading({Future<void> Function()? uploaded}) {
|
|
|
|
void _calculateHealthDataWithoutLoading(
|
|
|
|
{Future<void> Function()? uploaded, bool isPullToRefresh = false}) {
|
|
|
|
unawaited(
|
|
|
|
(() async {
|
|
|
|
try {
|
|
|
|
await _healthRawDataCoreService.startCoreCaculate();
|
|
|
|
await loadDataForDate(selectedDate.value);
|
|
|
|
await loadDataForDate(selectedDate.value,
|
|
|
|
isPullToRefresh: isPullToRefresh);
|
|
|
|
await uploaded?.call();
|
|
|
|
} catch (error, stackTrace) {
|
|
|
|
AppLogger.e('Apple Health calculate failed', error, stackTrace);
|
|
...
|
...
|
@@ -701,7 +707,7 @@ class TodayController extends GetMaterialController { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> refreshTab() async {
|
|
|
|
Future<void> refreshTab({bool isPullToRefresh = false}) async {
|
|
|
|
if (_isFirstLoad) {
|
|
|
|
_isFirstLoad = false;
|
|
|
|
return;
|
|
...
|
...
|
@@ -711,7 +717,7 @@ class TodayController extends GetMaterialController { |
|
|
|
// changeDate(today);
|
|
|
|
checkAddFriendVisible();
|
|
|
|
checkHrvAdBannerVisible();
|
|
|
|
checkHealthDataAuthCardVisible();
|
|
|
|
checkHealthDataAuthCardVisible(isPullToRefresh: isPullToRefresh);
|
|
|
|
// await loadDataForDate(selectedDate.value);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|