import 'package:flutter/cupertino.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';

class CurtainToggle extends StatelessWidget {
  final bool value;
  final String code;
  final String deviceId;
  final String label;
  final Null Function(dynamic value) onChanged;

  const CurtainToggle({
    super.key,
    required this.value,
    required this.code,
    required this.deviceId,
    required this.label,
    required this.onChanged,
  });

  @override
  Widget build(BuildContext context) {
    return DeviceControlsContainer(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          const SizedBox(
            height: 10,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              ClipOval(
                child: Container(
                  color: ColorsManager.whiteColors,
                  child: SvgPicture.asset(
                    Assets.curtainIcon,
                    width: 60,
                    height: 60,
                    fit: BoxFit.cover,
                  ),
                ),
              ),
              const SizedBox(
                width: 20,
              ),
              SizedBox(
                height: 20,
                width: 35,
                child: CupertinoSwitch(
                  value: value,
                  activeColor: ColorsManager.dialogBlueTitle,
                  onChanged: onChanged,
                ),
              ),
            ],
          ),
          const Spacer(),
          Text(
            label,
            style: const TextStyle(
              fontWeight: FontWeight.bold,
              fontSize: 14,
            ),
          ),
        ],
      ),
    );
  }
}
