import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart' show GoogleFonts;
import '../controller/login_controller.dart';

class MyLoginWidget extends StatelessWidget {
  final void Function()? onButtonPressed;
  final void Function()? signInOnTab;
  final LoginController logCtrl;

  const MyLoginWidget({
    super.key,
    this.onButtonPressed,
    this.signInOnTab,
    required this.logCtrl,
  });

  @override
  Widget build(BuildContext context) {
    final googleFont = GoogleFonts.righteous().fontFamily;
    return Column(
      children: [
        Stack(
          children: [
            // Umriss (Outline)
            Text(
              "Login Page",
              style: TextStyle(
                fontSize: 44,
                fontFamily: googleFont,
                fontStyle: FontStyle.normal,
                letterSpacing: 5.0,
                foreground: Paint()
                  ..style = PaintingStyle.stroke
                  ..strokeWidth = 5
                  ..color = Colors.blue.shade900,
              ),
            ),
            // Füllung
            Text(
              "Login Page",
              style: TextStyle(
                fontSize: 44,
                fontFamily: googleFont,
                fontStyle: FontStyle.normal,
                color: Colors.orange.shade300,
                letterSpacing: 5.0,
              ),
            ),
          ],
        ),
        SizedBox(height: 20),
        Container(
          decoration: BoxDecoration(
            border: Border.all(color: Colors.orange.shade400, width: 8),
            borderRadius: BorderRadius.circular(30),
          ),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(18),
            child: Image.asset(
              'assets/images/guru.png',
              width: 300,
              height: 300,
            ),
          ),
        ),
        SizedBox(height: 20),
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 50.0),
          child: TextField(
            controller: logCtrl.emailController,
            keyboardType: TextInputType.emailAddress,
            decoration: InputDecoration(
              border: OutlineInputBorder(),
              labelText: 'E-Mail',
            ),
          ),
        ),
        SizedBox(height: 20),
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 50.0),
          child: TextField(
            obscureText: true,
            controller: logCtrl.passwordController,
            keyboardType: TextInputType.visiblePassword,
            decoration: InputDecoration(
              border: OutlineInputBorder(),
              labelText: 'Password',
            ),
          ),
        ),
        SizedBox(height: 30),
        ElevatedButton(
          style: ButtonStyle(
            backgroundColor: WidgetStatePropertyAll<Color>(
              Colors.orange.shade500,
            ),
            foregroundColor: WidgetStatePropertyAll<Color>(
              Colors.blue.shade900,
            ),
            minimumSize: WidgetStatePropertyAll<Size>(Size(430, 60)),
          ),
          onPressed: onButtonPressed,
          child: Text(
            'Login',
            style: TextStyle(fontSize: 34, fontFamily: googleFont),
          ),
        ),
        SizedBox(height: 10),
        RichText(
          text: TextSpan(
            style: TextStyle(fontSize: 16, color: Colors.black),
            children: [
              TextSpan(text: 'Zum registrieren '),
              WidgetSpan(
                child: GestureDetector(
                  onTap: signInOnTab,
                  child: Text(
                    'Sign in',
                    style: TextStyle(
                      fontSize: 16,
                      color: Colors.blue.shade700,
                      decoration: TextDecoration.underline,
                    ),
                  ),
                ),
              ),
              TextSpan(text: ' clicken!!'),
            ],
          ),
        ),
      ],
    );
  }
}
