import 'package:chat/configs/app_colors.dart';
import 'package:chat/configs/app_size.dart';
import 'package:flutter/material.dart';

class LinkActionItem extends StatelessWidget {
  final IconData? prefix;
  final String title;
  final String? cover;
  final Widget? trailing;
  final bool? isLink;
  final GestureTapCallback? onTap;

  const LinkActionItem({
    Key? key,
    this.prefix,
    this.cover,
    required this.title,
    this.isLink,
    this.trailing,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        GestureDetector(
          onTap: onTap,
          child: Container(
            color: AppColors.white,
            padding: const EdgeInsets.symmetric(
              vertical: 20,
              horizontal: 16,
            ),
            child: Row(
              children: [
                if (prefix != null)
                  Icon(
                    prefix,
                    color: AppColors.unactive,
                    size: 18,
                  ),
                const SizedBox(width: 8),
                if (cover != null)
                  Image.asset(
                    'assets/user/$cover.png',
                    width: 24,
                    height: 24,
                  ),
                const SizedBox(width: 8),
                Expanded(
                  child: Text(
                    title,
                    style: const TextStyle(
                      fontSize: 15,
                    ),
                  ),
                ),
                if (trailing != null) trailing!,
                if (isLink == true)
                  const Padding(
                    padding: EdgeInsets.only(left: 4),
                    child: Icon(
                      Icons.arrow_forward_ios,
                      color: AppColors.unactive,
                      size: 14,
                    ),
                  ),
              ],
            ),
          ),
        ),
        const Divider(height: AppSize.dividerHeight),
      ],
    );
  }
}
