diff --git a/lib/core/widgets/intro_overlay_builder.dart b/lib/core/widgets/intro_overlay_builder.dart index 5b64fc8c1..bab8412b0 100644 --- a/lib/core/widgets/intro_overlay_builder.dart +++ b/lib/core/widgets/intro_overlay_builder.dart @@ -11,11 +11,13 @@ class IntroOverlayBuilder { }) { return Column( children: [ - SizedBox( - width: 200.w, - height: 200.w, - child: Lottie.asset('assets/lottie/intro_foriday.json'), - ), + isWakeup + ? _AnimatedLottieWidget() + : SizedBox( + width: 200.w, + height: 200.w, + child: Lottie.asset('assets/lottie/intro_foriday.json'), + ), Padding( padding: EdgeInsets.only(bottom: 20.w), child: Text( @@ -106,3 +108,61 @@ class IntroOverlayBuilder { ); } } + +// 新增的动画Widget +class _AnimatedLottieWidget extends StatefulWidget { + @override + _AnimatedLottieWidgetState createState() => _AnimatedLottieWidgetState(); +} + +class _AnimatedLottieWidgetState extends State<_AnimatedLottieWidget> + with SingleTickerProviderStateMixin { + late AnimationController _animationController; + late Animation _scaleAnimation; + + @override + void initState() { + super.initState(); + + // 创建动画控制器,持续时间1.5秒 + _animationController = AnimationController( + duration: const Duration(milliseconds: 1000), + vsync: this, + ); + + // 创建缩放动画,从0.8到1.2再回到1.0 + _scaleAnimation = Tween( + begin: 0.8, + end: 1.2, + ).animate(CurvedAnimation( + parent: _animationController, + curve: Curves.elasticInOut, + )); + + // 启动动画并设置为循环 + _animationController.repeat(reverse: true); + } + + @override + void dispose() { + _animationController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AnimatedBuilder( + animation: _scaleAnimation, + builder: (context, child) { + return Transform.scale( + scale: _scaleAnimation.value, + child: SizedBox( + width: 200.w, + height: 200.w, + child: Lottie.asset('assets/lottie/intro_foriday.json'), + ), + ); + }, + ); + } +} diff --git a/lib/data/services/novice_guide_service.dart b/lib/data/services/novice_guide_service.dart index ad7b19451..d0ef6ccc7 100644 --- a/lib/data/services/novice_guide_service.dart +++ b/lib/data/services/novice_guide_service.dart @@ -89,6 +89,7 @@ class NoviceGuideService extends GetxService { } void startWakeupListen() { + _bleService.setWakeup(false); _statusSubscription = _bleService.onStatusUpdated.listen((event) { if (event is Map && event['type'] == 'wakeup') { isWakeup.value = true; @@ -97,6 +98,7 @@ class NoviceGuideService extends GetxService { } void closeWakeupListen() { + _bleService.setWakeup(true); _statusSubscription?.cancel(); } } diff --git a/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt b/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt index 0426e6409..216f8a136 100644 --- a/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt +++ b/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt @@ -87,6 +87,9 @@ object BleService { // 是否是ota模式 var isEnterOta = false + // 是否需要唤醒 + var isWakeup = true + // 是否回复指令 var isReply = true @@ -1515,7 +1518,13 @@ object BleService { private fun notifyWakeupSignalReceived() { for (callback in callbacks) { try { - callback.onWakeupSignalReceived() + if (isWakeup) { + callback.onWakeupSignalReceived() + } else { + if (callback::class.java.simpleName == "BleServicePlugin") { + callback.onWakeupSignalReceived() + } + } } catch (e: Exception) { Log.e(TAG, "分发唤醒信号回调异常", e) } diff --git a/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt b/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt index f8f7b3db9..d18f07de6 100644 --- a/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt +++ b/local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt @@ -278,6 +278,13 @@ class BleServicePlugin : FlutterPlugin, MethodCallHandler, ActivityAware, val connected = BleService.isConnected() result.success(connected) } + "setWakeup" -> { + val wakeup = call.argument("wakeup") + if (wakeup != null) { + BleService.isWakeup = wakeup + } + result.success("") + } "registerBackgroundScan" -> { bleCompanionManager.registerBackgroundScan() result.success(true) diff --git a/local_plugins/ble_service/lib/ble_service.dart b/local_plugins/ble_service/lib/ble_service.dart index 3cfb0954d..7e5a21ffd 100644 --- a/local_plugins/ble_service/lib/ble_service.dart +++ b/local_plugins/ble_service/lib/ble_service.dart @@ -272,6 +272,17 @@ class BleService { } } + /// 设置是否是否需要唤醒 + Future setWakeup(bool wakeup) async { + try { + await _methodChannel.invokeMethod('setWakeup', { + 'wakeup': wakeup, + }); + } catch (e) { + print('设置是否是否需要唤醒失败: $e'); + } + } + /// 断开连接 Future disconnect() async { try {