import 'package:betting/commom/utils/textstyle.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_device_type/flutter_device_type.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class ItemTopScore extends StatelessWidget {
  const ItemTopScore({
    Key? key,
    required this.index,
    this.logo,
    required this.playerName,
    required this.clubName,
    required this.goal,
  }) : super(key: key);
  final int index;
  final String? logo;
  final String playerName;
  final String clubName;
  final String goal;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(8),
      decoration: BoxDecoration(
        border: Border.all(width: 0.5, color: Colors.white30),
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular((index == 0) ? 8 : 0),
          topRight: Radius.circular((index == 0) ? 8 : 0),
        ),
      ),
      width: Get.width,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          const SizedBox(
            width: 10,
          ),
          Text(
            '${index + 1}',
            style: TextStyleUtils.sizeText12Weight300()!
                .copyWith(color: Colors.white),
          ),
          const SizedBox(
            width: 25,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              const SizedBox(
                width: 8,
              ),
              CachedNetworkImage(
                imageUrl: 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: 15.w,
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  SizedBox(
                    width: !Device.get().isTablet? 225.w : null,
                    child: Text(playerName,
                      softWrap: false,
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyleUtils.sizeText14Weight400()!
                          .copyWith(color: Colors.white),
                    ),
                  ),
                  SizedBox(height: 5.h,),
                  Text(
                    clubName,
                    style: TextStyleUtils.sizeText12Weight400()!
                        .copyWith(color: Colors.white54),
                  ),
                ],
              ),
            ],
          ),
          const Spacer(),
          Text(
            goal,
            style: TextStyleUtils.sizeText12Weight500()!
                .copyWith(color: Colors.white),
          ),
          const SizedBox(
            width: 10,
          ),
        ],
      ),
    );
  }
}
