import 'package:mobile_monitoring/data/models/service_result.dart'; import 'package:mobile_monitoring/data/services/auth_service.dart'; import 'package:mobile_monitoring/data/services/flow_service.dart'; import 'package:mobile_monitoring/data/services/hidroponik_data_service.dart'; import 'package:mobile_monitoring/data/services/planting_cycles_service.dart'; import 'package:mobile_monitoring/logic/controllers/base_controller.dart'; class FlowController extends BaseController { FlowController({ FlowService? flowService, AuthService? authService, HidroponikDataService? hidroponikDataService, PlantingCyclesService? plantingCyclesService, }) : _flowService = flowService ?? FlowService(), _authService = authService ?? AuthService(), _hidroponikDataService = hidroponikDataService ?? HidroponikDataService(), _plantingCyclesService = plantingCyclesService ?? PlantingCyclesService(); final FlowService _flowService; final AuthService _authService; final HidroponikDataService _hidroponikDataService; final PlantingCyclesService _plantingCyclesService; String? resolveUserId(String? pageUserId) { return pageUserId ?? _authService.currentUser?.uid; } ServiceResult parseMonitoringData(Map data) { return _flowService.parseMonitoringDataResult(data); } ServiceResult mapError(Object error) { return _flowService.getErrorInfoResult(error); } ServiceResult hasActiveCycle(Map? cycleData) { return _flowService.hasActiveCycleResult(cycleData); } ServiceResult extractStartDate(Map? cycleData) { return _flowService.extractStartDateResult(cycleData); } ServiceResult> generateRecapRows( List> docs, DateTime? startDate, ) { return _flowService.generateRecapRowsResult(docs, startDate); } Stream?> latestDataStream(String? userId) { return _hidroponikDataService.latestDataStream(userId: userId); } Stream?> activeCycleStream(String userId) { return _plantingCyclesService.getActiveCycleStream(userId: userId); } Stream>> historyStream({ required int limit, required String? userId, }) { return _hidroponikDataService.historyStream(limit: limit, userId: userId); } }