import 'package:core_localization/core_localization.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

/// A widget that displays quick actions for the client.
class ActionsWidget extends StatelessWidget {
  /// Callback when RAPID is pressed.
  final VoidCallback onRapidPressed;

  /// Callback when Create Order is pressed.
  final VoidCallback onCreateOrderPressed;

  /// Optional subtitle for the section.
  final String? subtitle;

  /// Creates an [ActionsWidget].
  const ActionsWidget({
    super.key,
    required this.onRapidPressed,
    required this.onCreateOrderPressed,
    this.subtitle,
  });

  @override
  Widget build(BuildContext context) {
    // Check if client_home exists in t
    final TranslationsClientHomeActionsEn i18n = t.client_home.actions;

    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Row(
          children: <Widget>[
        /// TODO: FEATURE_NOT_YET_IMPLEMENTED
        // Expanded(
        //   child: _ActionCard(
        //     title: i18n.rapid,
        //     subtitle: i18n.rapid_subtitle,
        //     icon: UiIcons.zap,
        //     color: const Color(0xFFFEF2F2),
        //     borderColor: const Color(0xFFFECACA),
        //     iconBgColor: const Color(0xFFFEE2E2),
        //     iconColor: const Color(0xFFDC2626),
        //     textColor: const Color(0xFF7F1D1D),
        //     subtitleColor: const Color(0xFFB91C1C),
        //     onTap: onRapidPressed,
        //   ),
        // ),
        // const SizedBox(width: UiConstants.space2),
        Expanded(
          child: _ActionCard(
            title: i18n.create_order,
            subtitle: i18n.create_order_subtitle,
            icon: UiIcons.add,
            color: UiColors.white,
            borderColor: UiColors.border,
            iconBgColor: UiColors.primaryForeground,
            iconColor: UiColors.primary,
            textColor: UiColors.textPrimary,
            subtitleColor: UiColors.textSecondary,
            onTap: onCreateOrderPressed,
          ),
        ),
      ],
        ),
      ],
    );
  }
}

class _ActionCard extends StatelessWidget {
  final String title;
  final String subtitle;
  final IconData icon;
  final Color color;
  final Color borderColor;
  final Color iconBgColor;
  final Color iconColor;
  final Color textColor;
  final Color subtitleColor;
  final VoidCallback onTap;

  const _ActionCard({
    required this.title,
    required this.subtitle,
    required this.icon,
    required this.color,
    required this.borderColor,
    required this.iconBgColor,
    required this.iconColor,
    required this.textColor,
    required this.subtitleColor,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.all(UiConstants.space4),
        decoration: BoxDecoration(
          color: color,
          borderRadius: UiConstants.radiusLg,
          border: Border.all(color: borderColor),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              width: 36,
              height: 36,
              decoration: BoxDecoration(
                color: iconBgColor,
                borderRadius: UiConstants.radiusLg,
              ),
              child: Icon(icon, color: iconColor, size: 16),
            ),
            const SizedBox(height: UiConstants.space2),
            Text(
              title,
              style: UiTypography.footnote1b.copyWith(color: textColor),
            ),
            Text(
              subtitle,
              style: UiTypography.footnote2r.copyWith(color: subtitleColor),
            ),
          ],
        ),
      ),
    );
  }
}
