import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

enum OrderStatus { created, inProgress, completed, canceled }

Map<OrderStatus, String> orderStatusMap = {
  OrderStatus.created: 'Создан',
  OrderStatus.inProgress: 'В обработке',
  OrderStatus.completed: 'Завершен',
  OrderStatus.canceled: 'Отменен',
};

class HistoryItemCard extends StatelessWidget {
  final String id;
  final String cost;
  final String date;
  final Image image;
  final OrderStatus status;

  const HistoryItemCard({
    super.key,
    required this.id,
    required this.cost,
    required this.date,
    required this.status,
    required this.image,
  });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding:
          const EdgeInsetsDirectional.symmetric(horizontal: 10, vertical: 10),
      child: ConstrainedBox(
        constraints: const BoxConstraints(
          minHeight: 100,
          maxHeight: 200,
          minWidth: 600,
          maxWidth: 800,
        ),
        child: Card(
          elevation: 4,
          color: Theme.of(context).scaffoldBackgroundColor,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(30),
          ),
          child: Padding(
            padding: const EdgeInsetsDirectional.symmetric(horizontal: 20),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    image,
                    const SizedBox(width: 20),
                    Column(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        MarkdownBody(
                          data: '### Заказ **№$id** от $date',
                        ),
                        MarkdownBody(
                            data: 'Статус: **${orderStatusMap[status]}**'),
                        MarkdownBody(data: 'Сумма: **\$$cost**'),
                      ],
                    )
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
