mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 07:31:44 +00:00
push snackbar fix and device to scene route
This commit is contained in:
@ -44,11 +44,13 @@ class SceneListview extends StatelessWidget {
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneClearEvent());
|
||||
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||
FetchSceneTasksEvent(
|
||||
sceneId: scene.id, isAutomation: false));
|
||||
|
||||
/// the state to set the scene type must be after the fetch
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||
},
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.4,
|
||||
|
||||
@ -13,6 +13,7 @@ import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
|
||||
part 'create_scene_event.dart';
|
||||
part 'create_scene_state.dart';
|
||||
@ -364,6 +365,9 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
sceneType = CreateSceneEnum.none;
|
||||
conditionRule = 'or';
|
||||
emit(const CreateSceneWithTasks(success: true));
|
||||
CustomSnackBar.greenSnackBar(event.createSceneModel != null
|
||||
? 'Scene updated successfully'
|
||||
: 'Scene created successfully');
|
||||
} else {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
|
||||
@ -24,13 +24,14 @@ class CreateSceneSaveButton extends StatefulWidget {
|
||||
State<CreateSceneSaveButton> createState() => _CreateSceneSaveButtonState();
|
||||
}
|
||||
|
||||
class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton> with SceneLogicHelper {
|
||||
class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
||||
with SceneLogicHelper {
|
||||
late TextEditingController sceneNameController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sceneNameController =
|
||||
TextEditingController(text: widget.sceneName.isNotEmpty ? widget.sceneName : '');
|
||||
sceneNameController = TextEditingController(
|
||||
text: widget.sceneName.isNotEmpty ? widget.sceneName : '');
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@ -48,9 +49,6 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton> with Scen
|
||||
if (state.success) {
|
||||
navigateToRoute(context, Routes.homeRoute);
|
||||
sceneNameController.text = '';
|
||||
CustomSnackBar.greenSnackBar(widget.sceneName.isNotEmpty
|
||||
? 'Scene updated successfully'
|
||||
: 'Scene created successfully');
|
||||
}
|
||||
} else if (state is CreateSceneError) {
|
||||
CustomSnackBar.displaySnackBar(state.message);
|
||||
@ -60,7 +58,8 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton> with Scen
|
||||
return DefaultButton(
|
||||
onPressed: () {
|
||||
final sceneBloc = context.read<CreateSceneBloc>();
|
||||
final isAutomation = sceneBloc.sceneType == CreateSceneEnum.deviceStatusChanges;
|
||||
final isAutomation =
|
||||
sceneBloc.sceneType == CreateSceneEnum.deviceStatusChanges;
|
||||
|
||||
if (widget.sceneName.isNotEmpty) {
|
||||
handleSaveButtonPress(
|
||||
@ -83,11 +82,13 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton> with Scen
|
||||
elevation: WidgetStateProperty.all(0),
|
||||
textStyle: WidgetStateProperty.all(context.bodyMedium),
|
||||
hintStyle: WidgetStateProperty.all(
|
||||
context.bodyMedium
|
||||
.copyWith(fontSize: 14, color: ColorsManager.secondaryTextColor),
|
||||
context.bodyMedium.copyWith(
|
||||
fontSize: 14,
|
||||
color: ColorsManager.secondaryTextColor),
|
||||
),
|
||||
hintText: 'Enter scene name',
|
||||
backgroundColor: WidgetStateProperty.all(ColorsManager.backgroundColor),
|
||||
backgroundColor: WidgetStateProperty.all(
|
||||
ColorsManager.backgroundColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -39,11 +39,15 @@ class SceneItem extends StatelessWidget {
|
||||
if (disablePlayButton == false) {
|
||||
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||
FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
||||
|
||||
/// the state to set the scene type must be after the fetch
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||
} else {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: true));
|
||||
|
||||
/// the state to set the scene type must be after the fetch
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.deviceStatusChanges));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user