import 'package:auth/src/login/presentation/loading_google_screen.dart';
import 'package:auth/src/sign_up/signup_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:navigation/navigation.dart';
import 'package:sf_localizations/sf_localizations.dart';

class LoginScreen extends ConsumerStatefulWidget {
  final NavigationContract navigationContract;

  const LoginScreen({super.key, required this.navigationContract});

  @override
  ConsumerState<LoginScreen> createState() => _LoginScreenState();
}

class _LoginScreenState extends ConsumerState<LoginScreen> {
  bool passwordVisible = false;

  @override
  Widget build(BuildContext context) {
    // final l10n = SfLocalizations.of(context);

    return Scaffold(
      body: Center(
        child: Container(
          margin: const EdgeInsets.all(30),
          child: Column(
            spacing: 10,
            children: [
              const Icon(Icons.check, color: Color(0xFF329e95), size: 50),
              const Text(
                // context.translate(I18n.example)
                '¡Te damos la bienvenida!',
                style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
              ),
              const TextField(
                decoration: InputDecoration(
                  hintText: 'Nombre de usuario',
                  labelText: 'Nombre de usuario',
                  border: OutlineInputBorder(),
                ),
              ),
              TextField(
                obscureText: !passwordVisible,
                enableSuggestions: false,
                autocorrect: false,
                decoration: InputDecoration(
                  labelText: 'Contraseña',
                  hintText: '********',
                  border: const OutlineInputBorder(),
                  suffixIcon: IconButton(
                    icon: Icon(
                      passwordVisible ? Icons.visibility : Icons.visibility_off,
                    ),
                    onPressed: () {
                      setState(() {
                        passwordVisible = !passwordVisible;
                      });
                    },
                  ),
                ),
              ),
              TextButton(
                onPressed: () =>
                    widget.navigationContract.pushTo(AppRoutes.recoverPassword),
                child: const Text('¿Has olvidado la contraseña?'),
              ),
              FilledButton(
                onPressed: () =>
                    widget.navigationContract.pushTo(AppRoutes.dashboardHome),
                child: const Text('Iniciar sesión'),
              ),
              const Stack(children: [Divider(), Text('o continúa con')]),
              Row(
                spacing: 20,
                children: [
                  OutlinedButton(
                    onPressed: () => Navigator.push(
                      context,
                      MaterialPageRoute(
                        builder: (_) => const LoadingGoogleScreen(),
                      ),
                    ),
                    child: const Text('Google', semanticsLabel: 'Google'),
                  ),
                  OutlinedButton(
                    onPressed: () {},
                    child: const Icon(Icons.apple, semanticLabel: 'Apple'),
                  ),
                ],
              ),
              const Text('¿No tienes cuenta?'),
              TextButton(
                onPressed: () => Navigator.push(
                  context,
                  MaterialPageRoute(builder: (_) => const SignupScreen()),
                ),
                child: const Text('Crear una ahora'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
