mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Bug fixes
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/switch_tabs/switch_tabs_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routiens/helper/save_routine_helper.dart';
|
||||
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/discard_dialog.dart';
|
||||
@ -16,8 +15,7 @@ class RoutineSearchAndButtons extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
State<RoutineSearchAndButtons> createState() =>
|
||||
_RoutineSearchAndButtonsState();
|
||||
State<RoutineSearchAndButtons> createState() => _RoutineSearchAndButtonsState();
|
||||
}
|
||||
|
||||
class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
@ -37,15 +35,9 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<RoutineBloc, RoutineState>(
|
||||
listenWhen: (previous, current) =>
|
||||
previous.routineName != current.routineName,
|
||||
listener: (context, state) {
|
||||
if (state.routineName != _nameController.text) {
|
||||
_nameController.text = state.routineName ?? '';
|
||||
}
|
||||
},
|
||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||
builder: (context, state) {
|
||||
_nameController.text = state.routineName ?? '';
|
||||
return LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return Wrap(
|
||||
@ -62,9 +54,8 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: constraints.maxWidth > 700
|
||||
? 450
|
||||
: constraints.maxWidth - 32),
|
||||
maxWidth:
|
||||
constraints.maxWidth > 700 ? 450 : constraints.maxWidth - 32),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -73,13 +64,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
children: [
|
||||
Text('* ',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(
|
||||
color: ColorsManager.red,
|
||||
fontSize: 13)),
|
||||
.copyWith(color: ColorsManager.red, fontSize: 13)),
|
||||
Text(
|
||||
'Routine Name',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: ColorsManager.blackColor,
|
||||
@ -93,24 +81,20 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
decoration: containerWhiteDecoration,
|
||||
child: TextFormField(
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(
|
||||
color: ColorsManager.blackColor),
|
||||
.copyWith(color: ColorsManager.blackColor),
|
||||
controller: _nameController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Please enter the name',
|
||||
hintStyle: context.textTheme.bodyMedium!
|
||||
.copyWith(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.grayColor),
|
||||
.copyWith(fontSize: 12, color: ColorsManager.grayColor),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 10),
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
border: InputBorder.none,
|
||||
),
|
||||
onChanged: (value) {
|
||||
onTapOutside: (_) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(SetRoutineName(value));
|
||||
.add(SetRoutineName(_nameController.text));
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
@ -130,18 +114,16 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
width: 200,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: state.isAutomation ||
|
||||
state.isTabToRun
|
||||
onPressed: state.isAutomation || state.isTabToRun
|
||||
? () async {
|
||||
final result = await SettingHelper
|
||||
.showSettingDialog(
|
||||
final result = await SettingHelper.showSettingDialog(
|
||||
context: context,
|
||||
iconId:
|
||||
state.selectedIcon ?? '',
|
||||
iconId: state.selectedIcon ?? '',
|
||||
);
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddSelectedIcon(result));
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddSelectedIcon(result));
|
||||
}
|
||||
}
|
||||
: null,
|
||||
@ -197,12 +179,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: () async {
|
||||
if (state.routineName == null ||
|
||||
state.routineName!.isEmpty) {
|
||||
if (state.routineName == null || state.routineName!.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text(
|
||||
'Please enter the routine name'),
|
||||
content: const Text('Please enter the routine name'),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: ColorsManager.red,
|
||||
action: SnackBarAction(
|
||||
@ -216,12 +196,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.ifItems.isEmpty ||
|
||||
state.thenItems.isEmpty) {
|
||||
if (state.ifItems.isEmpty || state.thenItems.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text(
|
||||
'Please add if and then condition'),
|
||||
content: const Text('Please add if and then condition'),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: ColorsManager.red,
|
||||
action: SnackBarAction(
|
||||
@ -234,18 +212,17 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
);
|
||||
return;
|
||||
}
|
||||
final result = await SaveRoutineHelper
|
||||
.showSaveRoutineDialog(context);
|
||||
if (result != null && result) {
|
||||
BlocProvider.of<SwitchTabsBloc>(context)
|
||||
.add(
|
||||
const CreateNewRoutineViewEvent(false),
|
||||
);
|
||||
BlocProvider.of<SwitchTabsBloc>(context)
|
||||
.add(
|
||||
const TriggerSwitchTabsEvent(true),
|
||||
);
|
||||
}
|
||||
// final result =
|
||||
// await
|
||||
SaveRoutineHelper.showSaveRoutineDialog(context);
|
||||
// if (result != null && result) {
|
||||
// BlocProvider.of<RoutineBloc>(context).add(
|
||||
// const CreateNewRoutineViewEvent(createRoutineView: false),
|
||||
// );
|
||||
// BlocProvider.of<RoutineBloc>(context).add(
|
||||
// const TriggerSwitchTabsEvent(isRoutineTab: true),
|
||||
// );
|
||||
// }
|
||||
},
|
||||
borderRadius: 15,
|
||||
elevation: 0,
|
||||
@ -276,14 +253,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
child: DefaultButton(
|
||||
onPressed: state.isAutomation || state.isTabToRun
|
||||
? () async {
|
||||
final result =
|
||||
await SettingHelper.showSettingDialog(
|
||||
context: context,
|
||||
iconId: state.selectedIcon ?? '');
|
||||
final result = await SettingHelper.showSettingDialog(
|
||||
context: context, iconId: state.selectedIcon ?? '');
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddSelectedIcon(result));
|
||||
context.read<RoutineBloc>().add(AddSelectedIcon(result));
|
||||
}
|
||||
}
|
||||
: null,
|
||||
@ -333,12 +306,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: () async {
|
||||
if (state.routineName == null ||
|
||||
state.routineName!.isEmpty) {
|
||||
if (state.routineName == null || state.routineName!.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text(
|
||||
'Please enter the routine name'),
|
||||
content: const Text('Please enter the routine name'),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: ColorsManager.red,
|
||||
action: SnackBarAction(
|
||||
@ -352,12 +323,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.ifItems.isEmpty ||
|
||||
state.thenItems.isEmpty) {
|
||||
if (state.ifItems.isEmpty || state.thenItems.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text(
|
||||
'Please add if and then condition'),
|
||||
content: const Text('Please add if and then condition'),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: ColorsManager.red,
|
||||
action: SnackBarAction(
|
||||
@ -370,17 +339,17 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
);
|
||||
return;
|
||||
}
|
||||
final result =
|
||||
await SaveRoutineHelper.showSaveRoutineDialog(
|
||||
context);
|
||||
if (result != null && result) {
|
||||
BlocProvider.of<SwitchTabsBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(false),
|
||||
);
|
||||
BlocProvider.of<SwitchTabsBloc>(context).add(
|
||||
const TriggerSwitchTabsEvent(true),
|
||||
);
|
||||
}
|
||||
// final result =
|
||||
// await
|
||||
SaveRoutineHelper.showSaveRoutineDialog(context);
|
||||
// if (result != null && result) {
|
||||
// BlocProvider.of<RoutineBloc>(context).add(
|
||||
// const CreateNewRoutineViewEvent(createRoutineView: false),
|
||||
// );
|
||||
// BlocProvider.of<RoutineBloc>(context).add(
|
||||
// const TriggerSwitchTabsEvent(isRoutineTab: true),
|
||||
// );
|
||||
// }
|
||||
},
|
||||
borderRadius: 15,
|
||||
elevation: 0,
|
||||
|
Reference in New Issue
Block a user