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 ConsumerWidget {
  final NavigationContract navigationContract;

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

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    bool passwordVisible = true;
    return Scaffold(
      body: Expanded(
        child: Center(
          child: Container(
            margin: EdgeInsets.all(30),
            child: Column(
              spacing: 10,
              children: [
                Icon(Icons.check, color: Color(0xFF329e95), size: 50),
                Text(
                  // context.translate(I18n.example) // example to use Intl package
                  "¡Te damos la bienvenida!",
                  style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
                ),
                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: OutlineInputBorder(),
                    suffixIcon: IconButton(
                      icon: Icon(
                        passwordVisible
                            ? Icons.visibility
                            : Icons.visibility_off,
                      ),
                      onPressed: () {
                        // setState(() {
                        //   passwordVisible = !passwordVisible;
                        // });
                      },
                    ),
                  ),
                ),
                TextButton(
                  onPressed: () =>
                      navigationContract.pushTo('/recover_password'),
                  child: Text("¿Has olvidado la contraseña?"),
                ),
                FilledButton(
                  onPressed: () => navigationContract.pushTo('/main/home'),
                  child: Text("Iniciar sesión"),
                ),
                Stack(children: [Divider(), Text("o continúa con")]),
                Row(
                  spacing: 20,
                  children: [
                    OutlinedButton(
                      onPressed: () => Navigator.push(
                        context,
                        MaterialPageRoute(
                          builder: (_) => LoadingGoogleScreen(),
                        ),
                      ),
                      child: Text("Google", semanticsLabel: "Google"),
                    ),
                    OutlinedButton(
                      onPressed: () => {},
                      child: Icon(Icons.apple, semanticLabel: "Apple"),
                    ),
                  ],
                ),
                Text("¿No tienes cuenta?"),
                TextButton(
                  onPressed: () => Navigator.push(
                    context,
                    MaterialPageRoute(builder: (_) => SignupScreen()),
                  ),
                  child: Text("Crear una ahora"),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
