This commit is contained in:
Faris Armoush
2025-04-13 16:18:49 +03:00
parent 9472390284
commit 408e78962c
2 changed files with 43 additions and 42 deletions

View File

@ -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'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
class GarageList extends StatelessWidget { class GarageList extends StatelessWidget {
const GarageList( const GarageList({super.key, required this.garageList, required this.allSwitches});
{super.key, required this.garageList, required this.allSwitches});
final List<GroupGarageModel> garageList; final List<GroupGarageModel> garageList;
final bool allSwitches; final bool allSwitches;
@ -23,43 +22,42 @@ class GarageList extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const SizedBox(height: 10), const SizedBox(height: 10),
const BodySmall(text: 'All Lights'), const BodySmall(text: 'All Garages'),
const SizedBox(height: 5), const SizedBox(height: 5),
DevicesDefaultSwitch( DevicesDefaultSwitch(
off: 'OFF', off: 'Close',
on: 'ON', on: 'Open',
switchValue: allSwitches, switchValue: allSwitches,
action: () { action: () => BlocProvider.of<GarageDoorBloc>(context).add(
BlocProvider.of<GarageDoorBloc>(context) GroupAllOnEvent(),
.add(GroupAllOnEvent()); ),
}, secondAction: () => BlocProvider.of<GarageDoorBloc>(context).add(
secondAction: () { GroupAllOffEvent(),
BlocProvider.of<GarageDoorBloc>(context) ),
.add(GroupAllOffEvent());
},
), ),
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(0), padding: EdgeInsetsDirectional.zero,
itemCount: garageList.length, itemCount: garageList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final garageDoor = garageList[index];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: 10), const SizedBox(height: 10),
BodySmall(text: garageList[index].deviceName), BodySmall(text: garageDoor.deviceName),
const SizedBox(height: 5), const SizedBox(height: 5),
DevicesDefaultSwitch( DevicesDefaultSwitch(
off: 'OFF', off: 'Close',
on: 'ON', on: 'Open',
switchValue: garageList[index].firstSwitch, switchValue: garageDoor.firstSwitch,
action: () { action: () => BlocProvider.of<GarageDoorBloc>(context).add(
BlocProvider.of<GarageDoorBloc>(context).add( ChangeFirstWizardSwitchStatusEvent(
ChangeFirstWizardSwitchStatusEvent( value: garageDoor.firstSwitch,
value: garageList[index].firstSwitch, deviceId: garageDoor.deviceId,
deviceId: garageList[index].deviceId)); ),
}, ),
), ),
], ],
); );

View File

@ -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'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
class WHList extends StatelessWidget { 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<GroupWHModel> whList; final List<GroupWHModel> whList;
final bool allSwitches; final bool allSwitches;
@ -22,43 +26,42 @@ class WHList extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const SizedBox(height: 10), const SizedBox(height: 10),
const BodySmall(text: 'All Lights'), const BodySmall(text: 'All Water Heaters'),
const SizedBox(height: 5), const SizedBox(height: 5),
DevicesDefaultSwitch( DevicesDefaultSwitch(
off: 'OFF', off: 'OFF',
on: 'ON', on: 'ON',
switchValue: allSwitches, switchValue: allSwitches,
action: () { action: () => context.read<WaterHeaterBloc>().add(
BlocProvider.of<WaterHeaterBloc>(context) GroupAllOnEvent(),
.add(GroupAllOnEvent()); ),
}, secondAction: () => context.read<WaterHeaterBloc>().add(
secondAction: () { GroupAllOffEvent(),
BlocProvider.of<WaterHeaterBloc>(context) ),
.add(GroupAllOffEvent());
},
), ),
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(0), padding: EdgeInsetsDirectional.zero,
itemCount: whList.length, itemCount: whList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final waterHeater = whList[index];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: 10), const SizedBox(height: 10),
BodySmall(text: whList[index].deviceName), BodySmall(text: waterHeater.deviceName),
const SizedBox(height: 5), const SizedBox(height: 5),
DevicesDefaultSwitch( DevicesDefaultSwitch(
off: 'OFF', off: 'OFF',
on: 'ON', on: 'ON',
switchValue: whList[index].firstSwitch, switchValue: waterHeater.firstSwitch,
action: () { action: () => context.read<WaterHeaterBloc>().add(
BlocProvider.of<WaterHeaterBloc>(context).add(
ChangeFirstWizardSwitchStatusEvent( ChangeFirstWizardSwitchStatusEvent(
value: whList[index].firstSwitch, value: waterHeater.firstSwitch,
deviceId: whList[index].deviceId)); deviceId: waterHeater.deviceId,
}, ),
),
), ),
], ],
); );