完成优化登录的优化
完成切换和切回APP数据的及时响应 完成服务下发退出账号的命令 完成远程遥控的权限的前置确认和获取 完后远程遥控的前后左右的控制.
This commit is contained in:
@@ -6,12 +6,14 @@ import 'package:maibu_satabot_v2/features/remote_control/presentation/bloc/remot
|
||||
|
||||
import '../../domain/entities/machine_control_status_entity.dart';
|
||||
import '../../domain/repositories/remote_control_repository.dart';
|
||||
import '../../domain/usecase/remote_control_usecase.dart';
|
||||
|
||||
class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
final RemoteControlRepository _repository;
|
||||
final RequestControlPermissionUseCase _requestControlPermissionUseCase;
|
||||
Timer? _timer;
|
||||
|
||||
RemoteControlCubit(this._repository)
|
||||
RemoteControlCubit(this._repository, this._requestControlPermissionUseCase)
|
||||
: super(
|
||||
RemoteControlState(
|
||||
controlEntity: MachineControlStatusEntity(),
|
||||
@@ -61,7 +63,18 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
emit(state.copyWith(controlEntity: updatedEntity));
|
||||
}
|
||||
|
||||
void updateOriginY(int y) {}
|
||||
void updateOriginY(int y) {
|
||||
final updatedEntity = state.controlEntity.copyWith(
|
||||
y: y,
|
||||
);
|
||||
emit(state.copyWith(controlEntity: updatedEntity));
|
||||
}
|
||||
void updateOriginX(int x) {
|
||||
final updatedEntity = state.controlEntity.copyWith(
|
||||
x: x,
|
||||
);
|
||||
emit(state.copyWith(controlEntity: updatedEntity));
|
||||
}
|
||||
|
||||
// 5. 停止控制循环
|
||||
void stopControlLoop() {
|
||||
@@ -99,4 +112,35 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
void updateEmergency(bool bool) {}
|
||||
|
||||
void respondPermission(bool bool) {}
|
||||
|
||||
void requestControlPermissionS(String deviceName, String deviceId) async {
|
||||
// 1. 关闭弹窗
|
||||
emit(state.copyWith(showPermissionRequestDialog: false));
|
||||
|
||||
// 2. 调用 UseCase
|
||||
final result = await _requestControlPermissionUseCase(
|
||||
RequestControlPermissionParams(
|
||||
deviceName: deviceName,
|
||||
deviceId: deviceId,
|
||||
),
|
||||
);
|
||||
|
||||
// 3. 处理结果
|
||||
result.fold(
|
||||
(failure) {
|
||||
print('❌ [RemoteControl] 请求控制权限失败:${failure.message}');
|
||||
// 可以在这里显示错误提示或重新打开弹窗
|
||||
emit(state.copyWith(showPermissionRequestDialog: true));
|
||||
|
||||
},
|
||||
(success) {
|
||||
emit(state.copyWith(hasPermission: true));
|
||||
print('✅ c:$success');
|
||||
// 权限申请已发送,等待 0x12 回包更新状态
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user