import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pshared/provider/account.dart';

import 'package:pweb/widgets/vspacer.dart';

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


class LoginButton extends StatelessWidget {
  final VoidCallback? onPressed;

  const LoginButton({
    super.key,
    required this.onPressed,
  });

  @override
  Widget build(BuildContext context) => Consumer<AccountProvider>(builder: (context, provider, _) => ElevatedButton(
    onPressed: provider.isLoading ? null : onPressed,
    child: 
      Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          if (provider.isLoading) 
            ...[
              SizedBox(
                width: 20,
                height: 20,
                child: CircularProgressIndicator(),
              ),
              VSpacer(multiplier: 0.25),
            ],
          Text(AppLocalizations.of(context)!.login),
        ],
      ),
  ));
}
