import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';

class DevicesDefaultSwitch extends StatelessWidget {
  const DevicesDefaultSwitch(
      {super.key,
      required this.switchValue,
      required this.action,
      required this.on,
      required this.off,
      this.secondAction});

  final bool switchValue;
  final String on;
  final String off;
  final Function action;
  final Function? secondAction;

  @override
  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
        Expanded(
          child: InkWell(
            onTap: () {
              action();
            },
            child: Container(
              height: 60,
              decoration: BoxDecoration(
                color: switchValue
                    ? ColorsManager.switchButton.withOpacity(0.6)
                    : Colors.white,
                borderRadius: const BorderRadius.only(
                  topLeft: Radius.circular(15),
                  bottomLeft: Radius.circular(15),
                ),
              ),
              child: Center(
                child: BodyMedium(
                  fontSize: 14,
                  text: on,
                  fontColor: switchValue ? Colors.white : null,
                  fontWeight: FontWeight.w700,
                ),
              ),
            ),
          ),
        ),
        Expanded(
          child: InkWell(
            onTap: () {
              if (secondAction != null) {
                secondAction!();
              } else {
                action();
              }
            },
            child: Container(
              height: 60,
              decoration: BoxDecoration(
                color: switchValue
                    ? Colors.white
                    : ColorsManager.switchButton.withOpacity(0.6),
                borderRadius: const BorderRadius.only(
                  topRight: Radius.circular(15),
                  bottomRight: Radius.circular(15),
                ),
              ),
              child: Center(
                child: BodyMedium(
                  fontSize: 14,
                  text: off,
                  fontColor: switchValue ? null : Colors.white,
                  fontWeight: FontWeight.w700,
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}
