import 'package:flutter/material.dart';


class CopyableValueRow extends StatelessWidget {
  final String value;
  final bool canCopy;
  final VoidCallback? onCopy;
  final TextOverflow overflow;
  final bool wrapValueWithFlexible;

  const CopyableValueRow({
    super.key,
    required this.value,
    required this.canCopy,
    required this.onCopy,
    this.overflow = TextOverflow.visible,
    this.wrapValueWithFlexible = false,
  });

  @override
  Widget build(BuildContext context) {
    final valueText = Text(
      value,
      style: Theme.of(context).textTheme.bodyLarge,
      overflow: overflow,
    );

    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        if (wrapValueWithFlexible) Flexible(child: valueText) else valueText,
        IconButton(
          icon: const Icon(Icons.copy),
          iconSize: 18,
          onPressed: canCopy ? onCopy : null,
        ),
      ],
    );
  }
}
