import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sigap/src/features/auth/presentasion/controllers/signup/step/selfie-verification/face_liveness_detection_controller.dart';
import 'package:sigap/src/utils/constants/colors.dart';

class InstructionBanner extends StatelessWidget {
  final FaceLivenessController controller;

  const InstructionBanner({super.key, required this.controller});

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      final direction = controller.getCurrentDirection();
      final isCountdown = controller.status.value == LivenessStatus.countdown;

      // Select appropriate icon based on current status
      IconData iconData;
      Color iconColor;

      switch (controller.status.value) {
        case LivenessStatus.detectingFace:
          iconData = Icons.face;
          iconColor = TColors.primary;
          break;
        case LivenessStatus.checkLeftRotation:
          iconData = Icons.rotate_left;
          iconColor = TColors.primary;
          break;
        case LivenessStatus.checkRightRotation:
          iconData = Icons.rotate_right;
          iconColor = TColors.primary;
          break;
        case LivenessStatus.checkSmile:
          iconData = Icons.sentiment_satisfied_alt;
          iconColor = TColors.primary;
          break;
        case LivenessStatus.checkEyesOpen:
          iconData = Icons.remove_red_eye;
          iconColor = TColors.primary;
          break;
        case LivenessStatus.readyForPhoto:
        case LivenessStatus.countdown:
          iconData = Icons.check_circle;
          iconColor = Colors.green;
          break;
        case LivenessStatus.failed:
          iconData = Icons.error;
          iconColor = Colors.red;
          break;
        default:
          iconData = Icons.info;
          iconColor = TColors.primary;
      }

      return Container(
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
        decoration: BoxDecoration(
          color:
              isCountdown
                  ? Colors.green.withOpacity(0.1)
                  : TColors.primary.withOpacity(0.1),
          borderRadius: BorderRadius.circular(16),
          border: Border.all(
            color:
                isCountdown
                    ? Colors.green.withOpacity(0.3)
                    : TColors.primary.withOpacity(0.3),
            width: 1,
          ),
        ),
        child: Row(
          children: [
            Icon(iconData, color: iconColor, size: 24,
            ),
            SizedBox(width: 12),
            Expanded(
              child: Text(
                direction,
                style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                  color: Colors.black87,
                ),
              ),
            ),
          ],
        ),
      );
    });
  }
}
