fix real time garage door and add flush sensor to routines

This commit is contained in:
mohammad
2025-04-29 10:06:17 +03:00
parent c9c939c59f
commit ccce7bb671
21 changed files with 1435 additions and 140 deletions

View File

@ -27,7 +27,8 @@ class ThenContainer extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('THEN',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 16),
state.isLoading && state.isUpdate == true
? const Center(
@ -40,11 +41,12 @@ class ThenContainer extends StatelessWidget {
state.thenItems.length,
(index) => GestureDetector(
onTap: () async {
if (state.thenItems[index]['deviceId'] ==
if (state.thenItems[index]
['deviceId'] ==
'delay') {
final result = await DelayHelper
.showDelayPickerDialog(
context, state.thenItems[index]);
.showDelayPickerDialog(context,
state.thenItems[index]);
if (result != null) {
context
@ -64,14 +66,17 @@ class ThenContainer extends StatelessWidget {
context: context,
builder: (BuildContext context) =>
AutomationDialog(
automationName: state.thenItems[index]
['name'] ??
'Automation',
automationId: state.thenItems[index]
['deviceId'] ??
'',
uniqueCustomId: state.thenItems[index]
['uniqueCustomId'],
automationName:
state.thenItems[index]
['name'] ??
'Automation',
automationId:
state.thenItems[index]
['deviceId'] ??
'',
uniqueCustomId:
state.thenItems[index]
['uniqueCustomId'],
),
);
@ -80,11 +85,13 @@ class ThenContainer extends StatelessWidget {
.read<RoutineBloc>()
.add(AddToThenContainer({
...state.thenItems[index],
'imagePath': Assets.automation,
'title': state.thenItems[index]
['name'] ??
'imagePath':
Assets.automation,
'title':
state.thenItems[index]
['title'],
['name'] ??
state.thenItems[index]
['title'],
}));
}
return;
@ -109,8 +116,9 @@ class ThenContainer extends StatelessWidget {
'WPS',
'CPS',
"GW",
].contains(
state.thenItems[index]['productType'])) {
"NCPS"
].contains(state.thenItems[index]
['productType'])) {
context.read<RoutineBloc>().add(
AddToThenContainer(
state.thenItems[index]));
@ -120,7 +128,9 @@ class ThenContainer extends StatelessWidget {
imagePath: state.thenItems[index]
['imagePath'] ??
'',
title: state.thenItems[index]['title'] ?? '',
title: state.thenItems[index]
['title'] ??
'',
deviceData: state.thenItems[index],
padding: const EdgeInsets.symmetric(
horizontal: 4, vertical: 8),
@ -157,8 +167,8 @@ class ThenContainer extends StatelessWidget {
}
if (mutableData['type'] == 'automation') {
int index = state.thenItems
.indexWhere((item) => item['deviceId'] == mutableData['deviceId']);
int index = state.thenItems.indexWhere(
(item) => item['deviceId'] == mutableData['deviceId']);
if (index != -1) {
return;
}
@ -183,8 +193,8 @@ class ThenContainer extends StatelessWidget {
}
if (mutableData['type'] == 'tap_to_run' && state.isAutomation) {
int index = state.thenItems
.indexWhere((item) => item['deviceId'] == mutableData['deviceId']);
int index = state.thenItems.indexWhere(
(item) => item['deviceId'] == mutableData['deviceId']);
if (index != -1) {
return;
}
@ -222,7 +232,7 @@ class ThenContainer extends StatelessWidget {
dialogType: "THEN");
if (result != null) {
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'GW', 'CPS']
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'GW', 'CPS', "NCPS"]
.contains(mutableData['productType'])) {
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
}