|
|
@ -1,3 +1,6 @@ |
|
|
|
|
|
import 'dart:async'; |
|
|
|
|
|
|
|
|
|
|
|
import 'package:ble_service/ble_service.dart'; |
|
|
import 'package:flutter_intro/flutter_intro.dart'; |
|
|
import 'package:flutter_intro/flutter_intro.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
import 'package:get_storage/get_storage.dart'; |
|
|
import 'package:get_storage/get_storage.dart'; |
|
|
@ -5,6 +8,9 @@ import 'package:get_storage/get_storage.dart'; |
|
|
class NoviceGuideService extends GetxService { |
|
|
class NoviceGuideService extends GetxService { |
|
|
final GetStorage _storage = GetStorage(); |
|
|
final GetStorage _storage = GetStorage(); |
|
|
|
|
|
|
|
|
|
|
|
final BleService _bleService = BleService(); |
|
|
|
|
|
StreamSubscription<dynamic>? _statusSubscription; |
|
|
|
|
|
|
|
|
bool isHomeGuide = false; |
|
|
bool isHomeGuide = false; |
|
|
bool isAIGuide = true; |
|
|
bool isAIGuide = true; |
|
|
|
|
|
|
|
|
@ -58,6 +64,12 @@ class NoviceGuideService extends GetxService { |
|
|
// isAIGuide = _storage.read('ai_guide') ?? false; |
|
|
// isAIGuide = _storage.read('ai_guide') ?? false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
void onClose() { |
|
|
|
|
|
closeWakeupListen(); |
|
|
|
|
|
super.onClose(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void startHomeGuide() async { |
|
|
void startHomeGuide() async { |
|
|
if (!isHomeGuide) { |
|
|
if (!isHomeGuide) { |
|
|
await Future.delayed(const Duration(milliseconds: 200)); |
|
|
await Future.delayed(const Duration(milliseconds: 200)); |
|
|
@ -75,4 +87,16 @@ class NoviceGuideService extends GetxService { |
|
|
Intro.of(Get.context!).start(group: 'ai'); |
|
|
Intro.of(Get.context!).start(group: 'ai'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void startWakeupListen() { |
|
|
|
|
|
_statusSubscription = _bleService.onStatusUpdated.listen((event) { |
|
|
|
|
|
if (event is Map && event['type'] == 'wakeup') { |
|
|
|
|
|
isWakeup.value = true; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void closeWakeupListen() { |
|
|
|
|
|
_statusSubscription?.cancel(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|