import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';

class ProviderDetailsCard extends StatelessWidget {
  final String providerImageUrl;
  final String providerName;
  final String providerLocation;
  final String providerRatings;
  final Function() onCardTapped;

  const ProviderDetailsCard({
    Key? key,
    required this.providerImageUrl,
    required this.providerName,
    required this.providerRatings,
    required this.providerLocation,
    required this.onCardTapped,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: const EdgeInsets.only(
          bottom: 10,
          left: 21,
          right: 21,
        ),
        child: Row(
          children: [
            Image.asset(
              providerImageUrl,
              width: 80,
              height: 85,
              fit: BoxFit.cover,
            ),
            12.width,
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Expanded(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          mainAxisAlignment: MainAxisAlignment.start,
                          children: [
                            providerName.toText(fontSize: 16, isBold: true),
                            Row(
                              children: [
                                LocaleKeys.location.tr().toText(color: MyColors.lightTextColor, fontSize: 12),
                                2.width,
                                ":$providerLocation".toText(fontSize: 12),
                              ],
                            ),
                          ],
                        ),
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          providerRatings.toText(
                            isUnderLine: true,
                            isBold: true,
                            fontSize: 12,
                          ),
                          2.width,
                          MyAssets.starIcon.buildSvg(width: 12),
                        ],
                      ),
                    ],
                  ),
                  8.height,
                  Row(
                    children: [
                      Expanded(
                        child: Column(
                          children: [
                            Row(
                              children: [
                                MyAssets.maintenanceIcon.buildSvg(),
                                8.width,
                                LocaleKeys.maintenance.tr().toText(
                                      fontSize: 14,
                                      isBold: true,
                                    ),
                              ],
                            ),
                            Row(
                              children: [
                                MyAssets.modificationsIcon.buildSvg(),
                                8.width,
                                LocaleKeys.accessories_modifications.tr().toText(
                                      fontSize: 14,
                                      isBold: true,
                                    ),
                              ],
                            )
                          ],
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ).onPress(onCardTapped).toWhiteContainer(width: double.infinity, allPading: 12));
  }
}
