// Flutter imports:
import 'package:flutter/material.dart';

// Project imports:
import 'package:remever/common/resources.dart';
import 'package:remever/common/widgets/typography.dart';
import 'package:remever/components/extensions/context.dart';

class DialogItem extends StatelessWidget {
  const DialogItem({
    super.key,
    required this.onTap,
    this.child,
    this.title = '',
    this.dimension = 24,
    this.color,
  });

  final VoidCallback? onTap;
  final Widget? child;
  final String title;
  final Color? color;
  final double dimension;

  // Константы для стилей и отступов
  static final double _itemHeight = 52.h;
  static const BoxDecoration _itemDecoration = BoxDecoration(
    border: Border(bottom: BorderSide(color: AppColors.gray, width: 0.5)),
  );
  static final EdgeInsetsGeometry _itemPadding =
      EdgeInsets.symmetric(horizontal: 28).r;
  static final EdgeInsetsGeometry _iconPadding = EdgeInsets.only(right: 8).r;
  static final _regular17Style = Regular17px();

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: _itemHeight,
        decoration: _itemDecoration,
        child: Padding(
          padding: _itemPadding,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[_buildIcon(), _buildTitle()],
          ),
        ),
      ),
    );
  }

  /// Построение иконки
  Widget _buildIcon() {
    return Padding(
      padding: _iconPadding,
      child: SizedBox.square(dimension: dimension.r, child: child),
    );
  }

  /// Построение заголовка
  Widget _buildTitle() {
    return AppTypography(
      title,
      color: color ?? Colors.black,
      type: _regular17Style,
    );
  }
}
