mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-23 11:27:54 +00:00
Update device control logic for three gang interface
Refactor onTap functions in ThreeGangInterfaceBody to control all three switches simultaneously based on the user interaction. Split the logic for turning on and off the switches into separate functions for better readability and maintenance.
This commit is contained in:
@@ -117,7 +117,32 @@ class ThreeGangInterfaceBody extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
DevicesCubit.getInstance().deviceControl(
|
||||
DeviceControlModel(
|
||||
deviceId: device.id,
|
||||
code: 'switch_1',
|
||||
value: true,
|
||||
),
|
||||
device.id!,
|
||||
);
|
||||
DevicesCubit.getInstance().deviceControl(
|
||||
DeviceControlModel(
|
||||
deviceId: device.id,
|
||||
code: 'switch_2',
|
||||
value: true,
|
||||
),
|
||||
device.id!,
|
||||
);
|
||||
DevicesCubit.getInstance().deviceControl(
|
||||
DeviceControlModel(
|
||||
deviceId: device.id,
|
||||
code: 'switch_3',
|
||||
value: true,
|
||||
),
|
||||
device.id!,
|
||||
);
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
@@ -224,7 +249,32 @@ class ThreeGangInterfaceBody extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
DevicesCubit.getInstance().deviceControl(
|
||||
DeviceControlModel(
|
||||
deviceId: device.id,
|
||||
code: 'switch_1',
|
||||
value: false,
|
||||
),
|
||||
device.id!,
|
||||
);
|
||||
DevicesCubit.getInstance().deviceControl(
|
||||
DeviceControlModel(
|
||||
deviceId: device.id,
|
||||
code: 'switch_2',
|
||||
value: false,
|
||||
),
|
||||
device.id!,
|
||||
);
|
||||
DevicesCubit.getInstance().deviceControl(
|
||||
DeviceControlModel(
|
||||
deviceId: device.id,
|
||||
code: 'switch_3',
|
||||
value: false,
|
||||
),
|
||||
device.id!,
|
||||
);
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user