mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +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 {
|
||||
final scaledValue = totalMinutes ~/ 6;
|
||||
await DevicesManagementApi().deviceControl(
|
||||
deviceId,
|
||||
Status(code: 'countdown_time', value: scaledValue),
|
||||
await _runDebounce(
|
||||
isBatch: false,
|
||||
deviceId: deviceId,
|
||||
code: 'countdown_time',
|
||||
value: scaledValue,
|
||||
oldValue: scaledValue,
|
||||
emit: emit,
|
||||
);
|
||||
_startCountdownTimer(emit);
|
||||
emit(currentState.copyWith(isTimerActive: timerActive));
|
||||
@ -342,9 +346,13 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
emit(AcsFailedState(error: e.toString()));
|
||||
}
|
||||
} else {
|
||||
await DevicesManagementApi().deviceControl(
|
||||
deviceId,
|
||||
Status(code: 'countdown_time', value: 0),
|
||||
await _runDebounce(
|
||||
isBatch: false,
|
||||
deviceId: deviceId,
|
||||
code: 'countdown_time',
|
||||
value: 0,
|
||||
oldValue: 0,
|
||||
emit: emit,
|
||||
);
|
||||
_countdownTimer?.cancel();
|
||||
scheduledHours = 0;
|
||||
|
@ -62,9 +62,6 @@ class ToggleWidget extends StatelessWidget {
|
||||
)),
|
||||
if (showToggle)
|
||||
Container(
|
||||
height: 20,
|
||||
width: 35,
|
||||
padding: const EdgeInsets.only(right: 16, top: 10),
|
||||
child: CupertinoSwitch(
|
||||
value: value,
|
||||
activeColor: ColorsManager.dialogBlueTitle,
|
||||
|
Reference in New Issue
Block a user