import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';

class SpotLight extends StatelessWidget {
  const SpotLight({super.key, required this.value, required this.code, required this.deviceId});

  final bool value;
  final String code;
  final String deviceId;

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            ClipOval(
                child: Container(
              color: ColorsManager.whiteColors,
              child: SvgPicture.asset(
                Assets.lightPulp,
                width: 60,
                height: 60,
                fit: BoxFit.cover,
              ),
            )),
            SizedBox(
              height: 20,
              width: 35,
              child: CupertinoSwitch(
                value: value,
                activeColor: ColorsManager.dialogBlueTitle,
                onChanged: (newValue) {
                  context.read<LivingRoomBloc>().add(
                        LivingRoomControl(
                          deviceId: deviceId,
                          code: code,
                          value: newValue,
                        ),
                      );
                },
              ),
            ),
          ],
        ),
        const Spacer(),
        const Center(
          child: Text(
            'Spotlight',
            style: TextStyle(
              fontWeight: FontWeight.bold,
              fontSize: 14,
            ),
          ),
        ),
      ],
    );
  }
}
