import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.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(
        leading: IconButton(
          icon: const Icon(Symbols.arrow_back_ios_new),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
        title: Text(
          AppLocalizations.of(context).quickPay.replaceAll('\n', ' '),
          style:
              const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
        ),
        centerTitle: false,
        actions: [
          Padding(
            padding: const EdgeInsets.only(right: 10.0),
            child: CircleAvatar(
              backgroundColor: Colors.grey[200],
              radius: 20,
              child: SvgPicture.asset(
                'assets/images/avatar_male.svg',
                width: 40,
                height: 40,
                fit: BoxFit.cover,
              ),
            ),
          ),
        ],
      ),
      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(
            disable: true,
            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,
    );
  }
}
