-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #721 from CyBear-Jinni/Changing_grpc
Made vendor login generic
- Loading branch information
Showing
25 changed files
with
284 additions
and
519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import 'dart:collection'; | ||
|
||
import 'package:another_flushbar/flushbar_helper.dart'; | ||
import 'package:cbj_integrations_controller/integrations_controller.dart'; | ||
import 'package:cybearjinni/domain/connections_service.dart'; | ||
import 'package:cybearjinni/presentation/atoms/atoms.dart'; | ||
import 'package:cybearjinni/presentation/molecules/molecules.dart'; | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class AcMolecule extends StatefulWidget { | ||
const AcMolecule(this.entity); | ||
|
||
final GenericAcDE entity; | ||
|
||
@override | ||
State<AcMolecule> createState() => _AcMoleculeState(); | ||
} | ||
|
||
class _AcMoleculeState extends State<AcMolecule> { | ||
Future<void> _turnOnAllAcs() async { | ||
FlushbarHelper.createLoading( | ||
message: 'Turning_On_ac'.tr(), | ||
linearProgressIndicator: const LinearProgressIndicator(), | ||
).show(context); | ||
|
||
setEntityState(EntityActions.on); | ||
// IDeviceRepository.instance.moveUpStateDevices(devicesId: blindsIdToTurnUp); | ||
} | ||
|
||
void setEntityState(EntityActions action) { | ||
final VendorsAndServices? vendor = | ||
widget.entity.cbjDeviceVendor.vendorsAndServices; | ||
if (vendor == null) { | ||
return; | ||
} | ||
final HashMap<VendorsAndServices, HashSet<String>> uniqueIdByVendor = | ||
HashMap(); | ||
uniqueIdByVendor.addEntries( | ||
[ | ||
MapEntry( | ||
vendor, | ||
HashSet<String>() | ||
..addAll([widget.entity.deviceCbjUniqueId.getOrCrash()]), | ||
), | ||
], | ||
); | ||
|
||
ConnectionsService.instance.setEntityState( | ||
ActionObject( | ||
uniqueIdByVendor: uniqueIdByVendor, | ||
property: EntityProperties.acSwitchState, | ||
actionType: action, | ||
), | ||
); | ||
} | ||
|
||
Future<void> _turnOffAllAcs() async { | ||
FlushbarHelper.createLoading( | ||
message: 'Turning_Off_ac'.tr(), | ||
linearProgressIndicator: const LinearProgressIndicator(), | ||
).show(context); | ||
|
||
setEntityState(EntityActions.off); | ||
} | ||
|
||
void _onChange(bool value) { | ||
if (value) { | ||
_turnOnAllAcs(); | ||
} else { | ||
_turnOffAllAcs(); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return DeviceNameRow( | ||
widget.entity.cbjEntityName.getOrCrash()!, | ||
SwitchAtom( | ||
variant: SwitchVariant.ac, | ||
onToggle: _onChange, | ||
action: widget.entity.acSwitchState.action!, | ||
state: widget.entity.entityStateGRPC.state, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.