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: ListView(
        children: [
          QuickPayManagementTile(
            icon: Symbols.input_circle,
            label: AppLocalizations.of(context).ownBank,
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => QuickPayWithinBankScreen(
                    debitAccount: widget.debitAccount,
                  ),
                ),
              );
            },
          ),
          const Divider(height: 1),
          QuickPayManagementTile(
            icon: Symbols.output_circle,
            label: AppLocalizations.of(context).outsideBank,
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => QuickPayOutsideBankScreen(
                    debitAccount: widget.debitAccount,
                  ),
                ),
              );
            },
          ),
          const Divider(height: 1),
        ],
      ),
    );
  }
}

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

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

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: Icon(icon),
      title: Text(label),
      trailing: const Icon(Symbols.arrow_right, size: 20),
      onTap: onTap,
      enabled: !disable,
    );
  }
}
