import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:lgcc/models/item_model.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:intl/intl.dart';

class DetailItem extends StatefulWidget {
  final ItemModel items;
  const DetailItem({super.key, required this.items});

  @override
  State<DetailItem> createState() => _DetailItemState();
}

class _DetailItemState extends State<DetailItem> {
  @override
  Widget build(BuildContext context) {
    // Check if the conference has a thumbnail, if not use a default image
    // String urlImage;
    // if (widget.items.thumbnail.isEmpty) {
    //   urlImage =
    //       'https://ik.imagekit.io/lgccc/tr:w-1920,f-auto/youtube_thumbnail_46396.png';
    // } else {
    //   urlImage =
    //       'https://actividadeswp.carpa.com/v5/uploads/?path=${widget.items.thumbnail}';
    // }

    final formattedDate = DateFormat.yMMMMEEEEd().format(widget.items.date);

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.items.title),
        centerTitle: true,
        backgroundColor: Color(0xFFE5EBFD),
      ),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  // Image.network(urlImage),
                  const SizedBox(height: 8),
                  Text(
                    widget.items.title,
                    style: const TextStyle(
                      fontSize: 24,
                      fontWeight: FontWeight.bold,
                      height: 1.2,
                    ),
                  ),
                  Text(
                    formattedDate,
                    style: const TextStyle(fontSize: 16, color: Colors.black),
                  ),
                  Text(
                    '${widget.items.place}, ${widget.items.city}, ${widget.items.state}, ${widget.items.country}',
                    style: const TextStyle(fontSize: 16, color: Colors.black),
                  ),
                  Text(
                    'Actividad: ${widget.items.activity}',
                    style: const TextStyle(fontSize: 16, color: Colors.black),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
