import 'package:flutter/material.dart';
import 'package:remever/common/functions.dart';
import 'package:remever/common/resources.dart';
import 'package:remever/common/widgets/typography.dart';
import 'package:remever/common/widgets/wspace.dart';
import 'package:remever/components/extensions/context.dart';
import 'package:remever/gen/assets.gen.dart';
import 'package:remever/screens/dialogs/alert_dialog.dart';
import 'package:remever/screens/dialogs/dialog_header.dart';

class TagsDialog extends StatelessWidget {
  const TagsDialog({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(children: <Widget>[_header(context), _body(context)]);
  }

  /// Тело диалога
  Widget _body(BuildContext context) {
    return Expanded(
      child: Padding(
        padding: const EdgeInsets.all(16).r,
        child: Wrap(
          runSpacing: 8.r,
          spacing: 8.r,
          children: List<Widget>.generate(11, (int index) {
            return GestureDetector(
              onTap: () {},
              child: Container(
                height: 30,
                decoration: BoxDecoration(
                  borderRadius: const BorderRadius.all(Radius.circular(6)).r,
                  color: const Color(0xFFFFE4E6),
                ),
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      AppTypography(
                        'tag $index',
                        type: Regular14px(),
                        height: 0.95,
                        color: AppColors.danger,
                      ),
                      const WSpace(8),
                      Center(
                        child: Icon(
                          Icons.close,
                          size: 14.r,
                          color: AppColors.danger,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            );
          }),
        ),
      ),
    );
  }

  /// Шапка
  Widget _header(BuildContext context) {
    return DialogHeader(
      paddingSize: 16,
      title: 'Тэги',
      action: GestureDetector(
        onTap: () {
          showCuperModalBottomSheet(
            context: context,
            height: 282.h,
            builder:
                (BuildContext context) => const AlertInfoDialog(
                  title: 'Удалить все тэги?\nЭто действие необратимо',
                  acceptTitle: 'Да, удалить все',
                  declineTitle: 'Нет, оставьте',
                ),
          );
        },
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            SizedBox.square(
              dimension: 24.r,
              child: Assets.icons.typeTrash.image(color: AppColors.danger),
            ),
            const WSpace(4),
            AppTypography(
              'Удалить все',
              type: Medium16px(),
              color: AppColors.danger,
            ),
          ],
        ),
      ),
    );
  }
}
