import 'package:flutter/material.dart';
import 'package:food_health/api/dto/food_scan_dto.dart';
import 'package:markdown_widget/widget/markdown.dart';
import 'package:remixicon/remixicon.dart';

class DetailedAnalysis extends StatelessWidget {
  final FoodScanDto detail;

  const DetailedAnalysis({super.key, required this.detail});

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 20),
      padding: EdgeInsets.all(15),
      decoration: BoxDecoration(
        color: Theme.of(context).colorScheme.surface,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Theme.of(context).colorScheme.shadow,
            blurRadius: 10,
            offset: Offset(0, 4),
          ),
        ],
      ),
      child: Column(
        spacing: 10,
        children: [
          Row(
            spacing: 10,
            children: [
              Icon(
                RemixIcons.eye_line,
                color: Theme.of(context).primaryColor,
              ),
              Text(
                "Detailed Analysis",
                style: Theme.of(context).textTheme.titleMedium,
              ),
            ],
          ),
          MarkdownWidget(
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(),
            data: detail.explanation ?? "",
          ),
          Row(
            spacing: 10,
            children: [
              Icon(RemixIcons.menu_2_line),
              Text(
                "Detected Ingredients",
                style: Theme.of(context).textTheme.titleMedium,
              ),
            ],
          ),
          Wrap(
            spacing: 10,
            runSpacing: 10,
            children: detail.ingredientsList!.map((item) {
              return Container(
                padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
                decoration: BoxDecoration(
                  color: Theme.of(context).colorScheme.surfaceContainerLow,
                  borderRadius: BorderRadius.circular(8),
                ),
                child: Text(item, style: Theme.of(context).textTheme.labelMedium),
              );
            }).toList(),
          ),
        ],
      ),
    );
  }
}
