feat: 增加连续点击样式处理

This commit is contained in:
2025-12-03 19:42:46 -08:00
parent 5bd77511cc
commit 24cf03d6ce
5 changed files with 64 additions and 165 deletions
@@ -1,4 +1,5 @@
import 'dart:math';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/services.dart';
@@ -11,6 +12,9 @@ import 'package:kaer_with_panels/app/services/global_overlay_service.dart';
import 'package:kaer_with_panels/app/services/singbox_imp/kr_sing_box_imp.dart';
import 'package:kaer_with_panels/singbox/model/singbox_status.dart';
DateTime? _hiConnectBtnNextAllowedAt;
const Duration _hiConnectBtnDebounce = Duration(milliseconds: 800);
/// ✅ 按钮组件(带多层呼吸同心圆动画)
class HIAnimatedConnectButton extends GetView<KRHomeController> {
final VoidCallback? onTriggerSubscriptionAnimation;
@@ -88,11 +92,16 @@ class HIAnimatedConnectButton extends GetView<KRHomeController> {
child: InkWell(
onTap: () {
HapticFeedback.lightImpact();
if (isSwitching) {
print(
'🔵 Switch UI 正在更新,切换中点击了按钮: status=${status.runtimeType}, isConnected=$isConnected, isSwitching=$isSwitching');
final _now = DateTime.now();
if (_hiConnectBtnNextAllowedAt != null &&
_now.isBefore(_hiConnectBtnNextAllowedAt!)) {
_hiConnectBtnNextAllowedAt =
_now.add(_hiConnectBtnDebounce);
return;
}
_hiConnectBtnNextAllowedAt =
_now.add(_hiConnectBtnDebounce);
final current = controller
.kr_subscribeService.kr_currentSubscribe.value;
bool hasValidSubscription = false;