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/models/provider_branches_models/branch_detail_model.dart';
import 'package:mc_common_app/models/services_models/service_model.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';

class ProviderDetailCard extends StatelessWidget {
  final String providerImageUrl;
  final String title;
  final String startedSince;
  final String totalBranches;
  final String description;
  final List<BranchDetailModel> branches;
  final Function() onCardTapped;
  final bool isFromFavoriteList;

  const ProviderDetailCard({
    Key? key,
    required this.providerImageUrl,
    required this.title,
    required this.totalBranches,
    required this.branches,
    required this.description,
    required this.startedSince,
    required this.onCardTapped,
    this.isFromFavoriteList = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      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: [
                        title.toText(fontSize: 16, isBold: true),
                        Row(
                          children: [
                            ("${LocaleKeys.totalBranches.tr()}:").toText(color: MyColors.lightTextColor, fontSize: 12),
                            4.width,
                            totalBranches.toText(fontSize: 12, isBold: true),
                          ],
                        ),
                        if (description.isNotEmpty) ...[
                          Row(
                            children: [
                              ("${LocaleKeys.description.tr()}:").toText(color: MyColors.lightTextColor, fontSize: 12),
                              4.width,
                              description.toText(fontSize: 12, isBold: true),
                            ],
                          ),
                        ],
                        Row(
                          children: [
                            (isFromFavoriteList ? LocaleKeys.addToFavoritesOn.tr() : LocaleKeys.memberSince.tr()).toText(color: MyColors.lightTextColor, fontSize: 12),
                            4.width,
                            startedSince.toText(fontSize: 12, isBold: true),
                          ],
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      ],
    ).onPress(onCardTapped).toWhiteContainer(width: double.infinity, allPading: 12);
  }
}
