From 936857515489272204211849c32dc6e7e8e1389f Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 31 Mar 2024 12:08:53 +0300 Subject: [PATCH] Add AC cubit and state classes Add AC cubit and state classes with initial state for managing air conditioning related functionality in the devices feature bloc. --- lib/features/devices/bloc/cubit/ac_cubit.dart | 51 +++++++++++++++++++ lib/features/devices/bloc/cubit/ac_state.dart | 6 +++ 2 files changed, 57 insertions(+) create mode 100644 lib/features/devices/bloc/cubit/ac_cubit.dart create mode 100644 lib/features/devices/bloc/cubit/ac_state.dart diff --git a/lib/features/devices/bloc/cubit/ac_cubit.dart b/lib/features/devices/bloc/cubit/ac_cubit.dart new file mode 100644 index 0000000..511e3a8 --- /dev/null +++ b/lib/features/devices/bloc/cubit/ac_cubit.dart @@ -0,0 +1,51 @@ +// import 'package:bloc/bloc.dart'; +// import 'package:flutter/foundation.dart'; +// import 'package:meta/meta.dart'; +// import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; +// import 'package:syncrow_app/features/devices/model/device_category_model.dart'; +// import 'package:syncrow_app/features/devices/model/device_model.dart'; + +// part 'ac_state.dart'; + +// class AcCubit extends Cubit { +// AcCubit() : super(AcInitial()); +// DeviceModel? getSelectedAC() { +// DevicesCategoryModel category = DevicesCubit.allCategories![0]; +// for (var device in category.devices) { +// if (device is && device.isSelected) { +// return device; +// } +// } +// return null; +// } + +// void setTempToAll(double temperature) { +// for (DeviceModel ac in category.devices) { +// if (ac is DeviceModel) { +// if (ac.temperature != temperature && +// ac.bounds.min <= temperature && +// temperature <= ac.bounds.max) { +// setACTemp(ac, temperature); +// } +// } +// } +// universalACTemp = temperature; +// emit(ACsTempChanged(temperature)); +// } + +// void setACTemp(DeviceModel model, double temp) { +// if (model.bounds.min <= temp && temp <= model.bounds.max) { +// model.temperature = temp; +// } +// emit(ACsTempChanged(temp)); +// } + +// double getTemp(int index) { +// var device = category.devices[index]; +// if (device is DeviceModel) { +// return device.temperature; +// } +// return 0.0; // or any default value you prefer +// } + +// } diff --git a/lib/features/devices/bloc/cubit/ac_state.dart b/lib/features/devices/bloc/cubit/ac_state.dart new file mode 100644 index 0000000..4bd7e43 --- /dev/null +++ b/lib/features/devices/bloc/cubit/ac_state.dart @@ -0,0 +1,6 @@ +// part of 'ac_cubit.dart'; + +// @immutable +// sealed class AcState {} + +// final class AcInitial extends AcState {}