import 'package:betting/commom/utils/color_utils.dart';
import 'package:betting/commom/utils/textstyle.dart';
import 'package:betting/view/mobile/favourites_view/matches_view/matches_controller.dart';
import 'package:betting/view/mobile/favourites_view/teams/team_info_view/videos_view/video_controller.dart';
import 'package:betting/view/mobile/home_page/home_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class VideosView extends StatelessWidget {
  VideosView({Key? key}) : super(key: key);

  final matchesController = Get.put(MatchesController());
  final videoTeamController = Get.put(VideoTeamController());

  @override
  Widget build(BuildContext context) {
    return RefreshIndicator(
      onRefresh: () async{
        Get.find<HomeController>().onRefreshPressed();
      },
      color: ColorUtils.PRIMARY_COLOR,
      child: ListView.builder(
        itemCount: videoTeamController.videos.length,
        itemBuilder: (context, index) {
          return Container(
            padding: const EdgeInsets.all(8),
            width: Get.width,
            height: 100.h,
            margin: const EdgeInsets.only(top: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                SizedBox(
                  width: 160,
                  child: Stack(
                    children: [
                      SizedBox(
                        height: double.infinity,
                        child: ClipRRect(
                          borderRadius:
                          const BorderRadius.all(Radius.circular(8)),
                          child: Image.network(videoTeamController.videos[index]['image'],
                          fit: BoxFit.cover),
                        ),
                      ),
                      Column(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Container(
                            margin: const EdgeInsets.only(top: 10, right: 10),
                            alignment: Alignment.topRight,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              mainAxisAlignment: MainAxisAlignment.end,
                              children: [
                                Container(
                                  padding:
                                  const EdgeInsets.symmetric(horizontal: 8),
                                  decoration: BoxDecoration(
                                    color: Colors.white12,
                                    borderRadius: BorderRadius.circular(8),
                                  ),
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      const Icon(
                                        Icons.play_arrow_rounded,
                                        color: Colors.white,
                                      ),
                                      Text(videoTeamController.videos[index]['time'],
                                        style: TextStyleUtils
                                            .sizeText12Weight500()!
                                            .copyWith(color: Colors.white),
                                      ),
                                    ],
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Container(
                            width: double.infinity,
                            padding: const EdgeInsets.all(10),
                            alignment: Alignment.bottomCenter,
                            child: Text(videoTeamController.videos[index]['text'],
                                style: TextStyleUtils.sizeText13Weight500()!
                                    .copyWith(color: Colors.white),
                                maxLines: 3,
                                softWrap: true,
                                overflow: TextOverflow.ellipsis,
                                textAlign: TextAlign.start),
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
                const SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(videoTeamController.videos[index]['title'],
                          textAlign: TextAlign.left,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyleUtils.sizeText14Weight500()
                              ?.copyWith(
                              height: 1.3, color: Colors.white),
                          maxLines: 3),
                      const SizedBox(
                        height: 10,
                      ),
                      Text(videoTeamController.videos[index]['createdAt'],
                        style: TextStyleUtils.sizeText10Weight400()
                            ?.copyWith(color: Colors.white60),
                        textAlign: TextAlign.end,),
                    ],
                  ),
                ),
              ],
            ),
          );
        },),
    );
  }
}
