mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
finished adding tasks and removing them , added error handling
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/alert_dialog_countdown.dart';
|
||||
@ -10,6 +13,7 @@ import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/light_divider.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
@ -29,14 +33,22 @@ class DeviceFunctionsView extends StatelessWidget with SceneHelper {
|
||||
List<SceneStaticFunction> functions = [];
|
||||
if (device.functions.isNotEmpty) {
|
||||
functions = getFunctionsWithIcons(
|
||||
type: device.productType, functions: device.functions);
|
||||
type: device.productType,
|
||||
functions: device.functions,
|
||||
deviceId: device.uuid ?? '',
|
||||
deviceName: device.name ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
return DefaultScaffold(
|
||||
title: getTitle(type: device.productType),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
Navigator.popUntil(context, (route) {
|
||||
return route.settings.name == Routes.sceneTasksRoute;
|
||||
});
|
||||
},
|
||||
child: BodyMedium(
|
||||
text: 'Save',
|
||||
fontWeight: FontWeight.normal,
|
||||
@ -81,38 +93,60 @@ class DeviceFunctionsView extends StatelessWidget with SceneHelper {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SceneListTile(
|
||||
iconsSize: 32,
|
||||
minLeadingWidth: 20,
|
||||
assetPath: functions[index].icon,
|
||||
titleString: functions[index].name,
|
||||
trailingWidget: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// selected value or the default value
|
||||
// BodyMedium(text: ),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios_rounded,
|
||||
color: ColorsManager.greyColor,
|
||||
size: 16,
|
||||
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
return SceneListTile(
|
||||
iconsSize: 32,
|
||||
minLeadingWidth: 20,
|
||||
assetPath: functions[index].icon,
|
||||
titleString: functions[index].operationName,
|
||||
trailingWidget: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// selected value or the default value
|
||||
// BodyMedium(text: ),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios_rounded,
|
||||
color: ColorsManager.greyColor,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
context.customAlertDialog(
|
||||
alertBody: functions[index].code == 'temp_set'
|
||||
? AlertDialogTemperatureBody(
|
||||
index: index, functions: functions)
|
||||
: functions[index].code.contains('countdown')
|
||||
? AlertDialogCountdown(
|
||||
durationValue: functions[index]
|
||||
.operationalValues
|
||||
.first
|
||||
.value)
|
||||
: AlertDialogFunctionsOperationsBody(
|
||||
index: index, functions: functions),
|
||||
title: functions[index].name,
|
||||
onConfirm: () {},
|
||||
onPressed: () {
|
||||
context.customAlertDialog(
|
||||
alertBody: functions[index].code == 'temp_set'
|
||||
? AlertDialogTemperatureBody(
|
||||
index: index, functions: functions)
|
||||
: functions[index].code.contains('countdown')
|
||||
? AlertDialogCountdown(
|
||||
durationValue: functions[index]
|
||||
.operationalValues
|
||||
.first
|
||||
.value)
|
||||
: AlertDialogFunctionsOperationsBody(
|
||||
index: index, functions: functions),
|
||||
title: functions[index].operationName,
|
||||
onConfirm: () {
|
||||
final selectedValue = context
|
||||
.read<CreateSceneBloc>()
|
||||
.selectedValue;
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(AddTaskEvent(
|
||||
deviceControlModel: DeviceControlModel(
|
||||
deviceId: device.uuid,
|
||||
code: functions[index].code,
|
||||
value: selectedValue,
|
||||
),
|
||||
deviceId: device.uuid ?? '',
|
||||
operation: functions[index].operationName,
|
||||
icon: device.icon ?? '',
|
||||
deviceName: device.name ?? '',
|
||||
));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user