Update button behavior in DeviceManagementPage based on routineTab state

This commit is contained in:
mohammad
2025-06-11 10:47:59 +03:00
parent c6b55cb28b
commit 8a274af7be

View File

@ -40,13 +40,14 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: null, backgroundColor: null,
), ),
onPressed: () { onPressed: !state.routineTab
? null
: () {
BlocProvider.of<CreateRoutineBloc>(context) BlocProvider.of<CreateRoutineBloc>(context)
.add(const ResetSelectedEvent()); .add(const ResetSelectedEvent());
context context.read<RoutineBloc>().add(
.read<RoutineBloc>() const TriggerSwitchTabsEvent(isRoutineTab: false));
.add(const TriggerSwitchTabsEvent(isRoutineTab: false));
context context
.read<DeviceManagementBloc>() .read<DeviceManagementBloc>()
.add(FetchDevices(context)); .add(FetchDevices(context));
@ -66,13 +67,14 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: null, backgroundColor: null,
), ),
onPressed: () { onPressed: state.routineTab
? null
: () {
BlocProvider.of<CreateRoutineBloc>(context) BlocProvider.of<CreateRoutineBloc>(context)
.add(const ResetSelectedEvent()); .add(const ResetSelectedEvent());
context context.read<RoutineBloc>().add(
.read<RoutineBloc>() const TriggerSwitchTabsEvent(isRoutineTab: true));
.add(const TriggerSwitchTabsEvent(isRoutineTab: true));
}, },
child: Text( child: Text(
'Routines', 'Routines',