mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Merge pull request #141 from SyncrowIOT/fix-timer-toggle-issue
Refactor AC device controls and toggle widget
This commit is contained in:
@ -331,9 +331,13 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final scaledValue = totalMinutes ~/ 6;
|
final scaledValue = totalMinutes ~/ 6;
|
||||||
await DevicesManagementApi().deviceControl(
|
await _runDebounce(
|
||||||
deviceId,
|
isBatch: false,
|
||||||
Status(code: 'countdown_time', value: scaledValue),
|
deviceId: deviceId,
|
||||||
|
code: 'countdown_time',
|
||||||
|
value: scaledValue,
|
||||||
|
oldValue: scaledValue,
|
||||||
|
emit: emit,
|
||||||
);
|
);
|
||||||
_startCountdownTimer(emit);
|
_startCountdownTimer(emit);
|
||||||
emit(currentState.copyWith(isTimerActive: timerActive));
|
emit(currentState.copyWith(isTimerActive: timerActive));
|
||||||
@ -342,9 +346,13 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
emit(AcsFailedState(error: e.toString()));
|
emit(AcsFailedState(error: e.toString()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await DevicesManagementApi().deviceControl(
|
await _runDebounce(
|
||||||
deviceId,
|
isBatch: false,
|
||||||
Status(code: 'countdown_time', value: 0),
|
deviceId: deviceId,
|
||||||
|
code: 'countdown_time',
|
||||||
|
value: 0,
|
||||||
|
oldValue: 0,
|
||||||
|
emit: emit,
|
||||||
);
|
);
|
||||||
_countdownTimer?.cancel();
|
_countdownTimer?.cancel();
|
||||||
scheduledHours = 0;
|
scheduledHours = 0;
|
||||||
|
@ -62,9 +62,6 @@ class ToggleWidget extends StatelessWidget {
|
|||||||
)),
|
)),
|
||||||
if (showToggle)
|
if (showToggle)
|
||||||
Container(
|
Container(
|
||||||
height: 20,
|
|
||||||
width: 35,
|
|
||||||
padding: const EdgeInsets.only(right: 16, top: 10),
|
|
||||||
child: CupertinoSwitch(
|
child: CupertinoSwitch(
|
||||||
value: value,
|
value: value,
|
||||||
activeColor: ColorsManager.dialogBlueTitle,
|
activeColor: ColorsManager.dialogBlueTitle,
|
||||||
|
Reference in New Issue
Block a user