import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../constant/colors.dart';
import 'mydialoug.dart';

class MyCircleContainer extends StatelessWidget {
  final Widget child;
  final Color? backgroundColor;
  final Color? borderColor;

  MyCircleContainer({
    Key? key,
    required this.child,
    this.backgroundColor,
    this.borderColor,
  }) : super(key: key);

  final controller = Get.put(CircleController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder<CircleController>(
        builder: ((controller) => GestureDetector(
              onTap: () {
                controller.changeColor();
                MyDialog().getDialog(
                    'Rejected Orders Count'.tr,
                    'This is the total number of rejected orders per day after accepting the orders'
                        .tr, () {
                  Get.back();
                });
              },
              child: AnimatedContainer(
                onEnd: () {
                  controller.onEnd();
                },
                duration: const Duration(milliseconds: 300),
                width: controller.size,
                height: controller.size,
                decoration: BoxDecoration(
                  shape: BoxShape.circle,
                  color: controller.isAccented ? AppColor.accentColor : (backgroundColor ?? AppColor.secondaryColor),
                  border: Border.all(
                    color: borderColor ?? AppColor.accentColor,
                    width: 1,
                  ),
                ),
                child: Center(child: child),
              ),
            )));
  }
}

class CircleController extends GetxController {
  bool isAccented = false;
  double size = 40;
  void changeColor() {
    isAccented = !isAccented;
    size = 60;
    update();
  }

  void onEnd() {
    size = 40;
    update();
  }
}
