import 'package:betting/commom/utils/color_utils.dart';
import 'package:betting/commom/utils/textstyle.dart';
import 'package:betting/data/model/res/matches/matches.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ItemFixtureWidget extends StatelessWidget {
  const ItemFixtureWidget({
    Key? key,
    required this.isFavouriteMatch,
    required this.isNotification,
    required this.funcFavouriteMatch,
    this.match,
  }) : super(key: key);
  final bool isFavouriteMatch;
  final Function funcFavouriteMatch;
  final bool isNotification;

  final Matches? match;

  @override
  Widget build(BuildContext context) {
    return

      Container(
      margin: const EdgeInsets.only(bottom: 8),
      padding: const EdgeInsets.symmetric(horizontal: 8),
      decoration: BoxDecoration(
        color: Colors.grey.withOpacity(0.08),
        borderRadius: const BorderRadius.all(
          Radius.circular(8),
        ),
      ),
      height: 75.h,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            children: [
              SizedBox(
                height: double.infinity,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    (match?.date == null)
                        ? const SizedBox()
                        : Text(
                            '${match?.date}',
                            style: TextStyleUtils.sizeText10Weight500()!
                                .copyWith(color: Colors.white60),
                          ),
                    (match?.date == null)
                        ? const SizedBox()
                        : const SizedBox(
                            height: 16,
                          ),
                    Text(
                      '${match?.time}',
                      style: TextStyleUtils.sizeText10Weight500()!
                          .copyWith(color: Colors.white60),
                    ),
                  ],
                ),
              ),
              const SizedBox(
                width: 10,
              ),
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      CachedNetworkImage(
                        imageUrl: match?.home?.logo ??
                            'https://upload.wikimedia.org/wikipedia/vi/thumb/5/5c/Chelsea_crest.svg/1200px-Chelsea_crest.svg.png',
                        imageBuilder: (context, imageProvider) => Container(
                          decoration: BoxDecoration(
                            image: DecorationImage(
                              image: imageProvider,
                              fit: BoxFit.cover,
                            ),
                          ),
                        ),
                        placeholder: (context, url) =>
                            const CupertinoActivityIndicator(),
                        memCacheHeight: 150,
                        memCacheWidth: 150,
                        errorWidget: (context, url, error) => Image.network(
                          "https://files.lms.xteldev.com/files/n1/static/img",
                        ),
                        width: 25,
                        height: 25,
                      ),
                      SizedBox(
                        width: 10.w,
                      ),
                      Text('${match?.home?.name}',
                          maxLines: 3,
                          softWrap: true,
                          style: TextStyleUtils.sizeText12Weight500()!
                              .copyWith(color: Colors.white54)),
                      SizedBox(
                        width: 5.w,
                      ),
                      Visibility(
                        visible: match!.home!.favourite!,
                        child: Icon(
                          Icons.star_rounded,
                          color: Colors.white54,
                          size: 16.sp,
                        ),
                      ),
                    ],
                  ),
                  const SizedBox(
                    height: 8,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      CachedNetworkImage(
                        imageUrl: match?.away?.logo ??
                            'https://upload.wikimedia.org/wikipedia/vi/thumb/5/5c/Chelsea_crest.svg/1200px-Chelsea_crest.svg.png',
                        imageBuilder: (context, imageProvider) => Container(
                          decoration: BoxDecoration(
                            image: DecorationImage(
                              image: imageProvider,
                              fit: BoxFit.cover,
                            ),
                          ),
                        ),
                        placeholder: (context, url) =>
                            const CupertinoActivityIndicator(),
                        memCacheHeight: 150,
                        memCacheWidth: 150,
                        errorWidget: (context, url, error) => Image.network(
                          "https://files.lms.xteldev.com/files/n1/static/img",
                        ),
                        width: 25,
                        height: 25,
                      ),
                      SizedBox(
                        width: 10.w,
                      ),
                      Text('${match?.away?.name}',
                          maxLines: 3,
                          softWrap: true,
                          style: TextStyleUtils.sizeText12Weight500()!
                              .copyWith(color: Colors.white54)),
                      SizedBox(
                        width: 5.w,
                      ),
                      Visibility(
                        visible: match!.away!.favourite!,
                        child: Icon(
                          Icons.star_rounded,
                          color: Colors.white54,
                          size: 16.sp,
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
          GestureDetector(
            onTap: () => funcFavouriteMatch(),
            child: Container(
              margin: const EdgeInsets.only(right: 8),
              child: Icon(
                isNotification == false ?
                isFavouriteMatch == true
                    ? Icons.star_rounded
                    : Icons.star_border_rounded  :
                isFavouriteMatch == true ?
                Icons.notifications:
                Icons.notifications_off_outlined ,
                color:
                isNotification == false ?
                isFavouriteMatch == true
                    ? ColorUtils.PRIMARY_COLOR
                    : Colors.white :
                ColorUtils.PRIMARY_COLOR,
                size: 22.sp,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
