import 'package:betting/commom/utils/textstyle.dart';
import 'package:betting/view/mobile/find/list_regions/detail_regions/detail_matches_in_regions/feed_match/highlights_view/highlights_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class HighlightsView extends StatelessWidget {
  HighlightsView({Key? key}) : super(key: key);
  final highlightsController = Get.put(HighlightsController());

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: highlightsController.highlights.length,
      itemBuilder: (context, index) {
        var item = highlightsController.highlights[index];
        var key = item.keys.first;
        var value = item[key];

        return Container(
          width: Get.width,
          padding: EdgeInsets.all(10),
          decoration: BoxDecoration(
              border: Border.all(color: Colors.white60, width: 0.8),
              borderRadius: (highlightsController.highlights.length == 1)
                  ? const BorderRadius.all(Radius.circular(8))
                  : (index == 0)
                      ? const BorderRadius.only(
                          topRight: Radius.circular(8),
                          topLeft: Radius.circular(8))
                      : (index == highlightsController.highlights.length - 1)
                          ? const BorderRadius.only(
                              bottomLeft: Radius.circular(8),
                              bottomRight: Radius.circular(8))
                          : null),
          child: Row(
            children: [
              Container(
                margin: const EdgeInsets.only(right: 8),
                width: Get.width * 0.2,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      key.toString(),
                      style: TextStyleUtils.sizeText12Weight500()!
                          .copyWith(color: Colors.white60),
                    ),
                    (value['situation'] == 'substitution') ? Icon(
                      Icons.change_circle_outlined,
                      color: Colors.white60,
                    ) : (value['situation'] == 'goal')? Icon(
                      Icons.sports_soccer_rounded,
                      color: Colors.white60,
                    ): SizedBox(width: 20,),
                  ],
                ),
              ),
              Expanded(
                child: Text(
                  value['desc'].toString(),
                  softWrap: true,
                  maxLines: 3,
                  style: TextStyleUtils.sizeText12Weight500()!
                      .copyWith(color: Colors.white60),
                ),
              ),
            ],
          ),
        );
      },
    );
  }
}
