Fix local dev config and ALOTTTT OFF FLUTTER, im tired boss..
This commit is contained in:
+64
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../core/ai/obstacle_analyzer.dart';
|
||||
import '../domain/repositories/walk_guide_repository.dart';
|
||||
|
||||
class WalkGuideState {
|
||||
final bool active;
|
||||
final DetectionResult? latestDetection;
|
||||
final String status;
|
||||
|
||||
const WalkGuideState({
|
||||
this.active = false,
|
||||
this.latestDetection,
|
||||
this.status = 'Ready',
|
||||
});
|
||||
|
||||
WalkGuideState copyWith({
|
||||
bool? active,
|
||||
DetectionResult? latestDetection,
|
||||
String? status,
|
||||
}) {
|
||||
return WalkGuideState(
|
||||
active: active ?? this.active,
|
||||
latestDetection: latestDetection ?? this.latestDetection,
|
||||
status: status ?? this.status,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WalkGuideCubit extends Cubit<WalkGuideState> {
|
||||
final WalkGuideRepository _repository;
|
||||
|
||||
WalkGuideCubit(this._repository) : super(const WalkGuideState());
|
||||
|
||||
Future<void> start() async {
|
||||
emit(state.copyWith(active: true, status: 'WalkGuide active'));
|
||||
await _repository.startSession();
|
||||
}
|
||||
|
||||
Future<void> stop() async {
|
||||
emit(state.copyWith(active: false, status: 'WalkGuide stopped'));
|
||||
await _repository.stopSession();
|
||||
}
|
||||
|
||||
void updateStatus(String status) {
|
||||
emit(state.copyWith(status: status));
|
||||
}
|
||||
|
||||
void clearDetection({String status = 'Ready'}) {
|
||||
emit(WalkGuideState(active: state.active, status: status));
|
||||
}
|
||||
|
||||
Future<void> recordObstacle(DetectionResult detection) async {
|
||||
emit(state.copyWith(latestDetection: detection, status: detection.spokenId));
|
||||
await _repository.logObstacle({
|
||||
'label': detection.label,
|
||||
'confidence': detection.confidence,
|
||||
'direction': detection.directionName,
|
||||
'estimatedDist': detection.estimatedDistance,
|
||||
'lat': null,
|
||||
'lng': null,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user