Files
syncrow-app/lib/features/devices/bloc/ac_cubit.dart
Mohammad Salameh abe7072f2d AC devices page implemented
AC Cubit Add
New Devices Cubit Arch will be used
Devices Cubit (for devices categories, and devices page)
{
AC cubit,
Lights cubit.
... }
Replaced AssetsManager with Assets Class (auto generated)
2024-02-26 15:55:22 +03:00

58 lines
1.3 KiB
Dart

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:meta/meta.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
part 'ac_state.dart';
class AcCubit extends Cubit<AcState> {
AcCubit() : super(AcInitial());
static AcCubit get(context) => BlocProvider.of(context);
bool areAllACsOff() {
for (var ac in DevicesCubit.categories[0].devices) {
if (ac.status) {
return false;
}
}
return true;
}
void turnAllACsOff() {
for (var ac in DevicesCubit.categories[0].devices) {
ac.status = false;
}
emit(SwitchACsOff());
}
void turnAllACsOn() {
for (var ac in DevicesCubit.categories[0].devices) {
ac.status = true;
}
emit(SwitchACsOn());
}
void setTempToAll(double temperature) {
for (var ac in DevicesCubit.categories[0].devices) {
ac.temperature = temperature;
}
emit(ACsTempChanged());
}
double averageTempForAll() {
double allTemp = 0;
for (var ac in DevicesCubit.categories[0].devices) {
allTemp += ac.temperature;
}
emit(ACsTempChanged());
double averageTemp = allTemp / DevicesCubit.categories[0].devices.length;
averageTemp = (averageTemp * 2).round() / 2;
return averageTemp;
}
/// implement the fan speed and temp mode change
}