Implemented side tree to devices and rountines screen

This commit is contained in:
Abdullah Alassaf
2025-01-04 17:45:15 +03:00
parent 0341844ea9
commit a98f7e77a3
88 changed files with 1551 additions and 1202 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,210 @@
part of 'routine_bloc.dart';
abstract class RoutineEvent extends Equatable {
const RoutineEvent();
@override
List<Object> get props => [];
}
class AddToIfContainer extends RoutineEvent {
final Map<String, dynamic> item;
final bool isTabToRun;
const AddToIfContainer(this.item, this.isTabToRun);
@override
List<Object> get props => [item, isTabToRun];
}
class AddToThenContainer extends RoutineEvent {
final Map<String, dynamic> item;
const AddToThenContainer(this.item);
@override
List<Object> get props => [item];
}
class LoadScenes extends RoutineEvent {
final String spaceId;
final String communityId;
const LoadScenes(this.spaceId, this.communityId);
@override
List<Object> get props => [spaceId, communityId];
}
class LoadAutomation extends RoutineEvent {
final String spaceId;
const LoadAutomation(this.spaceId);
@override
List<Object> get props => [spaceId];
}
class AddFunctionToRoutine extends RoutineEvent {
final List<DeviceFunctionData> functions;
final String uniqueCustomId;
const AddFunctionToRoutine(this.functions, this.uniqueCustomId);
@override
List<Object> get props => [functions, uniqueCustomId];
}
class RemoveFunction extends RoutineEvent {
final DeviceFunctionData function;
const RemoveFunction(this.function);
@override
List<Object> get props => [function];
}
class SearchRoutines extends RoutineEvent {
final String query;
const SearchRoutines(this.query);
@override
List<Object> get props => [query];
}
class AddSelectedIcon extends RoutineEvent {
final String icon;
const AddSelectedIcon(this.icon);
@override
List<Object> get props => [icon];
}
class CreateSceneEvent extends RoutineEvent {
const CreateSceneEvent();
@override
List<Object> get props => [];
}
class RemoveDragCard extends RoutineEvent {
final int index;
final bool isFromThen;
final String key;
const RemoveDragCard({required this.index, required this.isFromThen, required this.key});
@override
List<Object> get props => [index, isFromThen, key];
}
class ChangeAutomationOperator extends RoutineEvent {
final String operator;
const ChangeAutomationOperator({required this.operator});
@override
List<Object> get props => [operator];
}
class EffectiveTimePeriodEvent extends RoutineEvent {
final EffectiveTime effectiveTime;
const EffectiveTimePeriodEvent(this.effectiveTime);
@override
List<Object> get props => [effectiveTime];
}
class CreateAutomationEvent extends RoutineEvent {
final String? automationId;
final bool updateAutomation;
const CreateAutomationEvent({
this.automationId,
this.updateAutomation = false,
});
@override
List<Object> get props => [];
}
class SetRoutineName extends RoutineEvent {
final String name;
const SetRoutineName(this.name);
@override
List<Object> get props => [name];
}
class GetSceneDetails extends RoutineEvent {
final String sceneId;
final bool isUpdate;
final bool isTabToRun;
const GetSceneDetails({
required this.sceneId,
required this.isUpdate,
required this.isTabToRun,
});
@override
List<Object> get props => [sceneId];
}
class GetAutomationDetails extends RoutineEvent {
final String automationId;
final bool isUpdate;
final bool isAutomation;
const GetAutomationDetails({
required this.automationId,
this.isUpdate = false,
this.isAutomation = false,
});
@override
List<Object> get props => [automationId];
}
class InitializeRoutineState extends RoutineEvent {
final RoutineDetailsModel routineDetails;
const InitializeRoutineState(this.routineDetails);
@override
List<Object> get props => [routineDetails];
}
class DeleteScene extends RoutineEvent {
const DeleteScene();
@override
List<Object> get props => [];
}
// class DeleteAutomation extends RoutineEvent {
// final String automationId;
// const DeleteAutomation({required this.automationId});
// @override
// List<Object> get props => [automationId];
// }
class UpdateScene extends RoutineEvent {
const UpdateScene();
@override
List<Object> get props => [];
}
class UpdateAutomation extends RoutineEvent {
const UpdateAutomation();
@override
List<Object> get props => [];
}
class SetAutomationActionExecutor extends RoutineEvent {
final String automationActionExecutor;
const SetAutomationActionExecutor({required this.automationActionExecutor});
@override
List<Object> get props => [automationActionExecutor];
}
class TriggerSwitchTabsEvent extends RoutineEvent {
final bool isRoutineTab;
const TriggerSwitchTabsEvent({required this.isRoutineTab});
@override
List<Object> get props => [isRoutineTab];
}
class CreateNewRoutineViewEvent extends RoutineEvent {
final bool createRoutineView;
const CreateNewRoutineViewEvent({required this.createRoutineView});
@override
List<Object> get props => [createRoutineView];
}
class FetchDevicesInRoutine extends RoutineEvent {}
class ResetRoutineState extends RoutineEvent {}
class ClearFunctions extends RoutineEvent {}
class ResetErrorMessage extends RoutineEvent {}

