import 'dart:developer';

import 'package:animated_rating_stars/animated_rating_stars.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:taafee_mobile/common/extensions/widget_extension.dart';
import 'package:taafee_mobile/common/widgets/button.dart';
import 'package:taafee_mobile/common/widgets/text.dart';
import 'package:taafee_mobile/core/routing/routing_manager.dart';
import 'package:taafee_mobile/features/card/business_logic_layer/card_controller.dart';
import 'package:taafee_mobile/features/card/data_layer/model/card_model.dart';
import 'package:taafee_mobile/features/card/presentation_layer/widgets/star.dart';
import 'package:taafee_mobile/features/card/presentation_layer/widgets/view_ratings.dart';

import '../../../../common/const/const.dart';
import '../../../../common/widgets/textfiled.dart';

class RateWidget extends StatelessWidget {
  final CardModel cardModel;
  final CardController cardController = Get.find<CardController>();
  RateWidget({super.key, required this.cardModel});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: Get.width * .89,
      height: 200,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const RegularTextWidget("Rates"),
              Container(
                margin: const EdgeInsets.only(top: 5),
                alignment: Alignment.center,
                width: 100,
                height: 25,
                decoration: BoxDecoration(
                  color: AppColors.primeColor,
                  borderRadius: BorderRadius.circular(25),
                ),
                child: RegularTextWidget(
                  "Rate Now".tr,
                  color: Colors.white,
                ),
              ).onTap(() {
                cardController.rateModel.cardId = cardModel.id;
                RoutingManager.to(RouteName.reviewForm);
              }),
            ],
          ).paddingSymmetric(horizontal: 20, vertical: 5),
          ViewRatingsWidget(
            cardModel: cardModel,
          ),
        ],
      ),
    ).onTap(() async {
      cardController.getFeedback(cardModel.id);
      RoutingManager.to(RouteName.feedback);
      log("message");
    });
  }
}
