bug fixes

This commit is contained in:
Abdullah Alassaf
2024-11-28 01:12:18 +03:00
parent 9b5ddc4dc8
commit 3b18c4e8cf
4 changed files with 44 additions and 14 deletions

View File

@ -363,11 +363,20 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
ifItems.removeAt(event.index);
selectedFunctions.remove(event.key);
emit(state.copyWith(ifItems: ifItems, selectedFunctions: selectedFunctions));
if (ifItems.isEmpty && state.thenItems.isEmpty) {
emit(state.copyWith(
ifItems: ifItems,
selectedFunctions: selectedFunctions,
isAutomation: false,
isTabToRun: false));
} else {
emit(state.copyWith(ifItems: ifItems, selectedFunctions: selectedFunctions));
}
}
}
FutureOr<void> _changeOperatorOperator(ChangeAutomationOperator event, Emitter<RoutineState> emit) {
FutureOr<void> _changeOperatorOperator(
ChangeAutomationOperator event, Emitter<RoutineState> emit) {
emit(state.copyWith(
selectedAutomationOperator: event.operator,
));
@ -396,7 +405,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
selectedIcon: null,
isTabToRun: false,
isAutomation: false,
selectedAutomationOperator: 'AND',
selectedAutomationOperator: 'or',
effectiveTime: null,
routineName: null,
);

View File

@ -27,7 +27,7 @@ class IfContainer extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('IF', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
if (state.isAutomation)
if (state.isAutomation && state.ifItems.isNotEmpty)
AutomationOperatorSelector(
selectedOperator: state.selectedAutomationOperator),
],
@ -88,13 +88,16 @@ class IfContainer extends StatelessWidget {
),
);
},
onWillAccept: (data) => data != null,
onAccept: (data) async {
onAcceptWithDetails: (data) async {
final uniqueCustomId = const Uuid().v4();
final mutableData = Map<String, dynamic>.from(data);
final mutableData = Map<String, dynamic>.from(data.data);
mutableData['uniqueCustomId'] = uniqueCustomId;
if (state.isAutomation && mutableData['deviceId'] == 'tab_to_run') {
return;
}
if (!state.isTabToRun) {
if (mutableData['deviceId'] == 'tab_to_run') {
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, true));
@ -134,7 +137,7 @@ class AutomationOperatorSelector extends StatelessWidget {
children: [
TextButton(
style: TextButton.styleFrom(
backgroundColor: selectedOperator == 'or'
backgroundColor: selectedOperator.toLowerCase() == 'or'
? ColorsManager.dialogBlueTitle
: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
@ -144,8 +147,9 @@ class AutomationOperatorSelector extends StatelessWidget {
child: Text(
'Any condition is met',
style: context.textTheme.bodyMedium?.copyWith(
color:
selectedOperator == 'or' ? ColorsManager.whiteColors : ColorsManager.blackColor,
color: selectedOperator.toLowerCase() == 'or'
? ColorsManager.whiteColors
: ColorsManager.blackColor,
),
),
onPressed: () {
@ -159,7 +163,7 @@ class AutomationOperatorSelector extends StatelessWidget {
),
TextButton(
style: TextButton.styleFrom(
backgroundColor: selectedOperator == 'and'
backgroundColor: selectedOperator.toLowerCase() == 'and'
? ColorsManager.dialogBlueTitle
: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
@ -169,7 +173,7 @@ class AutomationOperatorSelector extends StatelessWidget {
child: Text(
'All condition is met',
style: context.textTheme.bodyMedium?.copyWith(
color: selectedOperator == 'and'
color: selectedOperator.toLowerCase() == 'and'
? ColorsManager.whiteColors
: ColorsManager.blackColor,
),

View File

@ -75,7 +75,11 @@ class PeriodOptions extends StatelessWidget {
onTap: () {
context.read<EffectPeriodBloc>().add(SetPeriod(value));
},
title: Text(EffectPeriodHelper.formatEnumValue(value)),
title: Text(
EffectPeriodHelper.formatEnumValue(value),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 12),
),
subtitle: Text(
subtitle,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(

View File

@ -128,6 +128,20 @@ class ThenContainer extends StatelessWidget {
return;
}
if (mutableData['type'] == 'tap_to_run' && state.isAutomation) {
context.read<RoutineBloc>().add(AddToThenContainer({
...mutableData,
'imagePath': Assets.loginLogo,
'title': mutableData['name'],
}));
return;
}
if (mutableData['type'] == 'tap_to_run' && !state.isAutomation) {
return;
}
if (mutableData['deviceId'] == 'delay') {
final result = await DelayHelper.showDelayPickerDialog(context, mutableData);
@ -142,7 +156,6 @@ class ThenContainer extends StatelessWidget {
}
final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData);
if (result != null) {
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
} else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) {