View File

@ -0,0 +1,136 @@
part of 'routine_bloc.dart';
class RoutineState extends Equatable {
final List<Map<String, dynamic>> ifItems;
final List<Map<String, dynamic>> thenItems;
final List<Map<String, String>> availableCards;
final List<ScenesModel> scenes;
final List<ScenesModel> automations;
final Map<String, List<DeviceFunctionData>> selectedFunctions;
final bool isLoading;
final String? errorMessage;
final String? loadScenesErrorMessage;
final String? loadAutomationErrorMessage;
final String? routineName;
final String? selectedIcon;
final String? searchText;
final bool isTabToRun;
final bool isAutomation;
final String selectedAutomationOperator;
final EffectiveTime? effectiveTime;
final String? sceneId;
final String? automationId;
final bool? isUpdate;
final List<AllDevicesModel> devices;
// final String? automationActionExecutor;
final bool routineTab;
final bool createRoutineView;
const RoutineState(
{this.ifItems = const [],
this.thenItems = const [],
this.availableCards = const [],
this.scenes = const [],
this.automations = const [],
this.selectedFunctions = const {},
this.isLoading = false,
this.errorMessage,
this.routineName,
this.selectedIcon,
this.loadScenesErrorMessage,
this.loadAutomationErrorMessage,
this.searchText,
this.isTabToRun = false,
this.isAutomation = false,
this.selectedAutomationOperator = 'or',
this.effectiveTime,
this.sceneId,
this.automationId,
this.isUpdate,
this.devices = const [],
// this.automationActionExecutor,
this.routineTab = false,
this.createRoutineView = false});
RoutineState copyWith({
List<Map<String, dynamic>>? ifItems,
List<Map<String, dynamic>>? thenItems,
List<ScenesModel>? scenes,
List<ScenesModel>? automations,
Map<String, List<DeviceFunctionData>>? selectedFunctions,
bool? isLoading,
String? errorMessage,
String? routineName,
String? selectedIcon,
String? loadAutomationErrorMessage,
String? loadScenesErrorMessage,
String? searchText,
bool? isTabToRun,
bool? isAutomation,
String? selectedAutomationOperator,
EffectiveTime? effectiveTime,
String? sceneId,
String? automationId,
bool? isUpdate,
List<AllDevicesModel>? devices,
// String? automationActionExecutor,
TextEditingController? nameController,
bool? routineTab,
bool? createRoutineView,
}) {
return RoutineState(
ifItems: ifItems ?? this.ifItems,
thenItems: thenItems ?? this.thenItems,
scenes: scenes ?? this.scenes,
automations: automations ?? this.automations,
selectedFunctions: selectedFunctions ?? this.selectedFunctions,
isLoading: isLoading ?? this.isLoading,
errorMessage: errorMessage ?? this.errorMessage,
routineName: routineName ?? this.routineName,
selectedIcon: selectedIcon ?? this.selectedIcon,
loadScenesErrorMessage:
loadScenesErrorMessage ?? this.loadScenesErrorMessage,
loadAutomationErrorMessage:
loadAutomationErrorMessage ?? this.loadAutomationErrorMessage,
searchText: searchText ?? this.searchText,
isTabToRun: isTabToRun ?? this.isTabToRun,
isAutomation: isAutomation ?? this.isAutomation,
selectedAutomationOperator:
selectedAutomationOperator ?? this.selectedAutomationOperator,
effectiveTime: effectiveTime ?? this.effectiveTime,
sceneId: sceneId ?? this.sceneId,
automationId: automationId ?? this.automationId,
isUpdate: isUpdate ?? this.isUpdate,
devices: devices ?? this.devices,
// automationActionExecutor: automationActionExecutor ?? this.automationActionExecutor,
routineTab: routineTab ?? this.routineTab,
createRoutineView: createRoutineView ?? this.createRoutineView);
}
@override
List<Object?> get props => [
ifItems,
thenItems,
scenes,
automations,
selectedFunctions,
isLoading,
errorMessage,
routineName,
selectedIcon,
loadScenesErrorMessage,
loadAutomationErrorMessage,
searchText,
isTabToRun,
isAutomation,
selectedAutomationOperator,
effectiveTime,
sceneId,
automationId,
isUpdate,
devices,
// automationActionExecutor,
routineTab,
createRoutineView
];
}