diff --git a/lib/features/devices/view/widgets/garage_door/garage_list.dart b/lib/features/devices/view/widgets/garage_door/garage_list.dart index 4ddef1b..8d5256d 100644 --- a/lib/features/devices/view/widgets/garage_door/garage_list.dart +++ b/lib/features/devices/view/widgets/garage_door/garage_list.dart @@ -8,8 +8,7 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart' import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; class GarageList extends StatelessWidget { - const GarageList( - {super.key, required this.garageList, required this.allSwitches}); + const GarageList({super.key, required this.garageList, required this.allSwitches}); final List garageList; final bool allSwitches; @@ -23,43 +22,42 @@ class GarageList extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const SizedBox(height: 10), - const BodySmall(text: 'All Lights'), + const BodySmall(text: 'All Garages'), const SizedBox(height: 5), DevicesDefaultSwitch( - off: 'OFF', - on: 'ON', + off: 'Close', + on: 'Open', switchValue: allSwitches, - action: () { - BlocProvider.of(context) - .add(GroupAllOnEvent()); - }, - secondAction: () { - BlocProvider.of(context) - .add(GroupAllOffEvent()); - }, + action: () => BlocProvider.of(context).add( + GroupAllOnEvent(), + ), + secondAction: () => BlocProvider.of(context).add( + GroupAllOffEvent(), + ), ), ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - padding: const EdgeInsets.all(0), + padding: EdgeInsetsDirectional.zero, itemCount: garageList.length, itemBuilder: (context, index) { + final garageDoor = garageList[index]; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), - BodySmall(text: garageList[index].deviceName), + BodySmall(text: garageDoor.deviceName), const SizedBox(height: 5), DevicesDefaultSwitch( - off: 'OFF', - on: 'ON', - switchValue: garageList[index].firstSwitch, - action: () { - BlocProvider.of(context).add( - ChangeFirstWizardSwitchStatusEvent( - value: garageList[index].firstSwitch, - deviceId: garageList[index].deviceId)); - }, + off: 'Close', + on: 'Open', + switchValue: garageDoor.firstSwitch, + action: () => BlocProvider.of(context).add( + ChangeFirstWizardSwitchStatusEvent( + value: garageDoor.firstSwitch, + deviceId: garageDoor.deviceId, + ), + ), ), ], ); diff --git a/lib/features/devices/view/widgets/water_heater/wh_list.dart b/lib/features/devices/view/widgets/water_heater/wh_list.dart index ebc2ddd..a3f672d 100644 --- a/lib/features/devices/view/widgets/water_heater/wh_list.dart +++ b/lib/features/devices/view/widgets/water_heater/wh_list.dart @@ -8,7 +8,11 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart' import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; class WHList extends StatelessWidget { - const WHList({super.key, required this.whList, required this.allSwitches}); + const WHList({ + required this.whList, + required this.allSwitches, + super.key, + }); final List whList; final bool allSwitches; @@ -22,43 +26,42 @@ class WHList extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const SizedBox(height: 10), - const BodySmall(text: 'All Lights'), + const BodySmall(text: 'All Water Heaters'), const SizedBox(height: 5), DevicesDefaultSwitch( off: 'OFF', on: 'ON', switchValue: allSwitches, - action: () { - BlocProvider.of(context) - .add(GroupAllOnEvent()); - }, - secondAction: () { - BlocProvider.of(context) - .add(GroupAllOffEvent()); - }, + action: () => context.read().add( + GroupAllOnEvent(), + ), + secondAction: () => context.read().add( + GroupAllOffEvent(), + ), ), ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - padding: const EdgeInsets.all(0), + padding: EdgeInsetsDirectional.zero, itemCount: whList.length, itemBuilder: (context, index) { + final waterHeater = whList[index]; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), - BodySmall(text: whList[index].deviceName), + BodySmall(text: waterHeater.deviceName), const SizedBox(height: 5), DevicesDefaultSwitch( off: 'OFF', on: 'ON', - switchValue: whList[index].firstSwitch, - action: () { - BlocProvider.of(context).add( + switchValue: waterHeater.firstSwitch, + action: () => context.read().add( ChangeFirstWizardSwitchStatusEvent( - value: whList[index].firstSwitch, - deviceId: whList[index].deviceId)); - }, + value: waterHeater.firstSwitch, + deviceId: waterHeater.deviceId, + ), + ), ), ], );