import 'package:flutter/material.dart';
import 'package:kasy_kit/core/theme/theme.dart';

/// Row used in settings modal bottom sheets (avatar source, language, etc.).
class SettingsBottomSheetOptionTile extends StatelessWidget {
  const SettingsBottomSheetOptionTile({
    super.key,
    this.icon,
    this.leading,
    required this.label,
    this.color,
    required this.onTap,
    this.trailing,
  });

  final IconData? icon;
  final Widget? leading;
  final String label;
  final Color? color;
  final VoidCallback onTap;
  final Widget? trailing;

  @override
  Widget build(BuildContext context) {
    final Color fg = color ?? context.colors.onSurface;
    final TextStyle? labelStyle =
        context.textTheme.titleMedium?.copyWith(color: fg);
    final Text labelWidget = Text(label, style: labelStyle);
    return InkWell(
      onTap: onTap,
      child: Padding(
        padding: const EdgeInsets.symmetric(
          horizontal: KasySpacing.md,
          vertical: KasySpacing.smd,
        ),
        child: Row(
          children: <Widget>[
            if (leading != null) ...<Widget>[
              leading!,
              const SizedBox(width: KasySpacing.sm),
            ] else if (icon != null) ...<Widget>[
              Icon(icon, size: 22, color: fg),
              const SizedBox(width: KasySpacing.sm),
            ],
            Expanded(child: labelWidget),
            if (trailing != null) trailing!,
          ],
        ),
      ),
    );
  }
}
