|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:doublefeel_flutter/app/actions/dialog_action.dart';
|
|
|
|
import 'package:doublefeel_flutter/app/modules/friends/controllers/friend_trend_controller.dart';
|
|
|
|
import 'package:doublefeel_flutter/app/modules/home/controllers/home_controller.dart';
|
|
|
|
import 'package:doublefeel_flutter/app/modules/home/controllers/trend/trend_controller.dart';
|
|
...
|
...
|
@@ -12,8 +13,10 @@ import 'package:doublefeel_flutter/app/routes/app_pages.dart'; |
|
|
|
import 'package:doublefeel_flutter/app/utils/platform_compact.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/config/app_environment_config.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/constants/intent_keys.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/error/app_error.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/logging/app_logger.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/network/api/friend_api.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/network/api/harmony_api.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/network/api/pay_api.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/network/api/vip_api.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/result/app_result.dart';
|
|
...
|
...
|
@@ -101,6 +104,7 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
|
|
final stressSubtitle = ''.obs;
|
|
|
|
bool _isFirstLoad = true;
|
|
|
|
bool _isHandlingHealthAuthorizationTap = false;
|
|
|
|
bool _isUnbindingHuaweiHealth = false;
|
|
|
|
|
|
|
|
// ── HRV 表盘引导 Banner ───────────────────
|
|
|
|
final showHrvAdBanner = false.obs;
|
|
...
|
...
|
@@ -336,11 +340,39 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _showHuaweiHealthRegistrationDialog() async {
|
|
|
|
final confirmed = await HuaweiHealthRegistrationDialog.show();
|
|
|
|
if (confirmed) {
|
|
|
|
final action = await HuaweiHealthRegistrationDialog.show();
|
|
|
|
if (action == DialogAction.confirm) {
|
|
|
|
await _platformHostApi.nativeHandleUrl(
|
|
|
|
'huaweischeme://healthapp/home/main',
|
|
|
|
);
|
|
|
|
} else if (action == DialogAction.cancel) {
|
|
|
|
await _unbindHuaweiHealth();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _unbindHuaweiHealth() async {
|
|
|
|
if (_isUnbindingHuaweiHealth) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_isUnbindingHuaweiHealth = true;
|
|
|
|
try {
|
|
|
|
final result = await Get.find<HarmonyApi>().deletePrivacyRecords();
|
|
|
|
switch (result) {
|
|
|
|
case AppSuccess():
|
|
|
|
AppToast.show('已解除华为健康绑定');
|
|
|
|
await _checkHealthAuthStatus();
|
|
|
|
case AppFailure(:final error):
|
|
|
|
// 登录失效及服务端错误文案已由 safeCall 的全局处理器处理。
|
|
|
|
if (error is AppCancelledError ||
|
|
|
|
error.isAccessTokenInvalid ||
|
|
|
|
(error is AppHttpError &&
|
|
|
|
(error.businessMessage?.isNotEmpty ?? false))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AppToast.show('解除绑定失败,请稍后重试');
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
_isUnbindingHuaweiHealth = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -456,6 +488,7 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
|
|
return;
|
|
|
|
}
|
|
|
|
await Get.to(() => NoHealthDataPage(
|
|
|
|
onUnbind: _unbindHuaweiHealth,
|
|
|
|
onRefresh: () {
|
|
|
|
refreshTab();
|
|
|
|
Future.delayed(const Duration(milliseconds: 800), () {
|
...
|
...
|
|