import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart'; import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart'; import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart'; import 'package:syncrow_app/features/shared_widgets/custom_switch.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart'; import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/helpers/custom_page_route.dart'; import 'package:syncrow_app/utils/resource_manager/constants.dart'; class RoomPageSwitch extends StatelessWidget { const RoomPageSwitch({ super.key, required this.device, }); final DeviceModel device; @override Widget build(BuildContext context) { return InkWell( onTap: () { switch (device.productType) { case DeviceType.AC: { print("AC"); Navigator.push( context, CustomPageRoute( builder: (context) => BlocProvider( create: (context) => DevicesCubit.getInstance(), child: AcInterface(deviceModel: device), ), ), ); break; } case DeviceType.WallSensor: break; case DeviceType.CeilingSensor: break; case DeviceType.Curtain: break; case DeviceType.Blind: break; case DeviceType.DoorLock: break; case DeviceType.Gateway: break; case DeviceType.LightBulb: Navigator.push( context, CustomPageRoute( builder: (context) => BlocProvider( create: (context) => DevicesCubit.getInstance(), child: LightInterface(light: device), ), ), ); case DeviceType.ThreeGang: Navigator.push( context, CustomPageRoute( builder: (context) => BlocProvider( create: (context) => DevicesCubit.getInstance(), child: ThreeGangInterface( gangSwitch: device, ), ), ), ); break; default: } }, child: DefaultContainer( child: Padding( padding: const EdgeInsets.only(top: 10, right: 10, left: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SvgPicture.asset( device.icon!, fit: BoxFit.contain, ), CustomSwitch( device: device, ), ], ), Expanded( child: FittedBox( fit: BoxFit.scaleDown, child: BodyLarge( text: device.name ?? "", style: context.bodyLarge.copyWith( fontWeight: FontWeight.bold, height: 0, fontSize: 24, color: Colors.grey, ), ), ), ), ], ), ), ), ); } }