import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pshared/controllers/balance_mask/wallets.dart';

import 'package:pweb/pages/wallet_top_up/content.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';


class WalletTopUpPage extends StatelessWidget {
  final VoidCallback onBack;

  const WalletTopUpPage({super.key, required this.onBack});

  @override
  Widget build(BuildContext context) {
    final loc = AppLocalizations.of(context)!;

    return Consumer<WalletsController>(builder: (context, provider, child) {
      if (provider.isLoading) {
        return const Center(child: CircularProgressIndicator());
      }

      if (provider.error != null) {
        return Center(
          child: Text(loc.notificationError(provider.error.toString())),
        );
      }

      final wallet = provider.selectedWallet;
      if (wallet == null) {
        return Center(child: Text(loc.noWalletSelected));
      }

      return WalletTopUpContent(
        wallet: wallet,
        onBack: onBack,
      );
    });
  }
}
