You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.0 KiB
98 lines
3.0 KiB
import 'package:flutter_intro/flutter_intro.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get_storage/get_storage.dart';
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
import '../../core/utils/permission_util.dart';
|
|
|
|
class NoviceGuideService extends GetxService {
|
|
final GetStorage _storage = GetStorage();
|
|
|
|
bool isHomeGuide = false; //false代表未完成新手引导,true代表已经完成
|
|
bool isAIGuide = false;
|
|
|
|
/// AI 唤醒已下线,保留字段以兼容 home_view 引导覆盖层;始终为 false。
|
|
RxBool isWakeup = false.obs;
|
|
|
|
int aiStep = 0;
|
|
|
|
List aiStepsList = [
|
|
{
|
|
'startKey': 'guideWeatherStart',
|
|
'inputKey': 'guideWeatherInput',
|
|
'sendKey': 'guideWeatherSend',
|
|
'endKey': 'guideWeatherEnd',
|
|
'method': () async {
|
|
await PermissionUtil.instance.requestPermission(
|
|
permissionType: Permission.location,
|
|
permissionName: 'locationInfo'.tr,
|
|
explanationText: 'locationPermissionDesc'.tr,
|
|
permanentDenialText: 'locationPermissionDetailDesc'.tr,
|
|
);
|
|
},
|
|
},
|
|
{
|
|
'startKey': 'guideMusicStart',
|
|
'inputKey': 'guideMusicInput',
|
|
'sendKey': 'guideMusicSend',
|
|
'endKey': 'guideMusicEnd',
|
|
'method': () async {},
|
|
},
|
|
{
|
|
'startKey': 'guideNavStart',
|
|
'inputKey': 'guideNavInput',
|
|
'sendKey': 'guideNavSend',
|
|
'endKey': 'guideNavEnd',
|
|
'method': () async {
|
|
await PermissionUtil.instance.requestPermission(
|
|
permissionType: Permission.location,
|
|
permissionName: 'locationInfo'.tr,
|
|
explanationText: 'locationPermissionDesc'.tr,
|
|
permanentDenialText: 'locationPermissionDetailDesc'.tr,
|
|
);
|
|
},
|
|
},
|
|
{
|
|
'startKey': 'guideMeetingStart',
|
|
'inputKey': 'guideMeetingInput',
|
|
'sendKey': 'guideMeetingSend',
|
|
'endKey': 'guideMeetingEnd',
|
|
'method': () async {
|
|
await PermissionUtil.instance.requestPermission(
|
|
permissionType: Permission.calendarFullAccess,
|
|
permissionName: 'calendarFullAccess'.tr,
|
|
explanationText: 'calendarFullAccessPermissionDesc'.tr,
|
|
permanentDenialText: 'calendarFullAccessPermissionDetailDesc'.tr,
|
|
);
|
|
},
|
|
},
|
|
];
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
isHomeGuide = _storage.read('home_guide') ?? false;
|
|
isAIGuide = _storage.read('ai_guide') ?? false;
|
|
}
|
|
|
|
void startHomeGuide() async {
|
|
if (!isHomeGuide) {
|
|
await Future.delayed(const Duration(milliseconds: 200));
|
|
isHomeGuide = true;
|
|
_storage.write('home_guide', true);
|
|
Intro.of(Get.context!).start(group: 'home');
|
|
}
|
|
}
|
|
|
|
void startAIGuide() async {
|
|
if (!isAIGuide) {
|
|
await Future.delayed(const Duration(milliseconds: 300));
|
|
isAIGuide = true;
|
|
_storage.write('ai_guide', true);
|
|
Intro.of(Get.context!).start(group: 'ai');
|
|
}
|
|
}
|
|
|
|
/// 唤醒功能已移除,下面两个方法保留为空实现以兼容旧调用点。
|
|
void startWakeupListen() {}
|
|
void closeWakeupListen() {}
|
|
}
|
|
|