mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
matched design of Function and action in SaveRoutineHelper.showSaveRoutineDialog
This commit is contained in:
@ -5,8 +5,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/dialog_header.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';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
@ -31,7 +31,8 @@ class SaveRoutineHelper {
|
|||||||
children: [
|
children: [
|
||||||
DialogHeader('Create a scene: ${state.routineName ?? ""}'),
|
DialogHeader('Create a scene: ${state.routineName ?? ""}'),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -59,8 +60,9 @@ class SaveRoutineHelper {
|
|||||||
),
|
),
|
||||||
if (state.isAutomation)
|
if (state.isAutomation)
|
||||||
...state.ifItems.map((item) {
|
...state.ifItems.map((item) {
|
||||||
final functions =
|
final functions = state.selectedFunctions[
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
item['uniqueCustomId']] ??
|
||||||
|
[];
|
||||||
return functionRow(item, context, functions);
|
return functionRow(item, context, functions);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@ -68,10 +70,8 @@ class SaveRoutineHelper {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
// Right side - THEN items
|
// Right side - THEN items
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
@ -82,8 +82,9 @@ class SaveRoutineHelper {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
...state.thenItems.map((item) {
|
...state.thenItems.map((item) {
|
||||||
final functions =
|
final functions = state.selectedFunctions[
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
item['uniqueCustomId']] ??
|
||||||
|
[];
|
||||||
return functionRow(item, context, functions);
|
return functionRow(item, context, functions);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@ -92,33 +93,30 @@ class SaveRoutineHelper {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// if (state.errorMessage != null || state.errorMessage!.isNotEmpty)
|
|
||||||
// Padding(
|
|
||||||
// padding: const EdgeInsets.all(8.0),
|
|
||||||
// child: Text(
|
|
||||||
// state.errorMessage!,
|
|
||||||
// style: const TextStyle(color: Colors.red),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
DialogFooter(
|
DialogFooter(
|
||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onConfirm: () async {
|
onConfirm: () async {
|
||||||
if (state.isAutomation) {
|
if (state.isAutomation) {
|
||||||
if (state.isUpdate ?? false) {
|
if (state.isUpdate ?? false) {
|
||||||
context.read<RoutineBloc>().add(const UpdateAutomation());
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(const UpdateAutomation());
|
||||||
} else {
|
} else {
|
||||||
context.read<RoutineBloc>().add(const CreateAutomationEvent());
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(const CreateAutomationEvent());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (state.isUpdate ?? false) {
|
if (state.isUpdate ?? false) {
|
||||||
context.read<RoutineBloc>().add(const UpdateScene());
|
context.read<RoutineBloc>().add(const UpdateScene());
|
||||||
} else {
|
} else {
|
||||||
context.read<RoutineBloc>().add(const CreateSceneEvent());
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(const CreateSceneEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if (state.errorMessage == null || state.errorMessage!.isEmpty) {
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
isConfirmEnabled: true,
|
isConfirmEnabled: true,
|
||||||
),
|
),
|
||||||
@ -133,7 +131,10 @@ class SaveRoutineHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Widget functionRow(
|
static Widget functionRow(
|
||||||
dynamic item, BuildContext context, List<DeviceFunctionData> functions) {
|
dynamic item,
|
||||||
|
BuildContext context,
|
||||||
|
List<DeviceFunctionData> functions,
|
||||||
|
) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(top: 6),
|
padding: const EdgeInsets.only(top: 6),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -142,19 +143,36 @@ class SaveRoutineHelper {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
spacing: 8,
|
spacing: 17,
|
||||||
children: [
|
children: [
|
||||||
item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
Container(
|
||||||
? Image.memory(
|
width: 22,
|
||||||
base64Decode(item['icon']),
|
height: 22,
|
||||||
width: 22,
|
padding: const EdgeInsetsDirectional.all(4),
|
||||||
height: 22,
|
decoration: BoxDecoration(
|
||||||
)
|
shape: BoxShape.circle,
|
||||||
: SvgPicture.asset(
|
color: ColorsManager.textFieldGreyColor,
|
||||||
item['imagePath'],
|
border: Border.all(
|
||||||
width: 22,
|
color: ColorsManager.neutralGray,
|
||||||
height: 22,
|
width: 1.5,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
||||||
|
? Image.memory(
|
||||||
|
base64Decode(item['icon']),
|
||||||
|
width: 12,
|
||||||
|
height: 22,
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
)
|
||||||
|
: SvgPicture.asset(
|
||||||
|
item['imagePath'],
|
||||||
|
width: 12,
|
||||||
|
height: 12,
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@ -166,16 +184,18 @@ class SaveRoutineHelper {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
fontSize: 14,
|
fontSize: 15,
|
||||||
color: ColorsManager.textPrimaryColor,
|
color: ColorsManager.textPrimaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Wrap(
|
Wrap(
|
||||||
|
runSpacing: 16,
|
||||||
|
spacing: 4,
|
||||||
children: functions
|
children: functions
|
||||||
.map((f) => Text(
|
.map((f) => Text(
|
||||||
'${f.operationName}: ${f.value}',
|
'${f.operationName}: ${f.value}',
|
||||||
style: context.textTheme.bodySmall
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
?.copyWith(color: ColorsManager.grayColor, fontSize: 8),
|
color: ColorsManager.grayColor, fontSize: 8),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
))
|
))
|
||||||
@ -197,7 +217,10 @@ class SaveRoutineHelper {
|
|||||||
child: Row(
|
child: Row(
|
||||||
spacing: 2,
|
spacing: 2,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(width: 8, height: 8, child: SvgPicture.asset(Assets.deviceTagIcon)),
|
SizedBox(
|
||||||
|
width: 8,
|
||||||
|
height: 8,
|
||||||
|
child: SvgPicture.asset(Assets.deviceTagIcon)),
|
||||||
Text(
|
Text(
|
||||||
item['tag'] ?? '',
|
item['tag'] ?? '',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@ -218,7 +241,9 @@ class SaveRoutineHelper {
|
|||||||
spacing: 2,
|
spacing: 2,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 8, height: 8, child: SvgPicture.asset(Assets.spaceLocationIcon)),
|
width: 8,
|
||||||
|
height: 8,
|
||||||
|
child: SvgPicture.asset(Assets.spaceLocationIcon)),
|
||||||
Text(
|
Text(
|
||||||
item['subSpace'] ?? '',
|
item['subSpace'] ?? '',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
Reference in New Issue
Block a user