import 'package:didvan/constants/app_icons.dart';
import 'package:didvan/models/home_page_content/content.dart';
import 'package:didvan/views/widgets/didvan/card.dart';
import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:didvan/views/widgets/skeleton_image.dart';
import 'package:flutter/material.dart';
import 'package:persian_number_utility/persian_number_utility.dart';

class MainPageNewsItem extends StatelessWidget {
  final MainPageContentType content;
  const MainPageNewsItem({super.key, required this.content});

  @override
  Widget build(BuildContext context) {
    return DidvanCard(
      padding: EdgeInsets.zero,
      child: Column(
        children: [
          SkeletonImage(
            imageUrl: content.image,
            width: double.infinity,
            height: 160,
          ),
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                DidvanText(
                  content.title,
                  style: Theme.of(context).textTheme.bodyLarge,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 4),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Icon(
                        DidvanIcons.calendar_day_light,
                        size: 16,
                      ),
                      DidvanText(
                        DateTime.parse(content.subtitles[0]).toPersianDateStr(),
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: Theme.of(context).textTheme.bodySmall,
                      ),
                    ],
                  ),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
