import 'package:didvan/config/design_config.dart';
import 'package:didvan/config/theme_data.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: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.lowBorderRadius,
          border: Border.all(
            color: Theme.of(context).colorScheme.focusedBorder,
          ),
        ),
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Icon(
              DidvanIcons.hashtag_regular,
              color: Theme.of(context).colorScheme.focusedBorder,
              size: 16,
            ),
            DidvanText(
              tag.label,
              color: Theme.of(context).colorScheme.focusedBorder,
              style: Theme.of(context).textTheme.labelLarge,
            ),
          ],
        ),
      ),
    );
  }
}

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: [
        DidvanText(
          category,
          style: Theme.of(context).textTheme.bodySmall,
        ),
        DidvanText(
          ' / ${DateTime.parse(createdAt).toPersianDateStr()}',
          style: Theme.of(context).textTheme.bodySmall,
        ),
      ],
    );
  }
}
