import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/model/device_model.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/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';

class LightInterfaceSwitch extends StatelessWidget {
  const LightInterfaceSwitch({
    super.key,
    required this.light,
  });

  final DeviceModel light;

  @override
  Widget build(BuildContext context) {
    return DefaultContainer(
      boxConstraints: const BoxConstraints(
        maxHeight: 65,
      ),
      margin: const EdgeInsets.symmetric(vertical: 10),
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 15),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            BodyLarge(
              text: light.isOnline ?? false
                  ? StringsManager.on
                  : StringsManager.off,
              style:
                  context.bodyLarge.copyWith(color: Colors.grey, fontSize: 24),
            ),
            Container(
              width: 35,
              decoration: ShapeDecoration(
                color: light.isOnline ?? false
                    ? ColorsManager.primaryColorWithOpacity
                    : Colors.grey,
                shape: const CircleBorder(),
              ),
              child: Center(
                child: IconButton(
                  style: ButtonStyle(
                    padding: MaterialStateProperty.all(
                      const EdgeInsets.all(0),
                    ),
                    iconSize: MaterialStateProperty.all(25),
                  ),
                  onPressed: () {
                    // DevicesCubit.getInstance().toggleLight(light);
                  },
                  icon: const Icon(
                    Icons.power_settings_new,
                    color: Colors.white,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
