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

import '../home_captain_controller.dart';
import '../order_request_controller.dart';

class ConnectWidget extends StatelessWidget {
  const ConnectWidget({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    final OrderRequestController orderRequestController =
        Get.put(OrderRequestController());
    return Center(
      child: GetBuilder<HomeCaptainController>(
        builder: (homeCaptainController) =>
            int.parse(orderRequestController.countRefuse) > 3
                ? CupertinoButton(
                    child: Text('You are Stopped'.tr),
                    onPressed: () {},
                    color: CupertinoColors.destructiveRed,
                  )
                : CupertinoButton(
                    child: Text(homeCaptainController.isActive
                        ? 'Connected'.tr
                        : 'Not Connected'.tr),
                    onPressed: homeCaptainController.onButtonSelected,
                    color: homeCaptainController.isActive
                        ? CupertinoColors.activeGreen
                        : CupertinoColors.inactiveGray,
                  ),
      ),
    );
  }
}
