import 'package:didvan/config/design_config.dart';
import 'package:didvan/constants/app_icons.dart';
import 'package:didvan/models/tag.dart';
import 'package:didvan/routes/routes.dart';
import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:didvan/views/widgets/ink_wrapper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:persian_number_utility/persian_number_utility.dart';

class InfographyTag extends StatelessWidget {
  final Tag tag;
  final void Function(int id, bool value, bool shouldUpdate) onMarkChanged;

  const InfographyTag({
    Key? key,
    required this.tag,
    required this.onMarkChanged,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWrapper(
      borderRadius: DesignConfig.lowBorderRadius,
      onPressed: () =>
          Navigator.of(context).pushNamed(Routes.hashtag, arguments: {
        'tag': tag,
        'onMarkChanged': (int id, bool value) => onMarkChanged(id, value, true),
        'type': 'infography'
      }),
      child: Container(
        padding: const EdgeInsets.symmetric(
          vertical: 4,
          horizontal: 4,
        ),
        decoration: BoxDecoration(
          borderRadius: DesignConfig.mediumBorderRadius,
          border: Border.all(
            color:  const Color.fromARGB(255, 184, 184, 184),
          ),
        ),
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            const Icon(
              DidvanIcons.hashtag_regular,
              color:  Color.fromARGB(255, 102, 102, 102),
              size: 16,
            ),
            Padding(
              padding: const EdgeInsets.all(2.0),
              child: DidvanText(
                tag.label,
                color: const Color.fromARGB(255, 102, 102, 102),
                style: Theme.of(context).textTheme.labelMedium,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

class InfoCat extends StatelessWidget {
  final String category;
  final String createdAt;

  const InfoCat({
    Key? key,
    required this.category,
    required this.createdAt,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        const SizedBox(width: 15,),
        SvgPicture.asset('lib/assets/icons/calendar.svg',color: Colors.white,height: 22,),
        const SizedBox(width: 5,),
        // DidvanText(
        //   category,
        //   style: Theme.of(context).textTheme.bodySmall,
        // ),
        DidvanText(
          DateTime.parse(createdAt).toPersianDateStr(),
          style: const TextStyle(color: Colors.white),
        ),
      ],
    );
  }
}
