import 'package:flutter/material.dart';
import 'package:kmobile/features/quick_pay/screens/quick_pay_outside_bank_screen.dart';
import 'package:kmobile/features/quick_pay/screens/quick_pay_within_bank_screen.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
import '../../../l10n/app_localizations.dart';

class QuickPayScreen extends StatefulWidget {
  final String debitAccount;
  const QuickPayScreen({super.key, required this.debitAccount});

  @override
  State<QuickPayScreen> createState() => _QuickPayScreen();
}

class _QuickPayScreen extends State<QuickPayScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          AppLocalizations.of(context).quickPay.replaceAll('\n', ''),
        ),
      ),
      body: Stack(
        children: [
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 16.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                Expanded(
                  child: QuickPayManagementTile(
                    icon: Symbols.input_circle,
                    label: AppLocalizations.of(context).ownBank,
                    subtitle: AppLocalizations.of(context).quickownsubtitle,
                    onTap: () {
                      Navigator.push(
                        context,
                        MaterialPageRoute(
                          builder: (context) => QuickPayWithinBankScreen(
                            debitAccount: widget.debitAccount,
                          ),
                        ),
                      );
                    },
                  ),
                ),
                const SizedBox(height: 16),
                Expanded(
                  child: QuickPayManagementTile(
                    icon: Symbols.output_circle,
                    label: AppLocalizations.of(context).outsideBank,
                    subtitle: AppLocalizations.of(context).quickoutsidesubtitle,
                    onTap: () {
                      Navigator.push(
                        context,
                        MaterialPageRoute(
                          builder: (context) => QuickPayOutsideBankScreen(
                            debitAccount: widget.debitAccount,
                          ),
                        ),
                      );
                    },
                  ),
                ),
              ],
            ),
          ),
          IgnorePointer(
            child: Center(
              child: Opacity(
                opacity: 0.07, // Reduced opacity
                child: ClipOval(
                  child: Image.asset(
                    'assets/images/logo.png',
                    width: 200, // Adjust size as needed
                    height: 200, // Adjust size as needed
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

class QuickPayManagementTile extends StatelessWidget {
  final IconData icon;
  final String label;
  final String? subtitle;
  final VoidCallback onTap;
  final bool disable;

  const QuickPayManagementTile({
    super.key,
    required this.icon,
    required this.label,
    this.subtitle,
    required this.onTap,
    this.disable = false,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return Card(
      margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(12.0),
      ),
      elevation: 4, // Add some elevation for better visual separation
      child: InkWell(
        onTap:
            disable ? null : onTap, // Disable InkWell if the tile is disabled
        borderRadius: BorderRadius.circular(12.0),
        child: Padding(
          padding: const EdgeInsets.symmetric(vertical: 36.0, horizontal: 16.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(
                icon,
                size: 64, // Make icon larger for two cards
                color:
                    disable ? theme.disabledColor : theme.colorScheme.primary,
              ),
              const SizedBox(height: 16),
              Text(
                label,
                textAlign: TextAlign.center,
                style: theme.textTheme.headlineSmall?.copyWith(
                  fontWeight: FontWeight.bold,
                  color: disable
                      ? theme.disabledColor
                      : theme.colorScheme.onSurface,
                ),
              ),
              if (subtitle != null) // Conditionally display subtitle
                Padding(
                  padding: const EdgeInsets.only(top: 8.0),
                  child: Text(
                    subtitle!,
                    textAlign: TextAlign.center,
                    style: theme.textTheme.bodyMedium?.copyWith(
                      color: disable
                          ? theme.disabledColor
                          : theme.colorScheme.onSurfaceVariant,
                    ),
                  ),
                ),
            ],
          ),
        ),
      ),
    );
  }
}
