54 lines
1.9 KiB
Dart
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:get/get.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../../tools/eventBusEventManage.dart';
import 'groupEditLock_state.dart';
class GroupEditLockLogic extends BaseGetXController {
final GroupEditLockState state = GroupEditLockState();
//锁分组里面添加锁
Future<void> lockGroupAddLock(List lockIds) async {
if (lockIds.isEmpty) {
showToast('请选择锁'.tr);
return;
}
var entity = await ApiRepository.to.lockGroupAddLock(
lockIds: lockIds, groupId: state.selectGroupListItem.keyGroupId!);
if (entity.errorCode!.codeIsSuccessful) {
/*
TODO:这里eventbus连续发送两个事件触发两次监听回调会出现第一个回调中业务逻辑执行一半方法体执行一半后续逻辑不执行需要确定是get http或eventbus的问题
*/
eventBus.fire(LockGroupEditGroupLockRefreshEvent()); // 锁分组列表页面先触发刷新
showToast('添加成功'.tr, something: () {
eventBus.fire(RefreshLockListInfoDataEvent());
Get.close(2);
});
}
}
//锁分组里面添加锁
Future<void> lockGroupDeletLock(List lockIds) async {
if (lockIds.isEmpty) {
showToast('请选择锁'.tr);
return;
}
var entity = await ApiRepository.to.lockGroupDeletLock(lockIds: lockIds);
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(LockGroupEditGroupLockRefreshEvent()); // 锁分组列表页面先触发刷新
showToast('删除成功'.tr, something: () {
eventBus.fire(RefreshLockListInfoDataEvent());
Get.close(2);
});
}
}
Future<void> getVipStatus() async {
final bool? isVip = await Storage.getBool(saveIsVip);
state.isVip.value = isVip ?? false;
state.isVip.refresh();
}
}