push routine name field

This commit is contained in:
ashrafzarkanisala
2024-11-26 11:40:34 +03:00
parent 7ea628af92
commit 8d908e894b
3 changed files with 15 additions and 1 deletions

View File

@ -31,6 +31,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
on<ChangeAutomationOperator>(_changeOperatorOperator); on<ChangeAutomationOperator>(_changeOperatorOperator);
on<EffectiveTimePeriodEvent>(_onEffectiveTimeEvent); on<EffectiveTimePeriodEvent>(_onEffectiveTimeEvent);
on<CreateAutomationEvent>(_onCreateAutomation); on<CreateAutomationEvent>(_onCreateAutomation);
on<SetRoutineName>(_onSetRoutineName);
// on<RemoveFunction>(_onRemoveFunction); // on<RemoveFunction>(_onRemoveFunction);
// on<ClearFunctions>(_onClearFunctions); // on<ClearFunctions>(_onClearFunctions);
} }
@ -350,4 +351,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
EffectiveTimePeriodEvent event, Emitter<RoutineState> emit) { EffectiveTimePeriodEvent event, Emitter<RoutineState> emit) {
emit(state.copyWith(effectiveTime: event.effectiveTime)); emit(state.copyWith(effectiveTime: event.effectiveTime));
} }
FutureOr<void> _onSetRoutineName(
SetRoutineName event, Emitter<RoutineState> emit) {
emit(state.copyWith(routineName: event.name));
}
} }

View File

@ -115,4 +115,10 @@ class CreateAutomationEvent extends RoutineEvent {
List<Object> get props => []; List<Object> get props => [];
} }
class SetRoutineName extends RoutineEvent {
final String name;
const SetRoutineName(this.name);
@override
List<Object> get props => [name];
}
class ClearFunctions extends RoutineEvent {} class ClearFunctions extends RoutineEvent {}

View File

@ -45,7 +45,9 @@ class RoutineSearchAndButtons extends StatelessWidget {
isRequired: true, isRequired: true,
width: 450, width: 450,
onChanged: (value) { onChanged: (value) {
// context.read<RoutineBloc>().add(SearchRoutines(value)); context
.read<RoutineBloc>()
.add(SetRoutineName(value));
}, },
), ),
), ),