import 'package:betting/commom/utils/textstyle.dart';
import 'package:betting/view/mobile/find/detail_matches_in_regions/feed_match/commentary_view/commentary_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class CommentaryView extends StatelessWidget {
  CommentaryView({Key? key}) : super(key: key);
  final commentaryController = Get.put(CommentaryController());

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

        return Container(
          width: Get.width,
          padding: const EdgeInsets.all(10),
          decoration: BoxDecoration(
              border: Border.all(color: Colors.white60, width: 0.8),
              borderRadius: (commentaryController.highlights.length == 1)
                  ? const BorderRadius.all(Radius.circular(8))
                  : (index == 0)
                      ? const BorderRadius.only(
                          topRight: Radius.circular(8),
                          topLeft: Radius.circular(8))
                      : (index == commentaryController.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),
                ),
              ),
            ],
          ),
        );
      },
    );
  }
}
