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/core/routing/routing_manager.dart';
import 'package:taafee_mobile/features/card/data_layer/model/card_model.dart';
import 'package:taafee_mobile/features/card/presentation_layer/widgets/card_information.dart';

import 'card_header.dart';
import 'card_location.dart';
import 'card_service.dart';

class CardWidget extends StatelessWidget {
  final CardModel cardModel;
  const CardWidget(
    this.cardModel, {
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: Get.width,
      height: 175,
      child: Container(
        margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(4),
        ),
        width: Get.width,
        height: 150,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            CardHeaderWidget(
              cardModel: cardModel,
            ),
            Container(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(4),
              ),
              width: Get.width,
              height: 125,
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  CardInformation(
                    cardModel: cardModel,
                  ).paddingOnly(
                    left: Responsive.isTablet() ? 8 : 4,
                  ),
                  CardLocationWidget(
                    cardModel: cardModel,
                  ),
                  Divider(
                    color: AppColors.dividerColor,
                    thickness: 1,
                  ).paddingSymmetric(horizontal: 18),
                  CardServiceWidget(
                    cardModel: cardModel,
                  ).paddingOnly(
                    left: Responsive.isTablet() ? 8 : 8,
                  ),
                ],
              ),
            ),
          ],
        ).onTap(() {
          RoutingManager.to(RouteName.cardDetails, arguments: cardModel);
        }),
      ),
    );
  }
}
