import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:taafee_mobile/common/const/const.dart';
import 'package:taafee_mobile/common/extensions/widget_extension.dart';
import 'package:taafee_mobile/features/card/data_layer/model/card_model.dart';
import 'package:taafee_mobile/features/card/presentation_layer/widgets/card_service.dart';
import 'package:taafee_mobile/features/home/business_logic_layer/home_controller.dart';

import '../../../../core/routing/routing_manager.dart';
import 'card_header.dart';
import 'card_information.dart';
import 'card_location.dart';

class MyCardWidget extends StatelessWidget {
  final CardModel cardModel;
  final bool? isShowEditIcon;
  MyCardWidget(this.cardModel, {super.key, this.isShowEditIcon = false});
  final HomeController homeController = Get.find<HomeController>();
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: Responsive.isTablet() ? 2 : 20, vertical: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      width: Get.width,
      child: SizedBox(
        child: Column(
          children: [
            Column(
              children: [
                CardHeaderWidget(
                  isShowEditIcon: isShowEditIcon!,
                  cardModel: cardModel,
                ),
                const SizedBox(
                  height: 6,
                ),
                Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(4),
                  ),
                  width: Get.width,
                  height: Responsive.isTablet() ? 120 : 96,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      CardInformation(
                        cardModel: cardModel,
                      ).paddingOnly(
                        left: homeController.isArabic.value ? 0 : 4,
                        right: homeController.isArabic.value ? 4 : 0,
                      ),
                      CardLocationWidget(
                        cardModel: cardModel,
                      ),
                      const SizedBox(
                        height: 6,
                      ),
                      CardServiceWidget(cardModel: cardModel).paddingOnly(
                        left: homeController.isArabic.value ? 0 : 8,
                        right: homeController.isArabic.value ? 8 : 0,
                      ),
                    ],
                  ),
                ),
              ],
            ).onTap(() {
              homeController.setCardAppointment(cardModel.id);
              RoutingManager.to(RouteName.cardDetails, arguments: cardModel);
            }),
          ],
        ),
      ),
    );
  }
}
