// ignore_for_file: deprecated_member_use_from_same_package

import 'package:flutter/material.dart';
import 'package:hoshan/core/gen/assets.gen.dart';
import 'package:hoshan/ui/theme/text.dart';

class HintTooltip extends StatelessWidget {
  final String hint;
  final double? size;
  final Widget? child;
  final Color? iconColor;
  const HintTooltip(
      {super.key, required this.hint, this.child, this.size, this.iconColor});

  @override
  Widget build(BuildContext context) {
    final color = iconColor ?? Theme.of(context).colorScheme.primary;
    return Tooltip(
      padding: const EdgeInsets.all(8),
      decoration: BoxDecoration(
          color: Theme.of(context).colorScheme.surface,
          borderRadius: BorderRadius.circular(8)),
      triggerMode: TooltipTriggerMode.tap,
      enableTapToDismiss: true,
      enableFeedback: true,
      preferBelow: true,
      showDuration: const Duration(minutes: 2),
      richMessage: WidgetSpan(
        alignment: PlaceholderAlignment.baseline,
        baseline: TextBaseline.alphabetic,
        child: Container(
          padding: const EdgeInsets.all(10),
          constraints: const BoxConstraints(maxWidth: 300),
          child: Text(
            hint,
            style: AppTextStyles.body4
                .copyWith(color: Theme.of(context).colorScheme.onSurface),
            textDirection: TextDirection.rtl,
            textAlign: TextAlign.justify,
          ),
        ),
      ),
      child: child ??
          Assets.icon.outline.warning2
              .svg(width: size, height: size, color: color),
    );
  }
}
