mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
Fixed design issues
This commit is contained in:
@ -15,10 +15,13 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
|||||||
|
|
||||||
mixin SceneLogicHelper {
|
mixin SceneLogicHelper {
|
||||||
bool isOnlyDelayOrDelayLast(List<SceneStaticFunction> tasks) {
|
bool isOnlyDelayOrDelayLast(List<SceneStaticFunction> tasks) {
|
||||||
final lastTask = tasks.last;
|
final lastTask = tasks.isNotEmpty ? tasks.last : null;
|
||||||
return tasks.every((task) => task.code == 'delay') ||
|
|
||||||
lastTask.code == 'delay' ||
|
return tasks.isNotEmpty
|
||||||
lastTask.deviceId == 'delay';
|
? tasks.every((task) => task.code == 'delay') ||
|
||||||
|
lastTask!.code == 'delay' ||
|
||||||
|
lastTask.deviceId == 'delay'
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSaveButtonPress(
|
void handleSaveButtonPress(
|
||||||
@ -177,24 +180,21 @@ mixin SceneLogicHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getTheCorrectDialogBody(
|
Widget getTheCorrectDialogBody(SceneStaticFunction taskItem, dynamic functionValue,
|
||||||
SceneStaticFunction taskItem, dynamic functionValue,
|
|
||||||
{required bool isAutomation}) {
|
{required bool isAutomation}) {
|
||||||
if (taskItem.operationDialogType == OperationDialogType.temperature) {
|
if (taskItem.operationDialogType == OperationDialogType.temperature) {
|
||||||
return AlertDialogTemperatureBody(
|
return AlertDialogTemperatureBody(
|
||||||
taskItem: taskItem,
|
taskItem: taskItem,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
);
|
);
|
||||||
} else if ((taskItem.operationDialogType ==
|
} else if ((taskItem.operationDialogType == OperationDialogType.countdown) ||
|
||||||
OperationDialogType.countdown) ||
|
|
||||||
(taskItem.operationDialogType == OperationDialogType.delay)) {
|
(taskItem.operationDialogType == OperationDialogType.delay)) {
|
||||||
return AlertDialogCountdown(
|
return AlertDialogCountdown(
|
||||||
durationValue: taskItem.functionValue ?? 0,
|
durationValue: taskItem.functionValue ?? 0,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
function: taskItem,
|
function: taskItem,
|
||||||
);
|
);
|
||||||
} else if (taskItem.operationDialogType ==
|
} else if (taskItem.operationDialogType == OperationDialogType.integerSteps) {
|
||||||
OperationDialogType.integerSteps) {
|
|
||||||
return AlertDialogSliderSteps(
|
return AlertDialogSliderSteps(
|
||||||
taskItem: taskItem,
|
taskItem: taskItem,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
|
@ -60,7 +60,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
SceneListTile(
|
SceneListTile(
|
||||||
assetPath: Assets.player,
|
assetPath: Assets.player,
|
||||||
titleString: 'Select Automation',
|
titleString: 'Select Smart Scene',
|
||||||
minLeadingWidth: 30,
|
minLeadingWidth: 30,
|
||||||
assetHeight: 24,
|
assetHeight: 24,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
@ -70,8 +70,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(context, Routes.smartAutomationSelectRoute,
|
Navigator.pushNamed(context, Routes.smartAutomationSelectRoute, arguments: sceneId);
|
||||||
arguments: sceneId);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SceneListTile(
|
SceneListTile(
|
||||||
@ -93,8 +92,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onDelayActionPressed(BuildContext context) {
|
void _onDelayActionPressed(BuildContext context) {
|
||||||
final functionValues =
|
final functionValues = context.read<CreateSceneBloc>().selectedValues['delay'];
|
||||||
context.read<CreateSceneBloc>().selectedValues['delay'];
|
|
||||||
final functions = [
|
final functions = [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: 'delay',
|
deviceId: 'delay',
|
||||||
@ -117,8 +115,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
title: functions[0].operationName,
|
title: functions[0].operationName,
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
final selectedValue =
|
final selectedValue = context.read<CreateSceneBloc>().selectedValues['delay'];
|
||||||
context.read<CreateSceneBloc>().selectedValues['delay'];
|
|
||||||
context.read<CreateSceneBloc>().add(TempHoldSceneTasksEvent(
|
context.read<CreateSceneBloc>().add(TempHoldSceneTasksEvent(
|
||||||
deviceControlModel: DeviceControlModel(
|
deviceControlModel: DeviceControlModel(
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
@ -141,9 +138,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
|
|
||||||
for (var element in tempTaskList) {
|
for (var element in tempTaskList) {
|
||||||
if (element.code == functions[0].code) {
|
if (element.code == functions[0].code) {
|
||||||
context
|
context.read<CreateSceneBloc>().add(RemoveTempTaskByIdEvent(code: functions[0].code));
|
||||||
.read<CreateSceneBloc>()
|
|
||||||
.add(RemoveTempTaskByIdEvent(code: functions[0].code));
|
|
||||||
context
|
context
|
||||||
.read<CreateSceneBloc>()
|
.read<CreateSceneBloc>()
|
||||||
.add(RemoveFromSelectedValueById(code: functions[0].code));
|
.add(RemoveFromSelectedValueById(code: functions[0].code));
|
||||||
|
@ -24,14 +24,13 @@ class CreateSceneSaveButton extends StatefulWidget {
|
|||||||
State<CreateSceneSaveButton> createState() => _CreateSceneSaveButtonState();
|
State<CreateSceneSaveButton> createState() => _CreateSceneSaveButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton> with SceneLogicHelper {
|
||||||
with SceneLogicHelper {
|
|
||||||
late TextEditingController sceneNameController;
|
late TextEditingController sceneNameController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
sceneNameController = TextEditingController(
|
sceneNameController =
|
||||||
text: widget.sceneName.isNotEmpty ? widget.sceneName : '');
|
TextEditingController(text: widget.sceneName.isNotEmpty ? widget.sceneName : '');
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,12 +45,12 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
|||||||
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is CreateSceneWithTasks) {
|
if (state is CreateSceneWithTasks) {
|
||||||
if (state.success == true) {
|
if (state.success) {
|
||||||
navigateToRoute(context, Routes.homeRoute);
|
navigateToRoute(context, Routes.homeRoute);
|
||||||
sceneNameController.text = '';
|
sceneNameController.text = '';
|
||||||
CustomSnackBar.greenSnackBar('Scene created successfully');
|
CustomSnackBar.greenSnackBar(widget.sceneName.isNotEmpty
|
||||||
|
? 'Scene updated successfully'
|
||||||
return;
|
: 'Scene created successfully');
|
||||||
}
|
}
|
||||||
} else if (state is CreateSceneError) {
|
} else if (state is CreateSceneError) {
|
||||||
CustomSnackBar.displaySnackBar(state.message);
|
CustomSnackBar.displaySnackBar(state.message);
|
||||||
@ -61,8 +60,7 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
|||||||
return DefaultButton(
|
return DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final sceneBloc = context.read<CreateSceneBloc>();
|
final sceneBloc = context.read<CreateSceneBloc>();
|
||||||
final isAutomation =
|
final isAutomation = sceneBloc.sceneType == CreateSceneEnum.deviceStatusChanges;
|
||||||
sceneBloc.sceneType == CreateSceneEnum.deviceStatusChanges;
|
|
||||||
|
|
||||||
if (widget.sceneName.isNotEmpty) {
|
if (widget.sceneName.isNotEmpty) {
|
||||||
handleSaveButtonPress(
|
handleSaveButtonPress(
|
||||||
@ -85,13 +83,11 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
|||||||
elevation: WidgetStateProperty.all(0),
|
elevation: WidgetStateProperty.all(0),
|
||||||
textStyle: WidgetStateProperty.all(context.bodyMedium),
|
textStyle: WidgetStateProperty.all(context.bodyMedium),
|
||||||
hintStyle: WidgetStateProperty.all(
|
hintStyle: WidgetStateProperty.all(
|
||||||
context.bodyMedium.copyWith(
|
context.bodyMedium
|
||||||
fontSize: 14,
|
.copyWith(fontSize: 14, color: ColorsManager.secondaryTextColor),
|
||||||
color: ColorsManager.secondaryTextColor),
|
|
||||||
),
|
),
|
||||||
hintText: 'Enter scene name',
|
hintText: 'Enter scene name',
|
||||||
backgroundColor: WidgetStateProperty.all(
|
backgroundColor: WidgetStateProperty.all(ColorsManager.backgroundColor),
|
||||||
ColorsManager.backgroundColor),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user