mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
bug fixes
This commit is contained in:
@ -8,8 +8,8 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class SaveRoutineHelper {
|
class SaveRoutineHelper {
|
||||||
static Future<void> showSaveRoutineDialog(BuildContext context) async {
|
static Future<bool?> showSaveRoutineDialog(BuildContext context) async {
|
||||||
return showDialog<void>(
|
return showDialog<bool?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
@ -54,27 +54,23 @@ class SaveRoutineHelper {
|
|||||||
),
|
),
|
||||||
if (state.isAutomation)
|
if (state.isAutomation)
|
||||||
...state.ifItems.map((item) {
|
...state.ifItems.map((item) {
|
||||||
final functions = state.selectedFunctions[
|
final functions =
|
||||||
item['uniqueCustomId']] ??
|
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
[];
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: SvgPicture.asset(
|
leading: SvgPicture.asset(
|
||||||
item['imagePath'],
|
item['imagePath'],
|
||||||
width: 22,
|
width: 22,
|
||||||
height: 22,
|
height: 22,
|
||||||
),
|
),
|
||||||
title: Text(item['title'],
|
title:
|
||||||
style: const TextStyle(fontSize: 14)),
|
Text(item['title'], style: const TextStyle(fontSize: 14)),
|
||||||
subtitle: Wrap(
|
subtitle: Wrap(
|
||||||
children: functions
|
children: functions
|
||||||
.map((f) => Text(
|
.map((f) => Text(
|
||||||
'${f.operationName}: ${f.value}, ',
|
'${f.operationName}: ${f.value}, ',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: ColorsManager
|
color: ColorsManager.grayColor, fontSize: 8),
|
||||||
.grayColor,
|
overflow: TextOverflow.ellipsis,
|
||||||
fontSize: 8),
|
|
||||||
overflow:
|
|
||||||
TextOverflow.ellipsis,
|
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
@ -99,25 +95,22 @@ class SaveRoutineHelper {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
...state.thenItems.map((item) {
|
...state.thenItems.map((item) {
|
||||||
final functions = state.selectedFunctions[
|
final functions =
|
||||||
item['uniqueCustomId']] ??
|
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
[];
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: SvgPicture.asset(
|
leading: SvgPicture.asset(
|
||||||
item['imagePath'],
|
item['imagePath'],
|
||||||
width: 22,
|
width: 22,
|
||||||
height: 22,
|
height: 22,
|
||||||
),
|
),
|
||||||
title: Text(item['title'],
|
title:
|
||||||
style: const TextStyle(fontSize: 14)),
|
Text(item['title'], style: const TextStyle(fontSize: 14)),
|
||||||
subtitle: Wrap(
|
subtitle: Wrap(
|
||||||
children: functions
|
children: functions
|
||||||
.map((f) => Text(
|
.map((f) => Text(
|
||||||
'${f.operationName}: ${f.value}, ',
|
'${f.operationName}: ${f.value}, ',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color:
|
color: ColorsManager.grayColor, fontSize: 8),
|
||||||
ColorsManager.grayColor,
|
|
||||||
fontSize: 8),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
))
|
))
|
||||||
@ -140,19 +133,15 @@ class SaveRoutineHelper {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
DialogFooter(
|
DialogFooter(
|
||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context, false),
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
if (state.isAutomation) {
|
if (state.isAutomation) {
|
||||||
context
|
context.read<RoutineBloc>().add(const CreateAutomationEvent());
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(const CreateAutomationEvent());
|
|
||||||
} else {
|
} else {
|
||||||
context
|
context.read<RoutineBloc>().add(const CreateSceneEvent());
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(const CreateSceneEvent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context, true);
|
||||||
},
|
},
|
||||||
isConfirmEnabled: true,
|
isConfirmEnabled: true,
|
||||||
),
|
),
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.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/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/view/create_new_routine_view.dart';
|
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/main_routine_view/routine_view_card.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/main_routine_view/routine_view_card.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
@ -13,8 +11,7 @@ class FetchRoutineScenesAutomation extends StatefulWidget {
|
|||||||
const FetchRoutineScenesAutomation({super.key});
|
const FetchRoutineScenesAutomation({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FetchRoutineScenesAutomation> createState() =>
|
State<FetchRoutineScenesAutomation> createState() => _FetchRoutineScenesState();
|
||||||
_FetchRoutineScenesState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||||
@ -31,96 +28,94 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return SingleChildScrollView(
|
return state.isLoading
|
||||||
child: Padding(
|
? const Center(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
child: CircularProgressIndicator(),
|
||||||
child: Column(
|
)
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
: SingleChildScrollView(
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
if (state.isLoading)
|
child: Column(
|
||||||
const Center(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: CircularProgressIndicator(),
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Scenes (Tab to Run)",
|
"Scenes (Tab to Run)",
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
if (state.scenes.isEmpty)
|
||||||
|
Text(
|
||||||
|
"No scenes found",
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (state.scenes.isNotEmpty)
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: state.scenes.length,
|
||||||
|
itemBuilder: (context, index) => Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||||
|
),
|
||||||
|
child: RoutineViewCard(
|
||||||
|
onTap: () {},
|
||||||
|
textString: state.scenes[index].name,
|
||||||
|
icon: state.scenes[index].icon ?? Assets.logoHorizontal,
|
||||||
|
isFromScenes: true,
|
||||||
|
iconInBytes: state.scenes[index].iconInBytes,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
Text(
|
||||||
|
"Automations",
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
if (state.automations.isEmpty)
|
||||||
|
Text(
|
||||||
|
"No automations found",
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (state.automations.isNotEmpty)
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: state.automations.length,
|
||||||
|
itemBuilder: (context, index) => Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||||
|
),
|
||||||
|
child: RoutineViewCard(
|
||||||
|
onTap: () {},
|
||||||
|
textString: state.automations[index].name,
|
||||||
|
icon: state.automations[index].icon ?? Assets.automation,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
);
|
||||||
if (state.scenes.isEmpty)
|
|
||||||
Text(
|
|
||||||
"No scenes found",
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.scenes.isNotEmpty)
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
|
||||||
),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.scenes.length,
|
|
||||||
itemBuilder: (context, index) => Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
|
||||||
),
|
|
||||||
child: RoutineViewCard(
|
|
||||||
onTap: () {},
|
|
||||||
textString: state.scenes[index].name,
|
|
||||||
icon:
|
|
||||||
state.scenes[index].icon ?? Assets.logoHorizontal,
|
|
||||||
isFromScenes: true,
|
|
||||||
iconInBytes: state.scenes[index].iconInBytes,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Text(
|
|
||||||
"Automations",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
if (state.automations.isEmpty)
|
|
||||||
Text(
|
|
||||||
"No automations found",
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.automations.isNotEmpty)
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
|
||||||
),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.automations.length,
|
|
||||||
itemBuilder: (context, index) => Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
|
||||||
),
|
|
||||||
child: RoutineViewCard(
|
|
||||||
onTap: () {},
|
|
||||||
textString: state.automations[index].name,
|
|
||||||
icon: state.automations[index].icon ??
|
|
||||||
Assets.automation,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/common/buttons/default_button.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/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/helper/save_routine_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/save_routine_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/discard_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/discard_dialog.dart';
|
||||||
@ -173,7 +174,7 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
|||||||
width: 200,
|
width: 200,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
if (state.routineName == null || state.routineName!.isEmpty) {
|
if (state.routineName == null || state.routineName!.isEmpty) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@ -207,7 +208,16 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SaveRoutineHelper.showSaveRoutineDialog(context);
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
|
Reference in New Issue
Block a user