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

/// A widget that displays a list of quick links in a card.
class SettingsQuickLinks extends StatelessWidget {
  /// Creates a [SettingsQuickLinks].
  const SettingsQuickLinks({super.key});

  @override
  /// Builds the quick links UI.
  Widget build(BuildContext context) {
    final TranslationsClientSettingsProfileEn labels = t.client_settings.profile;

    return SliverPadding(
      padding: const EdgeInsets.all(UiConstants.space5),
      sliver: SliverToBoxAdapter(
        child: Card(
          elevation: 0,
          shape: RoundedRectangleBorder(
            borderRadius: UiConstants.radiusLg,
            side: const BorderSide(color: UiColors.border),
          ),
          color: UiColors.white,
          child: Padding(
            padding: const EdgeInsets.all(UiConstants.space4),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  labels.quick_links,
                  style: UiTypography.footnote1b.textPrimary,
                ),
                const SizedBox(height: UiConstants.space3),
                _QuickLinkItem(
                  icon: UiIcons.nfc,
                  title: labels.clock_in_hubs,
                  onTap: () => Modular.to.pushHubs(),
                ),
                
                _QuickLinkItem(
                  icon: UiIcons.building,
                  title: labels.billing_payments,
                  onTap: () {},
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

/// Internal widget for a single quick link item.
class _QuickLinkItem extends StatelessWidget {
  /// The icon to display.
  final IconData icon;

  /// The title of the link.
  final String title;

  /// Callback when the link is tapped.
  final VoidCallback onTap;

  /// Creates a [_QuickLinkItem].
  const _QuickLinkItem({
    required this.icon,
    required this.title,
    required this.onTap,
  });

  @override
  /// Builds the quick link item UI.
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      borderRadius: UiConstants.radiusMd,
      child: Padding(
        padding: const EdgeInsets.symmetric(
          vertical: UiConstants.space3,
          horizontal: UiConstants.space2,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Row(
              children: <Widget>[
                Icon(icon, size: 20, color: UiColors.iconSecondary),
                const SizedBox(width: UiConstants.space3),
                Text(title, style: UiTypography.footnote1m.textPrimary),
              ],
            ),
            const Icon(
              UiIcons.chevronRight,
              size: 20,
              color: UiColors.iconThird,
            ),
          ],
        ),
      ),
    );
  }
}
