mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 03:24:54 +00:00
@ -15,8 +15,7 @@ class RoutineSearchAndButtons extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
State<RoutineSearchAndButtons> createState() =>
|
||||
_RoutineSearchAndButtonsState();
|
||||
State<RoutineSearchAndButtons> createState() => _RoutineSearchAndButtonsState();
|
||||
}
|
||||
|
||||
class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
@ -62,9 +61,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 +71,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,23 +88,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,
|
||||
),
|
||||
onTapOutside: (_) {
|
||||
context.read<RoutineBloc>().add(
|
||||
SetRoutineName(_nameController.text));
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(SetRoutineName(_nameController.text));
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
@ -122,44 +114,41 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (constraints.maxWidth <= 1000)
|
||||
const SizedBox()
|
||||
else
|
||||
SizedBox(
|
||||
height: 40,
|
||||
width: 200,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: state.isAutomation ||
|
||||
state.isTabToRun
|
||||
? () async {
|
||||
final result = await SettingHelper
|
||||
.showSettingDialog(
|
||||
context: context,
|
||||
iconId: state.selectedIcon ?? '',
|
||||
);
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddSelectedIcon(result));
|
||||
}
|
||||
}
|
||||
: null,
|
||||
borderRadius: 15,
|
||||
elevation: 0,
|
||||
borderColor: ColorsManager.greyColor,
|
||||
backgroundColor: ColorsManager.boxColor,
|
||||
child: const Text(
|
||||
'Settings',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.primaryColor,
|
||||
(constraints.maxWidth <= 1000)
|
||||
? const SizedBox()
|
||||
: SizedBox(
|
||||
height: 40,
|
||||
width: 200,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: state.isAutomation || state.isTabToRun
|
||||
? () async {
|
||||
final result = await SettingHelper.showSettingDialog(
|
||||
context: context,
|
||||
iconId: state.selectedIcon ?? '',
|
||||
);
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddSelectedIcon(result));
|
||||
}
|
||||
}
|
||||
: null,
|
||||
borderRadius: 15,
|
||||
elevation: 0,
|
||||
borderColor: ColorsManager.greyColor,
|
||||
backgroundColor: ColorsManager.boxColor,
|
||||
child: const Text(
|
||||
'Settings',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -197,12 +186,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 +203,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(
|
||||
@ -236,10 +221,8 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
}
|
||||
// final result =
|
||||
// await
|
||||
BlocProvider.of<RoutineBloc>(context)
|
||||
.add(ResetErrorMessage());
|
||||
SaveRoutineHelper.showSaveRoutineDialog(
|
||||
context);
|
||||
BlocProvider.of<RoutineBloc>(context).add(ResetErrorMessage());
|
||||
SaveRoutineHelper.showSaveRoutineDialog(context);
|
||||
// if (result != null && result) {
|
||||
// BlocProvider.of<RoutineBloc>(context).add(
|
||||
// const CreateNewRoutineViewEvent(createRoutineView: false),
|
||||
@ -278,14 +261,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,
|
||||
@ -335,12 +314,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(
|
||||
@ -354,12 +331,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(
|
||||
@ -374,8 +349,7 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
|
||||
}
|
||||
// final result =
|
||||
// await
|
||||
BlocProvider.of<RoutineBloc>(context)
|
||||
.add(ResetErrorMessage());
|
||||
BlocProvider.of<RoutineBloc>(context).add(ResetErrorMessage());
|
||||
SaveRoutineHelper.showSaveRoutineDialog(context);
|
||||
// if (result != null && result) {
|
||||
// BlocProvider.of<RoutineBloc>(context).add(
|
||||
|
||||
Reference in New Issue
Block a user